Server cluster

Why Valid Kubernetes YAML Still Fails in Production, and How k8s-guardian Catch…

A manifest can pass linting and still fail at deploy time, because many failures depend on the cluster it is applied to. A new open-source tool, k8s-guardian, tries to check both.

Why Valid Kubernetes YAML Still Fails in Production, and How k8s-guardian Catch…
Source: Dev.to

Linting a Kubernetes manifest only checks the file itself. Many deploy-time failures come from the target cluster instead, such as resource quotas, node sizes, LimitRanges, referenced Secrets and CRDs, and differences from what is already running. The author, who set deployment standards across more than ten environments, said written standards alone did not stop drift, so they built a tool to enforce them.

The tool, k8s-guardian, is at version 0.7. It includes 21 built-in rules covering resource requests and limits, non-root users, privilege escalation, probes, :latest tags, host namespaces, seccomp, literal secrets in environment variables, Service wiring, PodDisruptionBudgets, removed APIs and RBAC wildcards. It can render Helm, Kustomize and Argo Rollouts charts, check live cluster context with a flag, diff changes against what is deployed, and apply a baseline so that only new findings fail a build.

To test the tool, the author ran it against 30 widely used Helm charts, including ingress-nginx, Argo CD and Vault, covering 652 Kubernetes objects. This found five bugs in the tool itself, all now fixed with regression tests. Automatic fixes are limited to changes that do not alter how a workload runs. Changes that could, such as forcing non-root users, have to be enabled explicitly and reviewed. The tool can also export its rules as ValidatingAdmissionPolicies or Kyverno policies so CI and the cluster apply the same checks. The project is open source under the Apache 2.0 license.

Source: Dev.to


Posted

in

by