Skip to content

ci(k8s): test discovery against a KIND cluster instead of SANDBOX - #866

Merged
stewartshea merged 2 commits into
mainfrom
ci/kind-k8s-tests
Nov 2, 2026
Merged

stewartshea merged 2 commits into
mainfrom
ci/kind-k8s-tests

Conversation

@stewartshea

Copy link
Copy Markdown
Contributor

What

The Discovery K8s Tests workflow depended on secrets.SANDBOX_KUBECONFIG and the shared SANDBOX cluster's ci-verify-basic namespace. This replaces that with a disposable KIND cluster created per test job.

Changes

  • .github/workflows/test-k8s.yaml — drops SANDBOX_KUBECONFIG; calls .test/k8s/basic/kind-up.sh rwl-ci, then runs the task with RWL_CONTAINER_NETWORK: kind. Adds .test/k8s/** to the PR path filter.
  • .test/k8s/basic/kind-up.sh (new) — creates/reuses a rwl-ci KIND cluster (kindest/node:v1.31.0), applies the fixture, exports kubeconfig.secret. Auto-installs kind on Linux; requires it on macOS.
  • .test/k8s/basic/kind/ci-verify-basic.yaml (new) — mirrors the SANDBOX fixture (runwhen/infra-flux-nonprod-sandbox/apps/ci-verify-basic): Namespace + podinfo Deployment + Service + Ingress. Discovery only reads those API objects, so SLX counts are driven by resource types.
  • .test/k8s/basic/Taskfile.yaml — context renamed sandbox-cluster-1 → kind-rwl-ci.
  • .test/k8s/basic/_discovery_common.sh — honours RWL_CONTAINER_NETWORK to attach the container to a Docker network.
  • .test/k8s/basic/README.md — documents local KIND usage.
  • .test/k8s/upload/ — removed; it required a SaaS upload service we no longer operate.

How the container reaches the cluster

KIND publishes its API on a random 127.0.0.1 port that a bridge container can't reach. kind-up.sh rewrites the exported kubeconfig to the control-plane container's IP on the kind Docker network (in the API server cert SANs via the kubeadm advertise address, so TLS verification still holds — no insecure flag), and the test container joins that same network. Air-gap --add-host flags keep working because this is a bridge network, not --network host.

Testing

  • ci-test-1 (basic) and ci-test-2 (detailed) SLX assertions are minimums (>=5, >=12) carried over from the SANDBOX namespace; the fixture reproduces the same indexed resource types, so they should hold. A live CI run is the confirmation.
  • Not in scope: .github/workflows/test-aks.yaml still uses SANDBOX_KUBECONFIG for its real AKS coverage.

The Discovery K8s Tests workflow depended on secrets.SANDBOX_KUBECONFIG and
the shared SANDBOX cluster's ci-verify-basic namespace. Replace that with a
disposable KIND cluster created per test job:

- .test/k8s/basic/kind-up.sh creates/reuses a 'rwl-ci' KIND cluster, applies
  the ci-verify-basic fixture, and exports a kubeconfig pointing at the
  control-plane IP on the kind Docker network.
- .test/k8s/basic/kind/ci-verify-basic.yaml mirrors the SANDBOX fixture
  (Namespace + podinfo Deployment/Service + Ingress) so the existing >=5 (basic)
  and >=12 (detailed) SLX minimums still hold.
- _discovery_common.sh honours RWL_CONTAINER_NETWORK so the RunWhen Local
  container joins the kind network; CI sets it to 'kind'.
- Test Taskfiles now use the 'kind-rwl-ci' context; README documents local use.
- Remove the .test/k8s/upload harness, which required a SaaS upload service.

Workflow also triggers on .test/k8s/** changes.
ci-test-2 (detailed LOD) produced 11 SLXs against KIND vs the SANDBOX
baseline of 12. The missing SLX comes from the detailed-only
k8s-fluxcd-helm-health generation rule, which matches
helmreleases.helm.toolkit.fluxcd.io -- the SANDBOX ci-verify-basic namespace
had a Flux HelmRelease that the first fixture pass omitted.

Add a HelmRelease to the fixture plus a minimal local CRD (kind/crds/) so it
is served and indexed without a full Flux install or network fetch. Basic LOD
is unaffected (the rule is detailed-only), and ci-test-1 still expects 5.
@stewartshea
stewartshea merged commit c4a282e into main Nov 2, 2026
5 checks passed
@stewartshea
stewartshea deleted the ci/kind-k8s-tests branch November 2, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant