Files
aevolution/deploy/kubernetes/platform/admission/world0-protection.yaml
T
dingoandClaude Opus 5.5 3a34ae39bc fix: M8 review findings (restore ownership, barrier tool, World0 claimRef, CI selection, drill verdicts)
P1: restore-world.sh claims its objects path (mkdir) and the database (a held
session with a restore try-lock and the exclusive upgrade lock), and removes only
what it created, so a losing restore never drops a winner's schema.
P2: barrier Ready-pod selection via shared jsonpath helper with fixtures; barrier
pod fsGroup; script-generated pods inspected by the policy check; World0 PV claim
references protected; ci-paths.sh uses the event's real base and runs on
uncertainty; fault-drill asserts RTO and needs positive quarantine evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 22:53:11 -04:00

103 lines
5.1 KiB
YAML

# 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);
# - removing or reassigning such a volume's claim reference (namespace or claim
# name): the reference is how this policy recognizes a World0 volume, so clearing
# it first would otherwise strip the protection (review M8 P2). The binder may
# still fill in uid/resourceVersion; reassignment is a break-glass operation;
# - deleting the aevolution-world0 or aevolution-platform Argo CD Application or
# AppProject (the platform app owns this policy and the World0 namespace).
# 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 in ['aevolution-world0', 'aevolution-platform']
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
- expression: >-
variables.breakGlass || request.operation != 'UPDATE' || !variables.world0Volume ||
(has(object.spec.claimRef) && has(object.spec.claimRef.namespace) &&
object.spec.claimRef.namespace == 'evolution-world0' &&
(!has(oldObject.spec.claimRef.name) ||
(has(object.spec.claimRef.name) && object.spec.claimRef.name == oldObject.spec.claimRef.name)))
message: "A World0 PersistentVolume keeps its World0 claim reference without the aevolution:world0-break-glass group"
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]