kyverno-production-policies
The Kubernetes production-readiness checklist as Kyverno policies - requests and limits, probes, owner labels, no latest tags, PodDisruptionBudgets and spread for multi-replica workloads, no NodePorts, nothing in the default namespace. Audit mode by default, enforce per namespace.
About this chart
kyverno-production-policies
The Kubernetes production readiness checklist as Kyverno policies. Install it in Audit mode (the default) and you get a findings list for the whole cluster in a few minutes; move namespaces to Enforce when they are clean.
| Policy | Checks | Default |
|---|---|---|
require-requests-limits | CPU and memory requests and a memory limit on every container and init container (CPU limit optional) | on |
require-probes | liveness and readiness probes on Deployments, StatefulSets, DaemonSets (startup probe optional) | on |
require-labels | pods carry the labels you route cost and alerts by (app.kubernetes.io/name, team by default) | on |
disallow-latest-tag | images have an explicit tag or digest, and it is not latest | on |
require-pdb | Deployments and StatefulSets with 2+ replicas have a PodDisruptionBudget whose selector matches their pod labels | on |
require-topology-spread | Deployments and StatefulSets with 2+ replicas declare topologySpreadConstraints or podAntiAffinity | on |
restrict-nodeport | no NodePort services | on |
disallow-default-namespace | nothing runs in default | on |
restrict-image-registries | images only from the registries you list | off |
require-ro-rootfs | readOnlyRootFilesystem: true on every container | off |
Pod-level checks are auto-generated by Kyverno for Deployments, StatefulSets, DaemonSets, Jobs and CronJobs, so reports point at the controller, not the pod. Pod Security Admission levels (privileged containers, host namespaces, root) are deliberately not duplicated here: set them as namespace labels, for example with our namespace-baseline chart.
Install
Needs Kyverno 1.13 or newer (rule-level failureAction).
helm repo add oreonit https://oreondev.github.io/helm-charts
helm install readiness oreonit/kyverno-production-policies -n kyverno
Read the findings:
kubectl get clusterpolicyreport,policyreport -A
kubectl get policyreport -A -o json \
| jq -r '.items[] | .metadata.namespace as $ns | .results[]? | select(.result=="fail")
| [$ns, .policy, .resources[0].kind, .resources[0].name] | @tsv' \
| sort | uniq -c | sort -rn
Enforce in one namespace while the rest keeps auditing:
helm upgrade readiness oreonit/kyverno-production-policies -n kyverno --reuse-values \
--set 'enforceNamespaces={staging}'
Enforce everywhere: --set failureAction=Enforce.
Values
| Key | Default | Description |
|---|---|---|
namePrefix | "" | Prefix for ClusterPolicy names |
failureAction | Audit | Audit or Enforce, for every policy |
enforceNamespaces | [] | Namespaces that enforce regardless of failureAction |
excludeNamespaces | kube-*, kyverno, gmp-*, gke-*, calico-*, tigera-operator | Namespaces no policy looks at (wildcards allowed) |
background | true | Scan existing resources, not only new requests |
policies.<name>.enabled | see table | Turn individual policies on or off |
policies.requireRequestsLimits.requireCpuLimit | false | Also require CPU limits |
policies.requireProbes.requireStartupProbe | false | Also require startup probes |
policies.requireLabels.labels | app.kubernetes.io/name, team | Required pod labels |
policies.requirePdb.minReplicas | 2 | Replica count from which a PDB is required |
policies.requireTopologySpread.minReplicas | 2 | Replica count from which spreading is required |
policies.restrictImageRegistries.registries | [] | Allowed image prefixes, e.g. ghcr.io/my-org/* |
rbac.kyvernoReadPdbs | true | Aggregated ClusterRole so Kyverno can list PodDisruptionBudgets for require-pdb |
Notes
require-pdblooks up PodDisruptionBudgets through the Kubernetes API (apiCallwith Kyverno'slabel_match). The chart ships an aggregated ClusterRole for that; if your Kyverno installation does not use therbac.kyverno.io/aggregate-to-*labels, grant the Kyverno controllerslistonpoddisruptionbudgets.policyyourself. OnlymatchLabelsselectors are compared: a PDB that selects withmatchExpressionsalone is not seen, so give such PDBs amatchLabelsentry or exclude the workload.- Audit findings for workloads that existed before the policy appear through background scans; give it a couple of minutes after install.
- Exceptions: use Kyverno
PolicyExceptionresources for the one workload that genuinely needs a NodePort, rather than turning the policy off. - A clean report is a readiness checklist you can show an auditor. If you would like the rest of the checklist (upgrades, backups, cost, observability) reviewed, that is the production readiness audit.
Licence
MIT. Maintained by Oreon IT.
Deploy kyverno-production-policies with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has kyverno-production-policies on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartkyverno-production-policies is pinned at v0.1.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply