OnCallReadyStart learning

kubesec: score a Kubernetes manifest's security settings (controlplane.io kubesec 2.15)

kubesec scan [flags] FILE|-

What it does

Each rule that matches adds its points: risky settings (privileged, hostNetwork, SYS_ADMIN, docker.sock, secrets in env vars) are critical with negative points, hardening (runAsNonRoot, readOnlyRootFilesystem, capabilities drop ALL, seccomp, AppArmor, resource limits, a service account) passes with positive points; a hardening rule that does not match is listed under advise. Score 0 or below exits 2.

Options you will use

-f, --format json|table|template
Output format (default json: an array, one report per document).
-r, --rules LIST
Scan only these rule IDs, e.g. RunAsNonRoot,SeccompAny.
--exit-code INT
Exit code when an object scores 0 or less (default 2).
-o, --output FILE
Also write the report to FILE.
--absolute-path
Report the file name as an absolute path.

Examples

$ kubesec scan pod.yaml

the JSON report: score, critical, passed, advise

$ kubesec scan deploy.yaml | jq '.[0].scoring.critical[].id'

only the critical findings

$ helm template ./chart | kubesec scan -

a rendered chart from stdin

Gotchas

Taught in

On the blog

Try kubesec in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.