# M8.2 World0 protection (ADR-0069). A native ValidatingAdmissionPolicy (GA since # Kubernetes 1.30; the cluster runs 1.32): no webhook, no new dependency. It applies # to every requester, including cluster-admin (system:masters), the Argo CD # application controller and any Application in any AppProject, so no permissive # app, prune, parent-app cascade or credential can remove World0 data or identity. # Only a member of the group `aevolution:world0-break-glass` passes. Membership is # granted out of band (client certificate O= or OIDC group) for a recorded operation. # # Denied without break-glass: # - deleting Namespace evolution-world0, or removing its aevolution.io/protected label; # - deleting PersistentVolumeClaims, Secrets or ServiceAccounts in evolution-world0; # - deleting a PersistentVolume bound to evolution-world0, or changing its reclaim # policy away from Retain once set (set Retain when the volume is bound: the # only StorageClass, local-path, provisions with Delete); # - deleting the aevolution-world0 Argo CD Application or AppProject. # Kubernetes does not run admission policies on policy objects themselves, so # removing this policy is itself the audited break-glass step (cluster-admin). # Apply by hand: kubectl apply -f deploy/kubernetes/platform/admission/ apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingAdmissionPolicy metadata: name: aevolution-world0-protection labels: app.kubernetes.io/part-of: aevolution spec: failurePolicy: Fail matchConstraints: resourceRules: - apiGroups: [""] apiVersions: ["v1"] operations: ["DELETE", "UPDATE"] resources: ["namespaces", "persistentvolumes"] - apiGroups: [""] apiVersions: ["v1"] operations: ["DELETE"] resources: ["persistentvolumeclaims", "secrets", "serviceaccounts"] - apiGroups: ["argoproj.io"] apiVersions: ["*"] operations: ["DELETE"] resources: ["applications", "appprojects"] variables: - name: breakGlass expression: "request.userInfo.groups.exists(g, g == 'aevolution:world0-break-glass')" - name: resource expression: "request.resource.resource" - name: world0Namespace expression: "variables.resource == 'namespaces' && request.name == 'evolution-world0'" - name: world0Volume expression: >- variables.resource == 'persistentvolumes' && has(oldObject.spec.claimRef) && has(oldObject.spec.claimRef.namespace) && oldObject.spec.claimRef.namespace == 'evolution-world0' - name: world0Object expression: >- request.namespace == 'evolution-world0' && variables.resource in ['persistentvolumeclaims', 'secrets', 'serviceaccounts'] - name: world0Delivery expression: >- request.resource.group == 'argoproj.io' && request.name == 'aevolution-world0' validations: - expression: >- variables.breakGlass || request.operation != 'DELETE' || !(variables.world0Namespace || variables.world0Volume || variables.world0Object || variables.world0Delivery) message: "World0 data, identity and delivery objects cannot be deleted without the aevolution:world0-break-glass group" reason: Forbidden - expression: >- variables.breakGlass || request.operation != 'UPDATE' || !variables.world0Namespace || (has(object.metadata.labels) && 'aevolution.io/protected' in object.metadata.labels && object.metadata.labels['aevolution.io/protected'] == 'true') message: "The World0 namespace must keep aevolution.io/protected=true" reason: Forbidden - expression: >- variables.breakGlass || request.operation != 'UPDATE' || !variables.world0Volume || oldObject.spec.persistentVolumeReclaimPolicy != 'Retain' || object.spec.persistentVolumeReclaimPolicy == 'Retain' message: "A World0 PersistentVolume set to Retain cannot be changed back" reason: Forbidden --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingAdmissionPolicyBinding metadata: name: aevolution-world0-protection labels: app.kubernetes.io/part-of: aevolution spec: policyName: aevolution-world0-protection validationActions: [Deny]