mirror of
https://github.com/ghndrx/homelab-gitops.git
synced 2026-02-10 06:44:57 +00:00
- Kyverno 3.3.4 via Helm (HA config: 3 admission, 2 background replicas) - Validation policies: - disallow-privileged-containers (Enforce) - require-resource-limits (Enforce) - require-labels (Audit - standard k8s labels) - require-run-as-non-root (Audit) - disallow-latest-tag (Enforce - GitOps reproducibility) - Mutating policy: - add-default-securitycontext (seccomp, drop caps, read-only fs) - System namespaces excluded (kube-system, kyverno, istio-system) - Auto-discovered by ArgoCD ApplicationSet Reference: CIS Kubernetes Benchmark, Pod Security Standards
48 lines
1.5 KiB
YAML
48 lines
1.5 KiB
YAML
# infrastructure/kyverno/policies/disallow-privileged.yaml
|
|
# Prevents pods from running as privileged containers
|
|
# Security baseline: CIS Benchmark 5.2.1
|
|
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: disallow-privileged-containers
|
|
annotations:
|
|
policies.kyverno.io/title: Disallow Privileged Containers
|
|
policies.kyverno.io/category: Pod Security Standards (Baseline)
|
|
policies.kyverno.io/severity: high
|
|
policies.kyverno.io/subject: Pod
|
|
policies.kyverno.io/description: >-
|
|
Privileged containers have all Linux capabilities and can access
|
|
host resources. This policy prevents privileged containers from
|
|
being created except in system namespaces.
|
|
spec:
|
|
validationFailureAction: Enforce
|
|
background: true
|
|
rules:
|
|
- name: privileged-containers
|
|
match:
|
|
any:
|
|
- resources:
|
|
kinds:
|
|
- Pod
|
|
exclude:
|
|
any:
|
|
- resources:
|
|
namespaces:
|
|
- kube-system
|
|
- kyverno
|
|
- istio-system
|
|
- cert-manager
|
|
validate:
|
|
message: "Privileged containers are not allowed. Set securityContext.privileged to false."
|
|
pattern:
|
|
spec:
|
|
containers:
|
|
- securityContext:
|
|
privileged: "false"
|
|
=(initContainers):
|
|
- securityContext:
|
|
privileged: "false"
|
|
=(ephemeralContainers):
|
|
- securityContext:
|
|
privileged: "false"
|