Video Thumbnail for Lesson
14.2: GitOps (using Kluctl)

GitOps (using Kluctl)

Kluctl provides a lightweight GitOps controller that keeps your cluster in sync with configuration stored in Git. The project works similarly to ArgoCD or Flux but leverages the familiar kluctl CLI. We'll use it to continuously deploy our demo application to both staging and production.

Directory Layout

All of the files used in this lesson live in 14-cicd/kluctl-gitops:

  • deployment.yaml – top‑level deployment that installs the Kluctl controller and web UI.
  • clusters/ – per‑cluster configuration. Each cluster contains a KluctlDeployment pointing back to our repo.
  • Taskfile.yaml – helper tasks for deploying and interacting with the controller.
version: "3"
tasks:
  deploy-staging-cluster:
    desc: "Deploy kluctl gitops staging target"
    cmds:
      - kluctl deploy -t staging

  deploy-production-cluster:
    desc: "Deploy kluctl gitops production target"
    cmds:
      - kluctl deploy -t production

Bootstrapping the Controller

  1. Deploy the controller into each cluster:
# task deploy-staging-cluster
# task deploy-production-cluster
  1. Retrieve the web UI password and port forward the service:
# task get-webui-password
# task port-forward-webui

Access http://localhost:8080 and log in as admin using the password from the secret. The interface shows the status of each KluctlDeployment and lets you trigger manual reconciliations.

Automatic Deployments

Each KluctlDeployment polls Git every five minutes. When new manifests are merged, the controller automatically applies them and prunes resources that no longer exist in Git.

Our GitHub Action builds container images and updates the manifests with the new tags. Once that pull request merges, Kluctl detects the update and rolls out the new images to staging and production.

Releases work the same way: tagging the repository kicks off the build pipeline, pushes images with the tag, and opens a PR updating the manifests. Merging the PR triggers the controller to deploy the release.


With Kluctl managing our clusters we have a fully automated path from GitHub to Kubernetes.