Kind labs

Create ConfigMaps with approval, compare OPA decisions and recover from drift in a local Kind cluster.

All hands-on labs

Run these exercises in the disposable cluster from Quickstart with Kind, where the first direct apply creates the hello-stack ConfigMap. All resources and IaC state stay in Kubernetes. No AWS account, credentials, S3 bucket or EKS cluster is needed.

ExerciseWhat you will observe
Direct applyThe runner validates, plans and creates a ConfigMap without a gate.
Manual approvalA human reviews the saved plan and chooses whether to apply it; no OPA evaluation.
OPA governanceRego allows one planned ConfigMap and denies another.
DriftAn out-of-band edit is corrected on the next periodic check.

Prepare the workflow examples

For approval and OPA, stay in the quickstart directory from the installation and keep the kind-iacstack-quickstart context. You need jq to inspect Argo status and a default StorageClass so Argo can provision a workspace PVC. Allow the direct attempt to finish before upgrading the chart. The drift exercise uses only the direct workflow and can be run without this preparation.

test "$(kubectl config current-context)" = kind-iacstack-quickstart || {
  printf '%s\n' 'Select kind-iacstack-quickstart before continuing.' >&2
  exit 1
}
kubectl get storageclass
CHART=oci://ghcr.io/iacstack/charts/iacstack-controller
CHART_VERSION=0.1.0-alpha.2
curl -fsSL "https://iacstack.io/examples/download-consumer.sh" -o download-consumer.sh && bash download-consumer.sh || exit 1
curl -fsSL "https://iacstack.io/examples/download-kind-lab.sh" -o download-kind-lab.sh && bash download-kind-lab.sh || exit 1
kubectl apply -k consumer
kubectl apply -f kind-lab/manual-workflow.yaml
helm upgrade iacstack-controller "$CHART" --version "$CHART_VERSION" \
  --namespace platform-system --values kind-lab/controller-values.yaml --wait --timeout 4m

Inspect the workflow alias values, manual workflow and governed workflow. The Helm values preserve the direct alias and register manual-lab and governed-lab. These workflows use the account and namespace-scoped permissions from the quickstart; the consumer manifests add claim permissions for their three named stacks. Do not use these values to overwrite an unrelated controller installation.

Where is the logic? Both workflows call the same plan and apply scripts. Kustomize puts the scripts and the Rego rule in separate ConfigMaps. Only the OPA workflow reads the rule. In both, review the plan in the Argo log. See the EKS lab file map for examples of optional HTML reports.

1. Manual approval

The manual stack selects manual-lab. Argo reuses the published plan and apply steps, but a human decides after reading the plan. The inspect-plan step checks only whether the plan has changes; it does not run Rego. If a plan has no changes during normal reconciliation, the workflow reports NoChanges without asking for approval.

kubectl apply -f kind-lab/manual.yaml
kubectl -n platform-system get iacstack consumer-manual -w

When the stack is waiting for approval, stop the watch with Ctrl+C. The ConfigMap should still be absent. Find the Workflow and the pending approval node:

kubectl -n iacstack-quickstart get configmap consumer-manual --ignore-not-found
WORKFLOW=$(kubectl -n platform-system get iacstack consumer-manual \
  -o jsonpath='{.status.execution.workflow}')
NODE_ID=$(kubectl -n argo-workflows get workflow "$WORKFLOW" -o json |
  jq -er '.status.nodes | to_entries[] | select(.value.type == "Suspend" and .value.phase == "Running") | .key')
printf '%s\n' "$WORKFLOW" "$NODE_ID"

In the Argo UI, open that Workflow and read the plan node logs. With the default server from the quickstart, you can also stream logs from the terminal:

kubectl -n argo-workflows exec deployment/argo-workflows-server -- \
  argo -n argo-workflows logs "$WORKFLOW"

Choose Approve only after confirming the plan creates the lab ConfigMap. To try rejection instead, replace Approve with Reject in the block below.

DECISION=Approve
test -n "$NODE_ID" && kubectl -n argo-workflows exec deployment/argo-workflows-server -- \
  argo -n argo-workflows node set "$WORKFLOW" \
  --node-field-selector "id=$NODE_ID,phase=Running" \
  --output-parameter "approval=$DECISION" --phase Succeeded

Wait for the workflow to finish, then verify the target and the stack:

kubectl -n platform-system get iacstack consumer-manual \
  -o jsonpath='{.status.result.outcome}{" "}{.status.result.reason}{"\n"}'
kubectl -n iacstack-quickstart get configmap consumer-manual --ignore-not-found \
  -o jsonpath='{.data.message}{"\n"}'

Approve: the saved plan applies and the value is Hello from manual. Reject on first creation: the stack reports ApprovalRejected and the ConfigMap is absent. To open a new attempt for the opposite decision, change spec.inputs.message in kind-lab/manual.yaml, apply it again and fetch the new Workflow name. Rejecting an update preserves the previous value.

2. OPA governance

Both auto.yaml and deny.yaml select governed-lab. The policy node evaluates the sample policy.rego against the plan summary. The templates use different policy_mode inputs to demonstrate two outcomes, not a production policy.

kubectl apply -f consumer/auto.yaml -f consumer/deny.yaml
kubectl -n platform-system get iacstack consumer-auto consumer-deny -w

Once both attempts finish, stop the watch. Open the corresponding Workflows from each stack’s status.execution.workflow and inspect the policy node output. Expect AutoApply for consumer-auto and Deny for consumer-deny. Verify that only the allowed ConfigMap exists:

kubectl -n iacstack-quickstart get configmap consumer-auto \
  -o jsonpath='{.data.message}{"\n"}'
kubectl -n iacstack-quickstart get configmap consumer-deny --ignore-not-found
kubectl -n platform-system get iacstack consumer-deny \
  -o jsonpath='{.status.result.reason}{"\n"}'

The first command prints Hello from auto. The second prints nothing. The third prints PolicyDenied.

3. Change a ConfigMap outside the workflow

Use the hello-stack ConfigMap from direct apply. Enable a short reconciliation interval and wait for the stack to be ready before patching the target. Leave the intent’s message unchanged.

kubectl -n platform-system patch iacstack hello-stack --type=merge \
  -p '{"spec":{"reconciliation":{"driftCheckInterval":"30s"}}}'
kubectl -n platform-system get iacstack hello-stack -w

After the stack is ready, stop the watch and make the out-of-band edit:

DESIRED_MESSAGE=$(kubectl -n platform-system get iacstack hello-stack \
  -o jsonpath='{.spec.inputs.message}')
printf '%s\n' "$DESIRED_MESSAGE"
kubectl -n iacstack-quickstart patch configmap hello-stack --type=merge \
  -p '{"data":{"message":"changed out of band"}}'
kubectl -n iacstack-quickstart get configmap hello-stack \
  -o jsonpath='{.data.message}{"\n"}' -w

Within the next successful periodic reconciliation, the message returns to DESIRED_MESSAGE. Stop the watch, check the stack’s execution and inspect the completed workflow logs:

kubectl -n platform-system get iacstack hello-stack \
  -o jsonpath='{.status.execution.trigger}{" "}{.status.execution.workflow}{"\n"}'

Look for DriftCheck and review the workflow logs for the plan that corrected the change. The simple direct runner demonstrates recovery without a separate policy or drift notification; later checks may report no changes.

Kind regression log excerpt: the out-of-band edit was corrected to the test’s declared value without editing the IaCStack. GitHub Actions run.

The plan reverses the out-of-band edit and apply updates one resource

Clean up

When finished, delete only the disposable cluster you created for the lab. This removes its ConfigMaps, Kubernetes backend state and workflow PVCs. Do not run this cleanup on a shared cluster.

kind delete cluster --name iacstack-quickstart