Investigation & Containment

Investigation

Start from the object, then walk back to Git. The commands are the on-call engineer’s, on the team’s production cluster on Hetzner - every one names it with --context (Chapter 01). You run the same steps on your kind cluster, in develop, in the lab.

  1. Which Kustomization owns the object? Flux labels everything it applies:

    kubectl --context hetzner-sre-control-plane -n production get deploy backend \
      -o jsonpath='{.metadata.labels.kustomize\.toolkit\.fluxcd\.io/name}{"\n"}'
    

    backend-production. That Kustomization decides what the Deployment looks like.

  2. Which Git folder does it apply? Its spec.path:

    kubectl --context hetzner-sre-control-plane -n flux-system get kustomization backend-production \
      -o jsonpath='{.spec.path}{"\n"}'
    

    ./flux/apps/backend/production. In that folder, kustomization.yaml builds the shared backend from ../base, adding only production’s image tag, autoscaler and budget. The memory limit comes from the base itself: flux/apps/backend/base/deployment.yaml holds production’s values, limits/memory: 256Mi - and staging uses the same base unchanged. That one line is what every reconcile puts back.

  3. Is it suspended? Read the SUSPENDED column, not only READY:

    flux --context hetzner-sre-control-plane get kustomizations -A
    

    A suspended Kustomization keeps its last Ready status. It does not apply anything new.

  4. Which revision is applied, and which is in Git? Take the REVISION of backend-production from step 3 - the commit it last applied - and compare it with the revision the source has fetched:

    flux --context hetzner-sre-control-plane get sources git -A
    

    If the source is at a newer commit than the Kustomization, the cluster is behind Git.

Flux did what it is there for, both times: production runs what was reviewed in Git, and Git still said 256Mi - the same way it would have put back anything else changed by hand that night. Once it was suspended, the cluster quietly stopped following Git: no more reviewed changes, and no more self-healing either.

The root cause is the path of the change: the fix was right, but it went into the cluster by hand, and then Flux was switched off to keep it there. Git - the source backend-production follows - still said 256Mi.

Containment

  1. Put the fix into Git. A one-line pull request that raises the limit in flux/apps/backend/base/deployment.yaml - for production and staging together, since staging must match production. During an incident it can be reviewed in minutes; that review is the whole point - and its checks look further than the hand patch did: check-app-resources.sh (Chapter 08) refuses 512Mi, because production at its largest - every replica the autoscaler may run plus one during a rollout - would need 4608Mi of limits in a namespace budget of 4096Mi. 384Mi fits; more than that is a second decision - a larger budget - reviewed on its own.

  2. Resume the Kustomization once the fix is merged, and reconcile:

    flux --context hetzner-sre-control-plane resume kustomization backend-production
    
  3. Prove it - the delivery and the application. First the delivery:

    flux --context hetzner-sre-control-plane get kustomizations -A        # SUSPENDED False, READY True, the latest revision
    kubectl --context hetzner-sre-control-plane -n production get deploy backend \
      -o jsonpath='{.spec.template.spec.containers[0].resources.limits.memory}{"  "}{.spec.template.spec.containers[0].image}{"\n"}'
    

    Expected: the limit the pull request merged - 384Mi - and an image whose tag is the newTag in flux/apps/backend/production/kustomization.yaml - the build that carries the security fix. That proves the fixes arrived; it does not prove they work. Then the application: the backend’s /version endpoint reports the commit of that build, and the pods get through the evening peak with no new OOMKilled restarts (Chapter 01, rule IV).

  4. Look for others. Any other Kustomization with SUSPENDED True is the same incident waiting to happen.

From here on Flux works for the team again on everything backend-production applies: the next hand edit to those objects - by a person, a script or an attacker - is set back to what Git says, and the next one deleted comes back at the next reconcile. That covers only what is declared in that Kustomization’s folder; an object no active Kustomization manages, or one under another Kustomization that is still suspended, gets none of it - which is why step 4 looks for others.


Pause and Predict: Suspending was a reasonable instinct at 22:48. What would have to be true for a suspend to be safe?