kubectl apply or any admission controller runs — enabling earlier feedback, faster remediation, and safer CI/CD pipelines.

Why perform static analysis?
When a user submits a Pod creation request, the control plane and configured admission controllers may accept, mutate, or reject the request. However, by the time that happens the manifest has already been written and applied. Static analysis moves policy and security checks earlier into the development workflow so problems are found:- Immediately after the manifest is authored (IDE, editor, pre-commit).
- During CI build and test stages (pull request validation).
- Before any resource is pushed to the cluster.
Example: a risky Pod manifest
Below is a simple Pod manifest that intentionally includes multiple security concerns:privileged: truegrants highly elevated privileges to the container and is generally high-risk.runAsUser: 0runs the process as root inside the container.- Adding capability
SYS_ADMINexpands kernel-level permissions. hostPathexposes the node filesystem to the Pod, enabling host-level access.
Static analysis helps catch misconfigurations and enforce policies before resources are submitted to the cluster, reducing the risk and cost of fixing issues later in the pipeline.
Typical findings, risk classification, and remediation
Lightweight static analysis: kubesec
kubesec (https://kubesec.io) is a simple tool that scores Kubernetes manifests and explains findings. It provides a numeric score and detailed guidance for each issue it detects, which makes it easy to prioritize fixes. Ways to use kubesec:- Install the
kubesecCLI and scan local files. - Use the publicly hosted API at
https://v2.kubesec.io/scan. - Run a local
kubesecHTTP server to integrate with local tooling.
Other useful static-analysis tools and integrations
Where to integrate static analysis
- Local development: editor/IDE plugins or pre-commit hooks (faster feedback).
- Continuous Integration: block pull requests with failing checks.
- Artifact scanning: validate rendered manifests from Helm, Kustomize, or templating pipelines.
- Developer platforms: embed checks in self-service portals and developer onboarding.
Recommended workflow
- Add static checks in the developer’s IDE and pre-commit hooks.
- Fail builds in CI when critical issues are detected.
- Enforce cluster-level policies with OPA Gatekeeper or similar admission controllers.
- Continuously scan images and artifacts in your supply chain.
References
- kubesec: https://kubesec.io
- Open Policy Agent: https://www.openpolicyagent.org/
- kube-linter: https://github.com/stackrox/kube-linter
- kube-score: https://github.com/zegl/kube-score
- conftest: https://www.conftest.dev/