# evidence-capture / kubernetes / t1 "Standard" # # Kyverno creates the quarantine network policy in every namespace, including # namespaces created later, and puts it back if anyone deletes it. Needs Kyverno, # which the admission control template installs. --- apiVersion: kyverno.io/v1 kind: ClusterPolicy metadata: name: quarantine-network-policy annotations: policies.kyverno.io/description: Every namespace gets a policy that cuts off pods labelled quarantine=true. spec: rules: - name: generate-quarantine match: any: - resources: kinds: [Namespace] exclude: any: - resources: names: [kube-system, kube-public, kube-node-lease, kyverno] generate: generateExisting: true apiVersion: networking.k8s.io/v1 kind: NetworkPolicy name: quarantine namespace: "{{request.object.metadata.name}}" synchronize: true data: spec: podSelector: matchLabels: quarantine: "true" policyTypes: - Ingress - Egress