Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions docs/tenant-abstraction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
devantler marked this conversation as resolved.
Resolved
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.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions k8s/providers/hetzner/apps/business-site/tenant.yaml
Original file line number Diff line number Diff line change
@@ -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
Comment thread
devantler marked this conversation as resolved.
Resolved
# 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
Expand Down
40 changes: 9 additions & 31 deletions scripts/tests/test-business-staging-hold.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -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'
7 changes: 6 additions & 1 deletion scripts/tests/test-restrict-tenant-network-policies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
Loading