Repository navigation
refactor(deploy): split manifests into base, dev and prod overlays #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
devantler
wants to merge
1
commit into
main
Choose a base branch
from
claude/deploy-base-dev-prod-369
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+150
−25
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| apiVersion: kustomize.config.k8s.io/v1beta1 | ||
| kind: Kustomization | ||
| # The static site that production (../prod) and dev (../dev) both run. Put a | ||
| # manifest here only when both environments run it unchanged. | ||
| resources: | ||
| - deployment.yaml | ||
| - service.yaml | ||
| # Tenant-owned CiliumNetworkPolicy allow-list (layered on the platform's | ||
| # default-deny floor): the site's Gateway ingress + DNS egress. | ||
| - networkpolicy.yaml | ||
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| apiVersion: kustomize.config.k8s.io/v1beta1 | ||
| kind: Kustomization | ||
| # Dev: the shared site (../base), changed only by the settings below. The | ||
| # platform reconciles it at `path: ./dev` into its own namespace and owns its | ||
| # ingress behind sign-on, so dev carries none of production's identity: no | ||
| # route, domain, certificate, DNS (external-dns), disruption budget or | ||
| # simply.com credentials. Change base objects with patches here; never copy a | ||
| # manifest. | ||
| # | ||
| # Analytics: the Umami tag is baked into the image at build time | ||
| # (src/app.html), so it cannot be switched from here. Its `data-domains` | ||
| # attribute limits tracking to ascoachingogvaner.dk, so dev's hostname sends | ||
| # no page views to the production website. | ||
| # | ||
| # The base hard-codes the production namespace on some objects; pin dev's own | ||
| # (the platform's Flux targetNamespace sets the same) so dev never renders | ||
| # into production's namespace. | ||
| namespace: ascoachingogvaner-dev | ||
| resources: | ||
| - ../base | ||
| # One replica; production runs two. | ||
| replicas: | ||
| - name: ascoachingogvaner | ||
| count: 1 | ||
| patches: | ||
| # The base policy's only egress rule names the kube-system namespace for DNS. | ||
| # A new tenant policy may name no namespace (the platform's | ||
| # restrict-tenant-network-policies), and the platform generates allow-dns in | ||
| # every tenant namespace, so dev keeps only the Gateway ingress. | ||
| - target: | ||
| kind: CiliumNetworkPolicy | ||
| name: app | ||
| patch: |- | ||
| - op: remove | ||
| path: /spec/egress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,9 @@ | ||
| apiVersion: kustomize.config.k8s.io/v1beta1 | ||
| kind: Kustomization | ||
| # Production entry point. The platform reconciles the published manifests | ||
| # artifact at `path: .`, which is this file, so it must only include ./prod. | ||
| # Shared manifests live in ./base, production-only ones in ./prod, and the dev | ||
| # overlay in ./dev (reconciled at `path: ./dev` into the | ||
| # `ascoachingogvaner-dev` namespace). | ||
| resources: | ||
| - deployment.yaml | ||
| - external-dns-deployment.yaml | ||
| - external-dns-serviceaccount.yaml | ||
| - httproute.yaml | ||
| - httproute-www.yaml | ||
| - pod-disruption-budget.yaml | ||
| - service.yaml | ||
| # Tenant-owned CiliumNetworkPolicy allow-lists (layered on the platform's | ||
| # default-deny floor): the app's Gateway ingress + DNS egress, and the | ||
| # external-dns pods' egress to the kube-apiserver + simply.com API. | ||
| - networkpolicy.yaml | ||
| - external-dns-networkpolicy.yaml | ||
| # Namespaced SecretStore backing the simply.com credentials below. | ||
| - secretstore.yaml | ||
| - simply-credentials-seed.yaml | ||
| - simply-credentials-externalsecret.yaml | ||
| # Tenant-owned TLS for ascoachingogvaner.dk: namespaced ACME Issuer (simply.com | ||
| # DNS01) + Certificate + a ReferenceGrant so the shared platform Gateway can | ||
| # terminate TLS with the resulting Secret cross-namespace. | ||
| - issuer.yaml | ||
| - certificate.yaml | ||
| - referencegrant.yaml | ||
| - prod |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| apiVersion: kustomize.config.k8s.io/v1beta1 | ||
| kind: Kustomization | ||
| # Production: the shared site (../base) plus everything that carries the | ||
| # production identity — the public routes and domain, its certificate and DNS, | ||
| # the disruption budget, and the simply.com credentials. The platform | ||
| # reconciles this through ../kustomization.yaml. | ||
| resources: | ||
| - ../base | ||
| - external-dns-deployment.yaml | ||
| - external-dns-serviceaccount.yaml | ||
| - httproute.yaml | ||
| - httproute-www.yaml | ||
| - pod-disruption-budget.yaml | ||
| # The external-dns pods' egress to the kube-apiserver + simply.com API, | ||
| # layered on the platform's default-deny floor. | ||
| - external-dns-networkpolicy.yaml | ||
| # Namespaced SecretStore backing the simply.com credentials below. | ||
| - secretstore.yaml | ||
| - simply-credentials-seed.yaml | ||
| - simply-credentials-externalsecret.yaml | ||
| # Tenant-owned TLS for ascoachingogvaner.dk: namespaced ACME Issuer (simply.com | ||
| # DNS01) + Certificate + a ReferenceGrant so the shared platform Gateway can | ||
| # terminate TLS with the resulting Secret cross-namespace. | ||
| - issuer.yaml | ||
| - certificate.yaml | ||
| - referencegrant.yaml |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/bin/sh | ||
| # Render deploy/ (the production entry), deploy/prod and deploy/dev, and keep | ||
| # production's identity out of dev. Needs kubectl (with its built-in Kustomize) | ||
| # and yq, both present on the runner. | ||
| set -eu | ||
|
|
||
| repo_root=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd) | ||
| work=$(mktemp -d) | ||
| trap 'rm -rf "$work"' EXIT | ||
|
|
||
| fail() { | ||
| printf 'FAIL: %s\n' "$*" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| kubectl kustomize "$repo_root/deploy" > "$work/root.yaml" || fail "deploy/ does not render" | ||
| kubectl kustomize "$repo_root/deploy/prod" > "$work/prod.yaml" || fail "deploy/prod does not render" | ||
| kubectl kustomize "$repo_root/deploy/dev" > "$work/dev.yaml" || fail "deploy/dev does not render" | ||
|
|
||
| # The platform reconciles deploy/ for production, so it must be exactly deploy/prod. | ||
| cmp -s "$work/root.yaml" "$work/prod.yaml" || | ||
| fail "deploy/kustomization.yaml must include only ./prod" | ||
|
|
||
| count_kind() { | ||
| KIND=$1 yq eval-all '[.] | map(select(.kind == strenv(KIND))) | length' "$work/dev.yaml" | ||
| } | ||
|
|
||
| # Dev runs the site alone: one Deployment with one replica. | ||
| [ "$(count_kind Deployment)" -eq 1 ] || fail "deploy/dev must render only the site's Deployment" | ||
| [ "$(yq eval-all 'select(.kind == "Deployment") | .metadata.name' "$work/dev.yaml")" = ascoachingogvaner ] || | ||
| fail "deploy/dev must render the ascoachingogvaner Deployment" | ||
| [ "$(yq eval-all 'select(.kind == "Deployment") | .spec.replicas' "$work/dev.yaml")" = 1 ] || | ||
| fail "deploy/dev must run one replica" | ||
|
|
||
| # Production identity stays in deploy/prod: routes, domain, TLS, DNS, the | ||
| # disruption budget and the simply.com credentials. | ||
| for kind in HTTPRoute Gateway ReferenceGrant Certificate Issuer PodDisruptionBudget \ | ||
| SecretStore ExternalSecret PushSecret Password ServiceAccount; do | ||
| [ "$(count_kind "$kind")" -eq 0 ] || fail "deploy/dev renders a $kind; it belongs in deploy/prod" | ||
| done | ||
| for needle in ascoachingogvaner.dk apps/ascoachingogvaner/ simply-credentials 'namespace: ascoachingogvaner$'; do | ||
| if grep -Eq -- "$needle" "$work/dev.yaml"; then | ||
| fail "deploy/dev references production ($needle)" | ||
| fi | ||
| done | ||
| # Dev's network policy is created fresh in its own namespace, where the | ||
| # platform refuses a tenant policy that names any namespace. | ||
| if grep -Fq 'io.kubernetes.pod.namespace' "$work/dev.yaml"; then | ||
| fail "deploy/dev network policy names a namespace; select pods by label instead" | ||
| fi | ||
|
|
||
| printf '%s\n' 'PASS: deploy/ renders deploy/prod; deploy/dev runs one replica without production identity' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the publisher before moving the Deployment into base.
At this revision,
.github/workflows/cd.yamlstill callspublish-app.yaml@af042c5…with the defaultdeploy-path: ./deploy. That publisher requires${DEPLOY_PATH}/deployment.yamland exits when the file is absent. The Deployment now resides indeploy/base/deployment.yaml, so the next release cannot publish. (raw.githubusercontent.com)Include the planned publisher migration before merge. Keep the artifact root at
deploy/while targetingdeploy/base/deployment.yamlfor digest injection. Settingdeploy-pathtodeploy/basealone would omit the overlays from the artifact. (raw.githubusercontent.com)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed: this is valid, and it is the merge-order item this PR's description already names. The release workflow has to move to the shared
actions/publish-appaction with the base manifest (or the verifier has to readdeploy/base) in this PR before it merges. That action shipped in devantler-tech/.github#935, but the platform does not yet trust this repository's own release tags (devantler-tech/platform#6265), so the PR is parked on that and this thread stays open until the switch is pushed here.