Oreon IT Helm charts / kyverno-production-policies

kyverno-production-policies Helm chart

Version 0.1.2 · app 0.1.0 · MIT · source · Artifact Hub

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

Licence

MIT. Maintained by Oreon IT.

Oreon IT

Maintained by Oreon IT

A London cloud, DevOps and SRE consultancy. If you want this chart rolled out and tuned for your platform, we can help.