Deploying Local Zarf Packages
Introduction
In this tutorial, we are going to deploy the WordPress package onto your cluster using the package we created in the earlier create a package tutorial and the cluster we initialized in the initialize a k8s cluster tutorial. We will be leveraging that past work to go the extra step of deploying an application we packaged onto our cluster with the zarf package deploy
command.
System Requirements
- You'll need a machine that has access to a built-package and an initialized cluster.
Prerequisites
Prior to this tutorial you'll want to have a built package and a working cluster with Zarf initialized.
- Zarf binary installed on your $PATH: (Installing Zarf)
- An initialized cluster
- The WordPress package created
Deploying the WordPress package
- Use the
zarf package deploy
command to deploy the package you built in a the previous tutorial (see prerequisites).
If you do not provide the path to the package as an argument to the zarf package deploy
command, Zarf will prompt you asking for you to choose which package you want to deploy. You can use the tab
key, to be prompted for available packages in the current working directory.
By hitting 'tab', you can use the arrow keys to select which package you want to deploy. Since we are deploying the WordPress package in this tutorial, we will select that package and hit 'enter'.
- You will be presented with a chance to review the SBOMs for the package along with its definition followed by a series of prompts for each variable we setup in the previous tutorial. To confirm package deployment press
y
thenenter
and input a value for each variable when prompted followed byenter
for them as well.
To accept a default value for a given variable, simply press the enter
key. You can also set variables from the CLI with the --set
flag, an environment variable, or a config file.
- Because we included the connect services in the previous tutorial we can quickly test our package in a browser with
zarf connect wordpress-blog
.
- We can also explore the resources deployed by our package by running the
zarf tools monitor
command to startK9s
. Once you are done, hitctrl/control c
to exit.
Deploying packages isn't the only way to interact with them in the air gap. If you would like to quickly inspect a package and it's SBOMs you can use zarf package inspect
to view them, and if you would like to push resources inside of a Zarf package (i.e. the images in this Wordpress package) to services in the air gap without running a deployment, you can do so with zarf package mirror-resources
.
Removal
- Use the
zarf package list
command to get a list of the installed packages. This will give you the name of the WordPress package to remove it.
- Use the
zarf package remove
command to remove thewordpress
package. Don't forget the--confirm
flag. Otherwise you'll receive an error.
- You can also use the
zarf package remove
command with the zarf package file, to remove the package. Again, don't forget the--confirm
flag.
The wordpress
package has now been removed from your cluster.
Troubleshooting
Unable to connect to the Kubernetes cluster
If you receive this error, either you don't have a Kubernetes cluster, your cluster is down, or your cluster is unreachable.
- Check your kubectl configuration, then try again. For more information about kubectl configuration see Configure Access to Multiple Clusters from the Kubernetes documentation.
If you need to setup a cluster, you can perform the following.
- Deploy a Kubernetes cluster with the Creating a K8s Cluster with Zarf tutorial.
- Perform the Initialize a cluster tutorial.
After that you can try deploying the package again.
Secrets "zarf-state" not found
If you receive this error when zarf is attempting to deploy a package, this means you have not initialized the kubernetes cluster. This is one of the prerequisites for this tutorial. Perform the Initialize a cluster tutorial, then try again.