k8s-guardian
Health Warn
- License — License: Apache-2.0
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 5 GitHub stars
Code Pass
- Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
Kubernetes guardrails that know your cluster: check and safely fix manifests, Helm charts and Kustomize, check cluster fit, and enforce the same rules as ValidatingAdmissionPolicy or Kyverno. CLI, kubectl plugin, GitHub Action, MCP server.
🛡️ k8s-guardian
Kubernetes guardrails that know your cluster: check and safely fix manifests, Helm charts and Kustomize overlays, see whether they fit the target cluster, and enforce the same rules at admission time. A CLI, a
kubectlplugin, a GitHub Action and an MCP server in one binary.

Most Kubernetes linters read a YAML file and print an error. k8s-guardian also answers the questions you hit at deploy time:
- "The YAML is valid, but will it actually run in
prod?" Quotas, node sizes, LimitRanges, missing Secrets, CRDs. - "What breaks if I apply this over what's running now?" Immutable selectors, removed APIs, downtime, port changes.
- "Can you just fix it, without breaking my app?" Safe fixes by default, riskier ones only when you ask.
- "Can the cluster enforce exactly what CI checks?" Export the same rules as ValidatingAdmissionPolicies or Kyverno policies.
flowchart LR
subgraph repo["Your repository"]
M["Manifests · Helm charts<br/>Kustomize overlays"]
R["Rules<br/>21 built-in + custom"]
end
subgraph ci["Before merge: CLI, pre-commit, GitHub Action"]
C["check<br/>findings · safe --fix · baseline"]
end
subgraph deploy["Before deploy: needs a kubeconfig"]
L["check --live<br/>quotas · nodes · references"]
D["diff<br/>breaking changes"]
end
subgraph cluster["In the cluster"]
A["ValidatingAdmissionPolicy<br/>or Kyverno"]
end
M --> C
R --> C
C --> L
C --> D
R -- "export vap | kyverno<br/>(same decisions, tested)" --> A
Features
| Feature | Command | Docs |
|---|---|---|
21 built-in rules: requests/limits, non-root, privilege escalation, capabilities, probes, :latest, host namespaces and ports, seccomp, literal secrets in env, Service wiring, PodDisruptionBudgets, removed APIs, RBAC wildcards |
check -f |
check |
| Safe auto-fix that keeps comments and leaves unchanged YAML byte for byte; riskier fixes opt-in | check --fix [--unsafe-fixes] |
check |
Helm, Kustomize, Argo Rollouts: render charts with your own --values |
check -f chart --values prod.yaml |
check |
| Config file and baseline: adopt it in an existing repo and fail only on new findings | .k8s-guardian.yaml, --baseline |
configuration |
| Live cluster context: ResourceQuota headroom, node capacity, LimitRanges, missing ConfigMaps/Secrets, CRDs | check --live |
live |
| Breaking-change detector against what is deployed | diff -f |
diff |
| Enforce in the cluster with the same decisions as the CLI (tested against a real API server and Kyverno) | export vap|kyverno |
enforce |
| Custom rules in a small YAML format, no Rego | --rules, .k8s-guardian/rules/ |
custom rules |
| CI: GitHub Action with PR annotations, SARIF, pre-commit, Docker | uses: andronaft/[email protected] |
CI |
| kubectl plugin and MCP server for Claude Code / Cursor | kubectl guard, mcp |
MCP |
| AI fixes for what rules can't fix (optional, needs an API key) | check --fix --ai |
AI |
Experimental: cost estimation and right-sizing (cost), the interactive review TUI (interactive) and rules from plain language (rule create). They work and are tested, but their output and flags may change.
Install
# Go (>= 1.26)
go install github.com/andronaft/k8s-guardian/cmd/k8s-guardian@latest
# Docker (multi-arch)
docker run --rm -v "$PWD:/work" ghcr.io/andronaft/k8s-guardian check -f .
# Krew: installs the plugin as `kubectl guard-workloads`
kubectl krew install --manifest-url=https://raw.githubusercontent.com/andronaft/k8s-guardian/main/docs/krew/guard-workloads.yaml
# From source (also creates the kubectl-guard plugin symlink)
git clone https://github.com/andronaft/k8s-guardian && cd k8s-guardian && make build && sudo make install
Binaries for Linux, macOS and Windows are on the releases page.
Quick start
New here? Try it walks through everything with the examples in this repository, from an offline run to enforcing the rules in a local kind cluster.
k8s-guardian check -f k8s/ # check files, directories, Helm charts, Kustomize
k8s-guardian check -f k8s/ --fix # apply the safe fixes in place
k8s-guardian init -f k8s/ # existing repo: config, baseline of today's findings
# (only new ones fail) and a GitHub workflow
k8s-guardian check -f k8s/ --live -n prod # will it fit the cluster?
k8s-guardian diff -f k8s/ -n prod # what breaks if I apply it?
k8s-guardian export vap > guardrails.yaml # enforce the same rules at admission
examples/insecure-deployment.yaml Deployment/web
✖ error KG011 hostNetwork enabled (line 17)
⚠ warning KG013 securityContext.seccompProfile is not set to RuntimeDefault or Localhost [fixable] (line 17)
✖ error KG001 container "nginx": missing resources.requests (cpu, memory) [unsafe fix] (line 19)
✖ error KG004 container "nginx": securityContext.privileged is true (line 19)
✖ error KG010 container "nginx": image "nginx:latest" uses the mutable :latest tag (line 19)
...
6 error(s), 4 warning(s), 2 info
1 issue(s) can be fixed automatically with --fix (add --ai to let Claude fix the rest)
4 more with --fix --unsafe-fixes: these can change how the workload runs (root images, writable filesystems, resources), so review them
In GitHub Actions:
- uses: andronaft/[email protected]
with:
path: k8s/
Tested on real charts
k8s-guardian was run against 30 popular Helm charts (ingress-nginx, kube-prometheus-stack, Argo CD, cert-manager, Vault, Longhorn and more; 652 objects). The run found five bugs in k8s-guardian itself, including a --fix that broke privileged node agents, and all of them are fixed. See docs/real-world-test.md for the results and a script to reproduce them.
Documentation
- Try it: a hands-on tour, offline and with a local cluster
- Checking and fixing: inputs, fixes, built-in rules, ignoring findings
- Configuration:
.k8s-guardian.yaml, baseline, environment - Live cluster checks · Breaking-change diff · Enforcing in the cluster
- Custom rules · CI integration · MCP server · AI features
- Experimental: cost · interactive review
- Roadmap: what's next and how to help
Contributing
See CONTRIBUTING.md for development, the architecture and how to add a rule, and the roadmap for what's planned. Good first issues come with pointers to the code. Security issues: SECURITY.md. Release notes are on the releases page.
Why it exists: Why valid Kubernetes YAML still breaks in prod. Made by Andrii Zhukovskyi.
License
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found