diff --git a/docs/tenant-abstraction.md b/docs/tenant-abstraction.md index d5c1b400bf..5e5807b819 100644 --- a/docs/tenant-abstraction.md +++ b/docs/tenant-abstraction.md @@ -196,9 +196,12 @@ templated verbatim. ### Public business-site staging hold -The platform installs `business-site-staging-hold` before enabling the public -business application. Tenant writers cannot create, update or delete that named -Cilium policy in `business-site`, including through reconciliation or pruning. +The platform installed `business-site-staging-hold` before enabling the public +business application, and lifted it once the signed application ran healthy +behind it (devantler-tech/business-site#554). The name stays reserved, so only +the platform can put the hold back. Tenant writers cannot create, update or +delete that named Cilium policy in `business-site`, including through +reconciliation or pruning. The existing trusted platform-controller carve-outs remain; a controller name in a tenant namespace does not grant the same authority. Other policy names and the same name in other namespaces retain their ordinary admission rules. diff --git a/k8s/providers/hetzner/apps/business-site/cilium-network-policy-staging-hold.yaml b/k8s/providers/hetzner/apps/business-site/cilium-network-policy-staging-hold.yaml deleted file mode 100644 index d62f0b3f57..0000000000 --- a/k8s/providers/hetzner/apps/business-site/cilium-network-policy-staging-hold.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# Install before enabling application reconciliation. Gateway traffic stays -# denied even when the signed application package adds its normal ingress allow. -# Node-origin health probes and the application's existing egress are unchanged. -apiVersion: cilium.io/v2 -kind: CiliumNetworkPolicy -metadata: - name: business-site-staging-hold - namespace: business-site -spec: - endpointSelector: - matchLabels: - app.kubernetes.io/name: business-site - ingressDeny: - - fromEntities: - - ingress - toPorts: - - ports: - - port: "8080" - protocol: TCP diff --git a/k8s/providers/hetzner/apps/business-site/kustomization.yaml b/k8s/providers/hetzner/apps/business-site/kustomization.yaml index f57d63fa8f..6921c490df 100644 --- a/k8s/providers/hetzner/apps/business-site/kustomization.yaml +++ b/k8s/providers/hetzner/apps/business-site/kustomization.yaml @@ -2,7 +2,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - tenant.yaml - - cilium-network-policy-staging-hold.yaml - cilium-network-policy-customer-identity-hold.yaml - certificate.yaml - reference-grant.yaml diff --git a/k8s/providers/hetzner/apps/business-site/tenant.yaml b/k8s/providers/hetzner/apps/business-site/tenant.yaml index 2f328da009..85ba681674 100644 --- a/k8s/providers/hetzner/apps/business-site/tenant.yaml +++ b/k8s/providers/hetzner/apps/business-site/tenant.yaml @@ -1,7 +1,7 @@ # Public-only staging: the tenant reconciles its signed v3.2.3 package — the # WebApp at business-site.platform.devantler.tech, its network policy, budget -# and disclosure input — while the platform-owned staging hold still denies -# gateway traffic. Portal identity and payments stay off, and devantler.tech +# and disclosure input — and gateway traffic reaches it now that the staging +# hold is lifted. Portal identity and payments stay off, and devantler.tech # keeps pointing at GitHub Pages until the DNS cutover. apiVersion: kro.run/v1alpha1 kind: Tenant diff --git a/scripts/tests/test-business-staging-hold.sh b/scripts/tests/test-business-staging-hold.sh index c118829f98..ada3df5e87 100755 --- a/scripts/tests/test-business-staging-hold.sh +++ b/scripts/tests/test-business-staging-hold.sh @@ -7,18 +7,12 @@ trap 'rm -rf "$scratch"' EXIT kubectl kustomize "$root/k8s/providers/hetzner/apps" >"$scratch/production.yaml" yq -o=json -I=0 '.' "$scratch/production.yaml" | jq -s '.' >"$scratch/production.json" -check_hold() { - jq -e ' - [ .[] | select(.kind == "CiliumNetworkPolicy" and .metadata.name == "business-site-staging-hold") ] | - length == 1 and .[0].metadata.namespace == "business-site" and - .[0].spec == { - endpointSelector: {matchLabels: {"app.kubernetes.io/name": "business-site"}}, - ingressDeny: [{fromEntities: ["ingress"], toPorts: [{ports: [{port: "8080", protocol: "TCP"}]}]}] - } - ' "$1" >/dev/null -} -check_hold "$scratch/production.json" || { - echo 'missing or broadened staging ingress hold' >&2 +# The staging ingress hold was lifted once the signed application ran healthy +# behind it (devantler-tech/business-site#554). Its name stays reserved by +# restrict-tenant-network-policies, so only the platform can put it back. +jq -e 'all(.[]; .kind != "CiliumNetworkPolicy" or .metadata.name != "business-site-staging-hold")' \ + "$scratch/production.json" >/dev/null || { + echo 'the lifted staging ingress hold is still rendered' >&2 exit 1 } check_identity_hold() { @@ -55,24 +49,8 @@ for change in \ exit 1 fi done -# These controls prevent an empty selector, a changed port/direction, or a mere -# additive allow policy from satisfying the independently enforced hold. -for change in \ - 'map(select(.metadata.name != "business-site-staging-hold"))' \ - 'map(if .metadata.name == "business-site-staging-hold" then .spec.endpointSelector={} else . end)' \ - 'map(if .metadata.name == "business-site-staging-hold" then .metadata.namespace="another-app" else . end)' \ - 'map(if .metadata.name == "business-site-staging-hold" then .spec.ingress=.spec.ingressDeny | del(.spec.ingressDeny) else . end)' \ - 'map(if .metadata.name == "business-site-staging-hold" then .spec.ingressDeny[0].fromEntities=["all"] else . end)' \ - 'map(if .metadata.name == "business-site-staging-hold" then .spec.ingressDeny[0].toPorts[0].ports[0].port="80" else . end)' \ - 'map(if .metadata.name == "business-site-staging-hold" then .spec.egress=[{}] else . end)'; do - jq "$change" "$scratch/production.json" >"$scratch/changed.json" - if check_hold "$scratch/changed.json"; then - echo 'unsafe hold mutation was accepted' >&2 - exit 1 - fi -done -# The public staging application reconciles behind the hold; the hold, not the -# Tenant, decides whether gateway traffic reaches it. +# The public staging application reconciles and receives gateway traffic; the +# customer identity hold above still keeps the portal's identity provider closed. jq -e ' [.[] | select(.kind == "Tenant" and .metadata.name == "business-site")] | length == 1 and .[0].metadata.namespace == "flux-system" and @@ -82,4 +60,4 @@ jq -e ' kubectl kustomize "$root/k8s/providers/docker/apps" >"$scratch/local.yaml" yq -o=json -I=0 '.' "$scratch/local.yaml" | jq -es 'all(.[]; .metadata.name != "business-site-staging-hold" and .metadata.name != "business-site-customer-identity-hold")' >/dev/null -printf 'PASS: production-only staging and identity holds; 16 unsafe mutations refused; application reconciles behind the hold\n' +printf 'PASS: staging hold lifted; production-only identity hold; 9 unsafe mutations refused; application reconciles\n' diff --git a/scripts/tests/test-restrict-tenant-network-policies.sh b/scripts/tests/test-restrict-tenant-network-policies.sh index 9ca3326cb9..994f9ca49f 100755 --- a/scripts/tests/test-restrict-tenant-network-policies.sh +++ b/scripts/tests/test-restrict-tenant-network-policies.sh @@ -194,7 +194,12 @@ control() { } hold_control() { local label="$1" actor="$2" operation="$3" namespace="$4" name="$5" expected="$6" managed="$7" - yq -o=json '.' "${repo_root}/k8s/providers/hetzner/apps/business-site/cilium-network-policy-staging-hold.yaml" | + # The former staging hold's body: the hold itself was lifted, but its name stays + # reserved, so these controls still exercise it (devantler-tech/business-site#554). + jq -n '{apiVersion: "cilium.io/v2", kind: "CiliumNetworkPolicy", + metadata: {name: "business-site-staging-hold", namespace: "business-site"}, + spec: {endpointSelector: {matchLabels: {"app.kubernetes.io/name": "business-site"}}, + ingressDeny: [{fromEntities: ["ingress"], toPorts: [{ports: [{port: "8080", protocol: "TCP"}]}]}]}}' | jq -c --arg label "${label}" --arg actor "${actor}" --arg operation "${operation}" \ --arg namespace "${namespace}" --arg name "${name}" --arg expected "${expected}" --arg managed "${managed}" ' .metadata.namespace = $namespace | .metadata.name = $name | . as $resource |