This example demonstrates using Zarf to deploy a simple operator example, in this case Strimzi Kafka Operator.
Here's what you'll do in this example:
Before the magic can happen you have to do a few things:
-
Install Docker. Other container engines will likely work as well but aren't actively tested by the Zarf team.
-
Install KinD. Other Kubernetes distros will work as well, but we'll be using KinD for this example since it is easy and tested frequently and thoroughly.
-
Clone the Zarf project — for the example configuration files.
-
Download a Zarf release — you need a binary and an init package, here.
You can't run software without somewhere to run it, so the first thing to do is create a local Kubernetes cluster that Zarf can deploy to. In this example we'll be using KinD to create a lightweight, local K8s cluster running in Docker.
Kick that off by running this command:
kind create cluster
This will result in a single-node Kubernetes cluster called kind-kind
on your local machine running in Docker. Your KUBECONFIG should be automatically configured to talk to the new cluster.
cd <same dir as zarf-init-<arch>.tar.zst>
zarf init
Follow the prompts, answering "no" to each of the optional components, since we don't need them for this deployment.
Congratulations! Your machine is now running a single-node Kubernetes cluster powered by Zarf!
Note
Zarf supports non-interactive installs too! Give
zarf init --confirm --components logging
a try next time.
Troubleshooting:
ERROR: Unable to find the package on the local system, expected package at zarf-init-.tar.zst
The zarf binary needs an init package to know how to setup your cluster! So, if
zarf init
returns an error like this:ERROR: Unable to find the package on the local system, expected package at zarf-init-<arch>.tar.zstIt's likely you've either forgotten to download
zarf-init-<arch>.tar.zst
(as part of getting ready) OR you are not runningzarf init
from the directory the init package is sitting in.
ERROR: failed to create cluster: node(s) already exist for a cluster with the name "kind"
You already have a KinD cluster running. Either just move on to use the current cluster, or run
kind delete cluster
, thenkind create cluster
.
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Docker isn't running or you're otherwise not able to talk to it. Check your Docker installation, then try again.
Zarf is (at heart) a tool for making it easy to get software from where you have it to where you need it—specifically, across an airgap. Since moving bits is so core to Zarf the idea of a "ready-to-move group of software" has a specific name—the package.
All of the software a Zarf cluster runs is installed via package—for many reasons like versioning, auditability, etc—which means that if you want to run a in your cluster you're going to have to build a package for it.
Luckily, this is very easy to do—package contents are defined by simple, declarative yaml files and we've already made one for you. To build this package you simply:
cd <zarf dir>/examples/tiny-kafka # directory with zarf.yaml, and
zarf package create --confirm # make the package
Watch the terminal scroll for a while. Once things are downloaded & zipped up and you'll see a file ending in .tar.zst
drop. That's your package.
It's time to feed the package you built into your cluster.
Since you're running a Zarf cluster directly on your local machine—where this package & zarf
binary already are—deploying the package is very simple:
zarf package deploy zarf-package-kafka-strimzi-demo-amd64.tar.zst --confirm
In a couple seconds the cluster will have loaded your package.
Testing will require JDK and the kafka tools: sudo apt install openjdk-14-jdk-headless
for Ubuntu. More details can be found at https://kafka.apache.org/quickstart. Steps to test:
- Install JDK and extract the Kafka tools from the package
kafka.tgz
- Get the Nodeport:
NODEPORT=$(kubectl get service demo-kafka-external-bootstrap -n kafka-demo -o=jsonpath='{.spec.ports[0].nodePort}{"\n"}')
- For pub:
./bin/kafka-console-producer.sh --broker-list localhost:$NODEPORT --topic cool-topic
- For sub:
./bin/kafka-console-consumer.sh --bootstrap-server localhost:$NODEPORT --topic cool-topic
Once you've had your fun it's time to clean up.
In this case, since the Zarf cluster was installed specifically (and only) to serve this example, clean up is really easy—you just tear down the entire cluster:
kind delete cluster
It only takes a couple moments for the entire cluster to disappear—long-running system services and all—leaving your machine ready for the next adventure.