Common CLI Uses
Zarf is a tool that optimizes the delivery of applications and capabilities into various environments, starting with air-gapped systems. This is achieved by using Zarf Packages, which are declarative files that the Zarf CLI uses to create, deploy, inspect, and remove applications and capabilities.
zarf package create
To create a Zarf Package, you must execute the
zarf package create command, which generates a tarball archive that includes all the required dependencies and instructions to deploy the capabilities onto another machine. The
zarf package create command uses a
zarf.yaml configuration file that describes the package's components and performs all necessary actions, such as downloading container images and git repositories, to build the final package.
Initializing a Cluster:
Before deploying a package to a cluster, you must initialize the cluster using the
zarf init command. This command creates and bootstraps an in-cluster container registry and provides the option to install optional tools and services necessary for future packages.
For Linux environments, Zarf itself can create and update a local K3s cluster, in addition to using any other local or remote Kubernetes cluster. The init package used by
zarf init contains all the resources necessary to create a local K3s cluster on your machine. This package may be located in your current working directory, the directory where the Zarf CLI binary is located, or downloaded from GitHub releases during command execution.
Depending on the permissions of your user, if you are installing K3s with
zarf init, you may need to run it as a privileged user. This can be done by either:
- Becoming a privileged user via the command
sudo suand then running all the Zarf commands as you normally would.
- Manually running all the Zarf commands as a privileged user via the command
- Running the init command as a privileged user via
sudo zarf initand then changing the permissions of the
~/.kube/configfile to be readable by the current user.
zarf package deploy
zarf package deploy command deploys the packaged capabilities into the target environment. The package can be deployed on any cluster, even those without an external internet connection, since it includes all of its external resources. The external resources are pushed into the cluster to services Zarf either deployed itself or that it was told about on
init, such as the init package's Gitea Git server or a pre-existing Harbor image registry. Then, the application is deployed according to the instructions in the zarf.yaml file, such as deploying a helm chart, deploying raw K8s manifests, or executing a series of shell commands. Generally, it is presumed that the
zarf init command has already been executed on the target machine. However, there are a few exceptional cases where this assumption does not apply, such as YOLO Mode.