Creating a K8s Cluster with Zarf
In this tutorial, we will demonstrate how to use Zarf on a fresh Linux machine to deploy a k3s cluster through Zarf’s k3s component.
rootaccess on a Linux machine
Before beginning this tutorial you will need the following:
- The Zarf repository cloned: (
git cloneInstructions) - Zarf binary installed on your $PATH: (Installing Zarf)
- An init-package built/downloaded: (init-package Build Instructions) or (Download Location)
- Run the
zarf initcommand asroot.
# zarf init- Confirm Package Deployment:
- When prompted to deploy the package select
yfor Yes, then hit theenterkey.
- Confirm k3s Component Deployment:
- When prompted to deploy the k3s component select
yfor Yes, then hit theenterkey.
After the zarf init command is done running, you should see a k3s cluster running and a few zarf pods in the zarf namespace.
By default, the k3s component will only automatically provide cluster access to the root user. To access the cluster as another user, you can run the following to setup the ~/.kube/config file:
# cp /root/.kube/config /home/otheruser/.kube# chown otheruser /home/otheruser/.kube/config# chgrp otheruser /home/otheruser/.kube/configThe zarf destroy command will remove all of the resources, including the k3s cluster, that was created by the initialization command.
zarf destroy --confirm