Files
aevolution/deploy/kubernetes/platform/admission/world0-protection.yaml
T
dingoandClaude Opus 5.5 7318d82a14 Deliver the platform layer and store Jobs through Argo CD
At the maintainer's request everything but Secrets and the store node
label now goes through Argo CD. aevolution-platform syncs one bundle
(World0 admission policy, Retain storage class, each environment's
namespace, guardrails, service accounts and object claim) with
self-heal, no prune and Prune=false,Delete=false on every object; the
admission policy also protects the platform app and project. Store Jobs
become kustomize components used as PreSync (migrate) and PostSync
(check-store) hooks per environment, and the policy check refuses any
unresolved marker in a path an Application syncs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 17:05:34 -04:00

91 lines
4.3 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);
# - 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
---
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]