Local Cluster Testing with Kind & Registry

Overview

Iterating on infrastructure directly against cloud VMs is slow, expensive, and error-prone. To enable fast, deterministic development, infra-bootstrap-tools provides a completely local end-to-end testing harness that mirrors production cloud clusters.

Using Kind (Kubernetes in Docker) and a local OCI container registry, you can bootstrap the entire Flux D2 GitOps pipeline, deploy OpenZiti, and verify zero-trust networking right on your workstation.


The One-Command Workflow

You can spin up the test environment and run the full verification test suite with a single command:

make test-flux-d2

This automated target executes two coordinated steps:

  1. Provisions a local Kind cluster and Docker container registry (bin/k8s/setup-kind-local-registry.sh).
  2. Pushes the local monorepo manifests as OCI artifacts and validates cluster reconciliation (bin/tests/flux-d2/test.sh).

Under the Hood: Architecture of the Test Harness

The test harness runs entirely on the developer workstation:

  1. Local Docker Registry (localhost:5000):

    • Manifests packaged and pushed via flux push artifact:
      • oci://localhost:5000/manifests/fleet/kind:latest
      • oci://localhost:5000/manifests/infra-addons:latest
  2. Local Kind Cluster (kindest/node:v1.32.0):

    • containerd configuration wired to route localhost:5000 to the local registry container.
    • Flux Operator installed via Helm.
    • Reconciles fleet/kind/flux-system/flux-instance.yaml.
    • Deploys and validates cert-manager, trust-manager, keycloak, and openziti.

Stable Node Images

The Kind cluster configuration explicitly pins the node image to kindest/node:v1.32.0. This prevents sudden breakages caused by bleeding-edge upstream Kubernetes releases (such as v1.35.0 system changes) and guarantees parity with CI test runners (.github/workflows/flux-d2-test.yml).


Verification Assertions

The test script (bin/tests/flux-d2/test.sh) does not merely check if pods are scheduled; it performs deep, end-to-end functional assertions:

  1. OCI Artifact Sync: Verifies that OCIRepository/flux-system and OCIRepository/infra-addons pull artifacts from localhost:5000 without authentication errors.
  2. Kustomization Health: Monitors kustomization/infra-addons-values and kustomization/infra-addons until both report status: "True" and reason: ReconciliationSucceeded.
  3. Trust & Certificate Infrastructure: Confirms cert-manager and trust-manager pods achieve Ready status and bundle webhooks respond.
  4. Identity & OpenZiti Mesh:
    • Asserts the local Keycloak deployment enters ready state.
    • Waits for the ziti-controller deployment to pass health checks.
    • Monitors the ziti-router-enroll Job to ensure automated token generation and router enrollment succeed (SuccessfulCreate).
    • Asserts the ziti-router HelmRelease and pods achieve full readiness.

Development Environment Setup

All required CLIs (kind, kubectl, helm, flux, docker) are packaged into the dedicated Nix development shell:

# Enter the Flux-focused Nix environment
nix develop .#flux

# Run tests
make test-flux-d2

Useful Troubleshooting Commands

While the cluster is running, you can inspect the GitOps status interactively:

# View all Flux resources and synchronization status
flux get all -A

# Check for HelmRelease reconciliation errors
flux get helmreleases -A

# Inspect router enrollment logs
kubectl logs -n openziti job/ziti-router-enroll

# Destroy the local test cluster when done
kind delete cluster --name kind
docker rm -f kind-registry