Tutorial 02
Local setup and first run
These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.
In this tutorial you will deploy one tiny Kix cluster to kind, port-forward to it, and make one config edit. The point is to feel the loop:
- Edit the cluster or package.
- Check what Kix can prove before touching the cluster.
- Deploy the checked activation.
- Verify with
kix port-forward,curl, orkubectl.
Prerequisites
Section titled “Prerequisites”- Read Orientation: what Kix is and why it exists.
- Have Docker, Colima, or OrbStack running.
- Have
kind,kubectl, and Kix available. The next section shows how to installkix.
Start From The Example Repo
Section titled “Start From The Example Repo”The runnable examples live in the kix-examples repo:
❱ git clone https://github.com/kix-run/kix-examples.git❱ cd kix-examples If you already have the repo, use that checkout instead. The commands below assume you are at the repo root.
Open the files for the first example:
1flake.nix2tutorials/02-hello-world/cluster.nix3tutorials/02-hello-world/README.md4kind-config.yamlYou do not need to understand all of them yet. For now:
flake.nixexposes the example clusters by name;tutorials/02-hello-world/cluster.nixdefines the first cluster;kind-config.yamlcreates a local kind cluster namedkix-demo.
Enter A Shell With The Tools
Section titled “Enter A Shell With The Tools”If your machine already has kix, kind, and kubectl on PATH, you can use
your normal shell. If you have not installed kix yet, follow
Install and run Kix
to download and unpack the release archive into ~/.local.
Keep Docker, Colima, or OrbStack running separately. kind needs a Docker-compatible daemon to create the local cluster.
Check that Kix can see the example clusters:
❱ kix list clusters
NAME
02-hello-world
06-service-dep
08-namespace-deps
09-typed-options
10-reuse-packages
19-scorecards
homelab-kind
homelab-kind-db-resize
homelab-kind-env-stamped
homelab-kind-env-stamped-dev-change
homelab-kind-gateway
homelab-kind-gateway-migrate
homelab-kind-ns-rename
homelab-kind-pg17
homelab-kind-pvc-resize
homelab-kind-storage-migrate
homelab-kind-tls
homelab-kind-tls-migrate
homelab-kind-upgrade-broad
homelab-kind-upgrade-small
how-to-adoption
how-to-adoption-takeover
how-to-application
how-to-auto-instantiation
how-to-composition
how-to-fragments
how-to-helm-bridge
how-to-multi-env
how-to-package-cilium
how-to-package-monitoring
how-to-package-monitoring-loki
how-to-package-stackgres
how-to-package-storage
how-to-package-valkey
how-to-package-velero
how-to-package-victoria-metrics
how-to-platform-cloudflare-tunnel
how-to-platform-gateway
how-to-platform-hostpath
how-to-platform-ingress
how-to-platform-monitoring
how-to-platform-network-policy
how-to-platform-secrets
how-to-platform-sops
how-to-stateful-migration You should see 02-hello-world in the output. If you are not in the example
repo, point Kix at it explicitly:
❱ kix --flake /path/to/kix-examples list clusters The --flake flag tells Kix which flake to evaluate. Without it, Kix uses the
current directory.
Create The Local Cluster
Section titled “Create The Local Cluster”Start Docker, then create the kind cluster:
❱ kind create cluster --config kind-config.yaml This creates a single-node cluster named kix-demo and sets your current
kubectl context to kind-kix-demo.
Check that Kubernetes is reachable:
❱ kubectl cluster-info
Kubernetes control plane is running at https://127.0.0.1:39863
CoreDNS is running at https://127.0.0.1:39863/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. ❱ kubectl get nodes
NAME STATUS ROLES AGE VERSION
kix-docs-control-plane NotReady control-plane 5s v1.35.0 If you already have this kind cluster, kind will say it exists. That is fine;
continue with the deploy step.
Your First Kix Deployment
Section titled “Your First Kix Deployment”Deploy the first Kix example:
❱ kix deploy 02-hello-world -y Show outputHide output · 56 lines
Building cluster '02-hello-world'...
Cluster 02-hello-world: 9 manifests
Connecting to context kind-kix-docs (https://127.0.0.1:39863)...
No previous deployment record on the cluster. First deploy.
Note: Cluster '02-hello-world' does not set `cluster.kubernetes.uid`, so Kix continues without checking that context kind-kix-docs (https://127.0.0.1:39863) is the right Kubernetes cluster.
If this is the right cluster, set `cluster.kubernetes.uid = "30309af6-078a-421d-ae40-61d8919c6b89";` in the '02-hello-world' cluster definition. Once set, Kix refuses to deploy '02-hello-world' to any other cluster. See https://kix.run/docs/how-to/operate-a-cluster/bind-a-cluster-definition-to-its-kubernetes-cluster/.
_cluster
~ cluster-level resources (1 changed, 1 added)
kube-system
+ platform-dns (0 resources)
+ platform-storage (0 resources)
tutorial-02
+ hello-world 1.30.6 (3 resources)
Plan: 3 added, plus cluster-level changes
Resources: 2 changed in content, 0 tracking annotation only (no spec change or restart)
Not checked by the dry run (7); their changes come from comparing builds:
? 4 uses a Kix CustomResourceDefinition that Kix installs when the deploy starts:
Activation.kix.run/02-hello-world-gixxaxm2m4qj
PackageInstance.kix.run/hello-world@tutorial-02
PackageInstance.kix.run/platform-dns@kube-system
PackageInstance.kix.run/platform-storage@kube-system
? 3 is in a Namespace created by this deploy:
ConfigMap/hello-world@tutorial-02
Deployment.apps/hello-world@tutorial-02
Service/hello-world@tutorial-02
Not checked by any preview: whether Pods start, pull their images, and pass their readiness probes.
Objects: 9 to write, 0 to delete (sha256:ffdf30fcb895c54707b2f460707ea454059ab2e7391357dd64ef826d1ae8453b)
plan: 9 nodes
+ Namespace/tutorial-02 created
~ Namespace/kube-system configured
✔ Namespace/tutorial-02 ready
✔ Namespace/kube-system ready
+ ConfigMap/hello-world@tutorial-02 created
✔ ConfigMap/hello-world@tutorial-02 ready
+ PackageInstance.kix.run/platform-storage@kube-system created
+ PackageInstance.kix.run/platform-dns@kube-system created
+ Deployment.apps/hello-world@tutorial-02 created
✔ PackageInstance.kix.run/platform-storage@kube-system ready
… PackageInstance.kix.run/platform-dns@kube-system waiting: Service exists, waiting for ready endpoints (14s of 180s); 1 object waits for it: Activation.kix.run/02-hello-world-gixxaxm2m4qj
… Deployment.apps/hello-world@tutorial-02 waiting: Deployment/hello-world: 0/1 updated pods ready; pod hello-world-7db457dd6b-4z5j7 cannot be scheduled: 0/1 nodes are available: 1 node(s) had untolerated taint(s). no new claims to deallocate, preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling. (idle 10s) (14s of 180s); 3 objects wait for it: Service/hello-world@tutorial-02 and 2 more
✔ PackageInstance.kix.run/platform-dns@kube-system ready
✔ Deployment.apps/hello-world@tutorial-02 ready
+ Service/hello-world@tutorial-02 created
✔ Service/hello-world@tutorial-02 ready
+ PackageInstance.kix.run/hello-world@tutorial-02 created
✔ PackageInstance.kix.run/hello-world@tutorial-02 ready
~ Activation.kix.run/02-hello-world-gixxaxm2m4qj configured
✔ Activation.kix.run/02-hello-world-gixxaxm2m4qj ready
• activation '02-hello-world-gixxaxm2m4qj' → Active
Deploy complete: 7 created, 2 configured, 0 unchanged, 0 failed The -y flag skips the confirmation prompt. On the first deploy, Kix builds the
cluster, sees there is no previous activation, and applies the resources
wave-by-wave. The order you see comes from the deploy graph.
List the packages installed in this Kix cluster:
❱ kix list packages 02-hello-world
NAME VERSION OWNER STATUS
hello-world 1.30.6 app-team installed [tutorial-02]
platform-dns - - import [kube-system]
platform-storage - - import [kube-system] You should see an installed hello-world instance. The import rows are
platform pieces (DNS, storage) Kix pulls in automatically; later tutorials
explain them. You can also ask Kubernetes
directly:
❱ kubectl get pods -n tutorial-02
NAME READY STATUS RESTARTS AGE
hello-world-7db457dd6b-4z5j7 1/1 Running 0 24s❱ kubectl get svc -n tutorial-02
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-world ClusterIP 10.96.10.237 <none> 80/TCP 1s Reach The Service
Section titled “Reach The Service”The first example installs an echo-server package instance named
hello-world. Use kix port-forward to port-forward to its primary workload:
❱ kix port-forward 02-hello-world hello-world 8080:8080 Leave that command running. In another terminal, call the service:
❱ curl http://localhost:8080/
Hello from Kix! Stop the port-forward with Ctrl-C.
kix port-forward resolves the package instance to the workload Kix built, then delegates
to kubectl port-forward. The package name can also be written as
namespace/name when a cluster has duplicate instance names, but this first
cluster only has one.
Make One Edit
Section titled “Make One Edit”Open tutorials/02-hello-world/cluster.nix and find this instance:
48 hello-world = {49 # `packages.echo-server` ships in the public kixpkgs50 # repository, along with many others.51 # It serves a simple fixed message over HTTP.52 package = packages.echo-server;53
54 # `config` is whatever the package's options accept.55 # echo-server's `message` becomes the body of every response.56 config = {57 message = "Hello from Kix!";58 };59 };Change the message:
1config = {2 message = "Hello from my laptop!";3};Deploy again:
❱ kix deploy 02-hello-world -y Show outputHide output · 29 lines
Building cluster '02-hello-world'...
Cluster 02-hello-world: 9 manifests
Connecting to context kind-kix-docs (https://127.0.0.1:39863)...
Current deployment: 02-hello-world-gixxaxm2m4qj (build gixxaxm2...)
tutorial-02
~ hello-world 1.30.6 (2 changed, 2 tracking annotation only)
Plan: 1 updated, 2 unchanged
Resources: 2 changed in content, 2 tracking annotation only (no spec change or restart)
Not checked by any preview: whether Pods start, pull their images, and pass their readiness probes.
Objects: 5 to write, 0 to delete (sha256:da9557d7adf9489eddab3373525df132a290cb717ee24b666c553361be4233ba)
plan: 9 nodes
~ ConfigMap/hello-world@tutorial-02 configured
✔ ConfigMap/hello-world@tutorial-02 ready
~ Deployment.apps/hello-world@tutorial-02 configured
✔ Deployment.apps/hello-world@tutorial-02 ready
~ Service/hello-world@tutorial-02 configured
✔ Service/hello-world@tutorial-02 ready
~ PackageInstance.kix.run/hello-world@tutorial-02 configured
✔ PackageInstance.kix.run/hello-world@tutorial-02 ready
~ Activation.kix.run/02-hello-world-f08rlc2rinfm configured
✔ Activation.kix.run/02-hello-world-f08rlc2rinfm ready
• activation '02-hello-world-gixxaxm2m4qj' → Superseded
• activation '02-hello-world-f08rlc2rinfm' → Active
Deploy complete: 0 created, 5 configured, 4 unchanged, 0 failed Port-forward and curl again:
❱ kix port-forward 02-hello-world hello-world 8080:8080 In another terminal:
❱ curl http://localhost:8080/
Hello from my laptop! The response should show your new message.
That edit is small, but it proves the core loop: Kix evaluated the flake, rebuilt the manifests, applied the changed workload, and left you with a normal Kubernetes Service and Pod.
Before Moving On
Section titled “Before Moving On”You have now used:
kix list clustersto discover cluster names;kix deploy <cluster> -yto apply one cluster;kix list packages <cluster>to inspect installed packages;kix port-forward <cluster> <package> <local>:<remote>to reach a workload.
The next tutorial steps back from the running cluster and looks at the repo shape that made those commands work.