Skip to main content

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.

System Requirements

  • root access on a Linux machine
REQUIRES ROOT

The 'k3s' component requires root access (not just sudo!) when deploying as it will modify your host machine to install the cluster.

Prerequisites

Before beginning this tutorial you will need the following:

Creating the Cluster

  1. Run the zarf init command as root.
# zarf init
  1. Confirm Package Deployment:
  • When prompted to deploy the package select y for Yes, then hit the enter key.
  1. Confirm k3s Component Deployment:
  • When prompted to deploy the k3s component select y for Yes, then hit the enter key.
tip

You can automatically accept the k3s component and confirm the package using the --components and --confirm flags.

$ zarf init --components="k3s" --confirm

Validating the Deployment

After the zarf init command is done running, you should see a k3s cluster running and a few zarf pods in the Kubernetes cluster.

# zarf tools monitor
note

You can press 0 if you want to see all namespaces and CTRL-C to exit

Accessing the Cluster as a Normal User

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/config

Cleaning Up

The zarf destroy command will remove all of the resources, including the k3s cluster, that was created by the initialization command.

zarf destroy --confirm