diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9c4409a28..ff0cabacc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1240,7 +1240,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e # v5.1.0 - - run: helm lint charts/gameplane + - run: helm lint charts/gameplane --set-string image.tag=dev - name: evaluate monitoring rules run: bash charts/gameplane/tests/monitoring-rules.sh - name: check MCP server RBAC scope @@ -1305,7 +1305,9 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e # v5.1.0 - - run: helm template gameplane charts/gameplane > /tmp/rendered.yaml + - run: helm template gameplane charts/gameplane --set-string image.tag=dev > /tmp/rendered.yaml + - name: check source chart image selection + run: python3 charts/tests/check_source_chart.py - name: deterministic offline native chart and upgrade renders run: python3 charts/tests/check_argocd.py - name: gateway isolation and API-disabled chart renders @@ -1327,7 +1329,7 @@ jobs: grep -q 'kind: NetworkPolicy' /tmp/rendered.yaml - name: backup/restore Job egress policy renders (F-215) run: | - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --show-only templates/networkpolicies.yaml > /tmp/netpol.yaml grep -q 'name: allow-backup-restore-egress' /tmp/netpol.yaml awk '/name: allow-backup-restore-egress/,/^---$/' /tmp/netpol.yaml \ @@ -1343,7 +1345,7 @@ jobs: # api.telemetry.receiver.dashboard.tokenSecretRef.name. run: | scrape_ns='serviceMonitors.scrapeNamespaceSelector={"matchLabels":{"kubernetes.io/metadata.name":"monitoring"}}' - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set serviceMonitors.enabled=true \ --set api.telemetry.receiver.enabled=true \ --set api.telemetry.receiver.dashboard.tokenSecretRef.name=receiver-dashboard \ @@ -1368,7 +1370,7 @@ jobs: grep -q 'name: receiver-dashboard' /tmp/receiver-servicemonitor.yaml # No dashboard token: no receiver ServiceMonitor (it could only scrape # a permanently-down target); NOTES.txt carries the warning. - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set serviceMonitors.enabled=true \ --set api.telemetry.receiver.enabled=true \ --set-json "$scrape_ns" \ @@ -1377,13 +1379,13 @@ jobs: echo "::error::receiver ServiceMonitor rendered without api.telemetry.receiver.dashboard.tokenSecretRef.name" exit 1 fi - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set serviceMonitors.enabled=true \ --set-json "$scrape_ns" \ --show-only templates/networkpolicies.yaml > /tmp/netpol-scrape.yaml awk '/name: allow-prometheus-to-agent/,/^---$/' /tmp/netpol-scrape.yaml \ | grep -q 'port: 9090' - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set serviceMonitors.enabled=true \ --set api.telemetry.receiver.enabled=true \ --set api.telemetry.receiver.dashboard.tokenSecretRef.name=receiver-dashboard \ @@ -1405,13 +1407,13 @@ jobs: awk '/kind: Service/,/^---$/' /tmp/telemetry-receiver-scrape.yaml \ | grep -q 'name: dashboard' # Missing scrape ingress must fail with actionable guidance. - if helm template gameplane charts/gameplane --set serviceMonitors.enabled=true > /tmp/monitoring-invalid.txt 2>&1; then + if helm template gameplane charts/gameplane --set-string image.tag=dev --set serviceMonitors.enabled=true > /tmp/monitoring-invalid.txt 2>&1; then echo "::error::monitoring without a scrape selector unexpectedly rendered" exit 1 fi grep -q 'serviceMonitors.scrapeNamespaceSelector' /tmp/monitoring-invalid.txt # Explicit external policy ownership renders no chart exception. - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set serviceMonitors.enabled=true \ --set serviceMonitors.externallyManagedPolicy=true \ --show-only templates/networkpolicies.yaml > /tmp/netpol-default.yaml @@ -1431,7 +1433,7 @@ jobs: --set api.oidc.redirectURL=https://gameplane.example/auth/oidc/callback) rules='api.oidc.roleRules=[{"group":"sys-admin","role":"admin"},{"group":"gameplane login only, staff","role":"login-only"}]' # Old form only: the per-role flags exactly as before, no rules flag. - helm template gameplane charts/gameplane "${oidc[@]}" \ + helm template gameplane charts/gameplane --set-string image.tag=dev "${oidc[@]}" \ --set-json 'api.oidc.roleMappings={"admin":["gp-admins"],"operator":["gp-ops","gp-sre"],"viewer":["gp-view"]}' \ --show-only templates/api.yaml > /tmp/api-oidc-old.yaml grep -qF -- '- "--oidc-role-mapping-admin=gp-admins"' /tmp/api-oidc-old.yaml @@ -1442,7 +1444,7 @@ jobs: exit 1 fi # New form: exactly one JSON flag, in list order, and no per-role flags. - helm template gameplane charts/gameplane "${oidc[@]}" \ + helm template gameplane charts/gameplane --set-string image.tag=dev "${oidc[@]}" \ --set-json "$rules" \ --show-only templates/api.yaml > /tmp/api-oidc-rules.yaml if [ "$(grep -c -- '--oidc-role-rules=' /tmp/api-oidc-rules.yaml)" -ne 1 ]; then @@ -1455,7 +1457,7 @@ jobs: exit 1 fi # Both forms: the render fails and names both keys (OD-1). - if helm template gameplane charts/gameplane "${oidc[@]}" \ + if helm template gameplane charts/gameplane --set-string image.tag=dev "${oidc[@]}" \ --set-json "$rules" \ --set-json 'api.oidc.roleMappings={"admin":["gp-admins"]}' > /tmp/api-oidc-both.txt 2>&1; then echo "::error::api.oidc.roleRules together with api.oidc.roleMappings unexpectedly rendered" @@ -1468,12 +1470,12 @@ jobs: # is used as-is without the bundled marker; defaults render no endpoint. run: | # api.telemetry.enabled=false is the hard off switch. - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set api.telemetry.enabled=false \ --show-only templates/api.yaml > /tmp/api-telemetry-off.yaml grep -q -- '--telemetry-disabled' /tmp/api-telemetry-off.yaml # The bundled receiver auto-wires the API and marks it bundled. - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set api.telemetry.receiver.enabled=true \ --show-only templates/api.yaml > /tmp/api-telemetry-bundled.yaml grep -q -- '--telemetry-endpoint=http://gameplane-telemetry-receiver' /tmp/api-telemetry-bundled.yaml @@ -1483,7 +1485,7 @@ jobs: exit 1 fi # A custom endpoint is used as-is and is never marked bundled. - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set api.telemetry.endpoint=https://telemetry.example.com/ingest \ --set api.telemetry.receiver.enabled=true \ --show-only templates/api.yaml > /tmp/api-telemetry-custom.yaml @@ -1493,7 +1495,7 @@ jobs: exit 1 fi # Defaults render no endpoint (the API falls back to its compiled-in default). - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --show-only templates/api.yaml > /tmp/api-telemetry-default.yaml if grep -q -- '--telemetry-endpoint' /tmp/api-telemetry-default.yaml; then echo "::error::default values rendered a --telemetry-endpoint" @@ -1522,7 +1524,7 @@ jobs: pow_fails() { # pow_fails MESSAGE --set ...: the render must fail with MESSAGE. message="$1"; shift - if helm template gameplane charts/gameplane --set api.telemetry.receiver.enabled=true "$@" \ + if helm template gameplane charts/gameplane --set-string image.tag=dev --set api.telemetry.receiver.enabled=true "$@" \ --show-only templates/telemetry-receiver.yaml > /dev/null 2> /tmp/pow-fail.err; then echo "::error::receiver rendered for $*" exit 1 @@ -1535,12 +1537,12 @@ jobs: } pow=api.telemetry.receiver.ingestPow # Defaults: proof-of-work off, with the OD-5 values. - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set api.telemetry.receiver.enabled=true \ --show-only templates/telemetry-receiver.yaml > /tmp/pow-default.yaml pow_env /tmp/pow-default.yaml false 60 0 22 # Enabled with its own values. - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set api.telemetry.receiver.enabled=true \ --set $pow.enabled=true --set $pow.targetPerMinute=30 \ --set $pow.minBits=8 --set $pow.maxBits=26 \ @@ -1581,7 +1583,7 @@ jobs: # (api.yaml), unlike the surrounding Role/RoleBinding names. Any such # release could install but never upgrade. run: | - helm template gp charts/gameplane --namespace gpns --is-upgrade > /tmp/rendered-gp.yaml + helm template gp charts/gameplane --set-string image.tag=dev --namespace gpns --is-upgrade > /tmp/rendered-gp.yaml python3 - <<'PY' import sys, yaml docs = list(yaml.safe_load_all(open('/tmp/rendered-gp.yaml'))) @@ -1612,7 +1614,7 @@ jobs: trap 'cp /tmp/values.yaml.orig charts/gameplane/values.yaml' EXIT cp charts/gameplane/values.yaml /tmp/values.yaml.orig cp charts/gameplane/testdata/upgrade-from-v0.2.0-beta.8-values.yaml charts/gameplane/values.yaml - helm template gameplane charts/gameplane --include-crds > /tmp/rendered-reuse-values.yaml + helm template gameplane charts/gameplane --set-string image.tag=dev --include-crds > /tmp/rendered-reuse-values.yaml python3 - <<'PY' import yaml docs = [d for d in yaml.safe_load_all(open('/tmp/rendered-reuse-values.yaml')) if d] @@ -1635,7 +1637,7 @@ jobs: # keys), the chart still renders: no receiver PVC is added, no # receiver ServiceMonitor renders without a token, and the API # keeps working without api.telemetry.enabled. - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set api.telemetry.receiver.enabled=true \ --set serviceMonitors.enabled=true \ --set serviceMonitors.externallyManagedPolicy=true > /tmp/rendered-reuse-values-receiver.yaml @@ -1679,7 +1681,7 @@ jobs: # The release workflows check the root key against the signing secret; # this checks the chart's copy against the root key. run: | - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ --set defaultModuleSource.oci.verify.enabled=true \ --show-only templates/module-cosign-key.yaml > /tmp/keysecret.yaml # The rendered Secret carries the key under stringData/data; pull the @@ -1712,7 +1714,7 @@ jobs: raise SystemExit("could not find the Keycloak 'Or in values.yaml' example in docs/oidc.md") print(m.group(1)) PY - helm template gameplane charts/gameplane \ + helm template gameplane charts/gameplane --set-string image.tag=dev \ -f /tmp/oidc-example-values.yaml \ --show-only templates/api.yaml > /tmp/rendered-oidc.yaml grep -q 'GAMEPLANE_OIDC_CLIENT_SECRET' /tmp/rendered-oidc.yaml @@ -2046,6 +2048,38 @@ jobs: uses: ./.github/actions/e2e-images with: arch: ${{ matrix.arch }} + - name: verify source checkout controller rollouts + if: matrix.bucket == 'operator' && matrix.arch == 'amd64' && env.RUN_REGEX != '' + shell: bash + run: | + cluster="source-checkout-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" + trap 'kind delete cluster --name "$cluster"' EXIT + kind create cluster --name "$cluster" --wait 90s + kind load docker-image --name "$cluster" gameplane-test/{api,operator,telemetry-receiver}:e2e + # The CI image bundle omits the dashboard. Scaling only web to zero + # leaves both controllers' documented source-install arguments intact. + helm upgrade --install gameplane ./charts/gameplane --kube-context "kind-$cluster" \ + --namespace gameplane-system --create-namespace \ + --set-string image.registry=gameplane-test --set-string image.tag=e2e \ + --set api.telemetry.receiver.enabled=true --set web.replicas=0 + k=(kubectl --context "kind-$cluster" -n gameplane-system) + for component in operator api; do + name="gameplane-$component" + container="$component" + if [[ "$component" == operator ]]; then container=manager; fi + if ! "${k[@]}" rollout status "deployment/$name" --timeout=5m; then + "${k[@]}" logs "deployment/$name" -c "$container" --tail=30 || true + exit 1 + fi + "${k[@]}" get pods -l "app.kubernetes.io/name=$name" -o json | + jq -ce --arg c "$container" --arg image "gameplane-test/$component:e2e" ' + [.items[] | select(.metadata.deletionTimestamp == null)] | select(length == 1) | .[0] | + select(any(.status.conditions[]; .type == "Ready" and .status == "True")) | + (.spec.containers[] | select(.name == $c and .image == $image)) as $spec | + (.status.containerStatuses[] | select(.name == $c and .ready)) as $status | + select(($spec.args | length) > 0 and ($status.imageID | length) > 0) | + {pod: .metadata.name, image: $spec.image, imageID: $status.imageID, args: $spec.args}' + done - name: bring up cluster + helm install if: env.RUN_REGEX != '' || env.TAIL_REGEX != '' env: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4a84d593a..ea41af298 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -211,11 +211,14 @@ jobs: run: | sed -i "s/^version: .*/version: ${GITHUB_REF_NAME#v}/" charts/gameplane/Chart.yaml sed -i "s/^appVersion: .*/appVersion: ${GITHUB_REF_NAME#v}/" charts/gameplane/Chart.yaml + sed -i '/^ gameplane\.local\/source-checkout:/d' charts/gameplane/Chart.yaml sed -i "s/^version: .*/version: ${GITHUB_REF_NAME#v}/" charts/gameplane/charts/gameplane-crds/Chart.yaml # gameplane-crds is also published on its own, for GitOps setups where a # separate Application owns the CRDs (docs/argocd.md). - name: helm package run: helm package charts/gameplane charts/gameplane/charts/gameplane-crds -d dist + - name: check packaged chart image defaults + run: python3 charts/tests/check_source_chart.py --release-chart "dist/gameplane-${GITHUB_REF_NAME#v}.tgz" --release-version "${GITHUB_REF_NAME#v}" # The chart is a published artifact like the images, so it must be signed # too — it was previously pushed unsigned, which made the "everything we # publish is signed" claim untrue. diff --git a/Makefile b/Makefile index b74ba5bcf..5bc9079fe 100644 --- a/Makefile +++ b/Makefile @@ -463,11 +463,10 @@ dev-load: ## Load every image `make images` builds into the kind cluster (kind o kind load docker-image $(REGISTRY)/$$img:$(TAG) --name $(KIND_CLUSTER) || exit $$?; \ done -dev-push: ## Push operator/api/web/agent images to REGISTRY (remote clusters) - docker push $(REGISTRY)/operator:$(TAG) - docker push $(REGISTRY)/api:$(TAG) - docker push $(REGISTRY)/web:$(TAG) - docker push $(REGISTRY)/agent:$(TAG) +dev-push: ## Push every image built by make images to REGISTRY + @for img in $(ALL_IMAGE_NAMES); do \ + docker push "$(REGISTRY)/$$img:$(TAG)" || exit $$?; \ + done dev-install: ## Install Gameplane Helm chart into the selected cluster @hack/need.sh helm @@ -482,8 +481,8 @@ dev-install: ## Install Gameplane Helm chart into the selected cluster $(KUBECONFIG_ENV) helm upgrade --install $(CHART_RELEASE) $(CHART_DIR) \ --kube-context $(KUBE_CONTEXT) \ --namespace $(NAMESPACE) --create-namespace \ - --set image.tag=$(TAG) \ - --set image.registry=$(REGISTRY) \ + --set-string "image.tag=$(TAG)" \ + --set-string "image.registry=$(REGISTRY)" \ --set operator.addressManager=$(ADDRESS_MANAGER) \ --set api.telemetry.receiver.enabled=true \ --set defaultModuleSource.type=oci \ diff --git a/changelog/unreleased/1165-source-chart-images.md b/changelog/unreleased/1165-source-chart-images.md new file mode 100644 index 000000000..247cd582f --- /dev/null +++ b/changelog/unreleased/1165-source-chart-images.md @@ -0,0 +1,7 @@ +# Breaking: source-chart installs require an explicit image tag + +When installing or upgrading from a Git checkout, set `image.tag` to a build +from that revision. Use `make images` and `make dev-push` to build and push +the full component set to your registry. Published OCI charts still select +their matching release images automatically. +[Source checkout instructions](../../docs/install.md#install-from-a-source-checkout) · [PR #1165](https://github.com/GameplanePanel/Gameplane/pull/1165) diff --git a/charts/gameplane/Chart.yaml b/charts/gameplane/Chart.yaml index 08387b469..75c8c92d9 100644 --- a/charts/gameplane/Chart.yaml +++ b/charts/gameplane/Chart.yaml @@ -5,6 +5,8 @@ type: application version: 0.5.0 appVersion: "0.5.0" kubeVersion: ">=1.30.0-0" +annotations: + gameplane.local/source-checkout: "true" home: https://github.com/GameplanePanel/gameplane sources: - https://github.com/GameplanePanel/gameplane diff --git a/charts/gameplane/templates/_helpers.tpl b/charts/gameplane/templates/_helpers.tpl index 935ed2297..37cb01a5e 100644 --- a/charts/gameplane/templates/_helpers.tpl +++ b/charts/gameplane/templates/_helpers.tpl @@ -1,10 +1,11 @@ {{- /* -gameplane.imageTag resolves the shared image tag: an explicit image.tag wins, -otherwise it falls back to the chart's appVersion so a released chart vX always -pulls images vX with no per-install override. Set image.tag (e.g. "edge") to -track a rolling channel. +The release workflow removes the checkout annotation when it packages the +chart alongside matching release images. A checkout can contain newer flags. */}} {{- define "gameplane.imageTag" -}} +{{- if and (not .Values.image.tag) (index .Chart.Annotations "gameplane.local/source-checkout") -}} +{{- fail "This source chart requires an explicit image.tag. Build images from this checkout and set image.registry and image.tag, or install oci://ghcr.io/gameplanepanel/charts/gameplane with --version ." -}} +{{- end -}} {{- .Values.image.tag | default .Chart.AppVersion -}} {{- end -}} diff --git a/charts/gameplane/tests/mcp-server-rbac.sh b/charts/gameplane/tests/mcp-server-rbac.sh index bb2a89eae..b9d8f6d9d 100755 --- a/charts/gameplane/tests/mcp-server-rbac.sh +++ b/charts/gameplane/tests/mcp-server-rbac.sh @@ -4,9 +4,9 @@ set -euo pipefail cd "$(dirname "$0")/../../.." scratch="$(mktemp -d)" trap 'rm -rf "$scratch"' EXIT -helm template gameplane charts/gameplane --namespace gameplane-system \ +helm template gameplane charts/gameplane --set-string image.tag=dev --namespace gameplane-system \ --set mcpServer.enabled=true --set 'operator.gameNamespaces={tenant-b}' > "$scratch/enabled.yaml" -helm template gameplane charts/gameplane --namespace gameplane-system \ +helm template gameplane charts/gameplane --set-string image.tag=dev --namespace gameplane-system \ --set mcpServer.enabled=false > "$scratch/disabled.yaml" python3 - "$scratch" <<'PY' import pathlib,sys,yaml diff --git a/charts/gameplane/tests/monitoring-rules.sh b/charts/gameplane/tests/monitoring-rules.sh index ae876184e..1d9a64e8f 100644 --- a/charts/gameplane/tests/monitoring-rules.sh +++ b/charts/gameplane/tests/monitoring-rules.sh @@ -4,7 +4,7 @@ set -euo pipefail cd "$(dirname "$0")/../../.." scratch="$(mktemp -d)" trap 'rm -rf "$scratch"' EXIT -helm template gameplane charts/gameplane -f docs/examples/monitoring/gameplane-values.yaml \ +helm template gameplane charts/gameplane --set-string image.tag=dev -f docs/examples/monitoring/gameplane-values.yaml \ --set 'operator.gameNamespaces={tenant-b,gameplane-games}' > "$scratch/rendered.yaml" python3 - "$scratch" <<'PY' import pathlib,sys,yaml diff --git a/charts/gameplane/tests/sftp.sh b/charts/gameplane/tests/sftp.sh index 292f22b6b..0f9fe8b1f 100755 --- a/charts/gameplane/tests/sftp.sh +++ b/charts/gameplane/tests/sftp.sh @@ -6,7 +6,7 @@ scratch="$(mktemp -d)" trap 'rm -rf "$scratch"' EXIT render() { # render [helm --set args...] local out="$1"; shift - helm template gameplane charts/gameplane --namespace gameplane-system "$@" > "$out" + helm template gameplane charts/gameplane --set-string image.tag=dev --namespace gameplane-system "$@" > "$out" } render "$scratch/off.yaml" --set sftp.enabled=false render "$scratch/local.yaml" --set sftp.enabled=true @@ -18,8 +18,8 @@ render "$scratch/hostkey.yaml" --set sftp.enabled=true --set sftp.hostKeySecret= render "$scratch/metrics.yaml" --set sftp.enabled=true --set serviceMonitors.enabled=true \ --set serviceMonitors.scrapeNamespaceSelector.matchLabels.name=monitoring # Remote mode must refuse a plain-HTTP central API URL. -if helm template gameplane charts/gameplane --namespace gameplane-system --set api.enabled=false --set sftp.enabled=true \ - --set sftp.apiURL=http://panel.example.com --set sftp.serviceTokenSecret=panel-sftp-token > /dev/null 2>&1; then +if render /dev/null --set api.enabled=false --set sftp.enabled=true \ + --set sftp.apiURL=http://panel.example.com --set sftp.serviceTokenSecret=panel-sftp-token 2>/dev/null; then echo 'sftp.apiURL=http:// rendered, want a failure' >&2 exit 1 fi diff --git a/charts/gameplane/values.yaml b/charts/gameplane/values.yaml index 9002821f3..411692a9d 100644 --- a/charts/gameplane/values.yaml +++ b/charts/gameplane/values.yaml @@ -38,8 +38,8 @@ image: # release workflow. The release matches this default; override only to pin a # mirror or fork. registry: ghcr.io/gameplanepanel/gameplane - # Empty tag => the chart's appVersion (so chart vX pulls images vX). Set to a - # channel like "edge" to track the rolling images published on every master push. + # A packaged release defaults to its appVersion. For a source chart, supply the + # tag of images built from your checkout. Set "edge" to track rolling builds. tag: "" pullPolicy: IfNotPresent pullSecrets: [] diff --git a/charts/tests/check_argocd.py b/charts/tests/check_argocd.py index c4f965a9e..4be5075e5 100644 --- a/charts/tests/check_argocd.py +++ b/charts/tests/check_argocd.py @@ -14,7 +14,7 @@ def render(*flags, capabilities=(POLICY, BINDING), failure=None): cmd = ["helm", "template", "gameplane", str(CHART), "--namespace", "gameplane-system", - "--kube-version", "1.34.0", "--values", str(PROFILE)] + "--kube-version", "1.34.0", "--set-string", "image.tag=dev", "--values", str(PROFILE)] for capability in capabilities: cmd.extend(["--api-versions", capability]) result = subprocess.run(cmd + list(flags), capture_output=True, check=False) diff --git a/charts/tests/check_gateway.py b/charts/tests/check_gateway.py index 08b50502c..296730402 100644 --- a/charts/tests/check_gateway.py +++ b/charts/tests/check_gateway.py @@ -17,7 +17,9 @@ def render(values=None, failure=None, upgrade=False, namespace="gameplane-system """ with tempfile.TemporaryDirectory() as directory: values_path = Path(directory) / "values.yaml" - values_path.write_text(yaml.safe_dump(values or {}), encoding="utf-8") + fixture_values = dict(values or {}) + fixture_values["image"] = {"tag": "dev", **fixture_values.get("image", {})} + values_path.write_text(yaml.safe_dump(fixture_values), encoding="utf-8") result = subprocess.run( ["helm", "template", release, str(chart), "--namespace", namespace, "--values", str(values_path)] + (["--is-upgrade"] if upgrade else []) diff --git a/charts/tests/check_source_chart.py b/charts/tests/check_source_chart.py new file mode 100644 index 000000000..e86a3d63f --- /dev/null +++ b/charts/tests/check_source_chart.py @@ -0,0 +1,66 @@ +"""Check how a checkout and the official release archive select component images.""" +import argparse +from pathlib import Path +import subprocess +import tempfile + + +CHART = Path(__file__).resolve().parents[1] / "gameplane" +DEFAULT_REGISTRY = "ghcr.io/gameplanepanel/gameplane" +SOURCE_ERROR = "This source chart requires an explicit image.tag" + + +def render(chart, *flags, expect_source_error=False): + args = ["helm", "template", "gameplane", str(chart), "--namespace", "gameplane-system", + "--kube-version", "1.34.0", *flags] + result = subprocess.run(args, text=True, capture_output=True, check=False) + if expect_source_error: + assert result.returncode != 0 and SOURCE_ERROR in result.stderr, result.stderr + elif result.returncode != 0: + raise RuntimeError(result.stderr) + return result.stdout + + +def check_images(manifests, registry, tag, agent=None): + images = {line.strip().removeprefix("image:").strip().strip("\"'") + for line in manifests.splitlines() if line.strip().startswith("image:")} + for component in ("operator", "api", "web"): + reference = f"{registry}/{component}:{tag}" + assert reference in images, f"expected {reference} among {sorted(images)}" + agent = agent or f"{registry}/agent:{tag}" + assert f"--agent-image={agent}" in manifests, f"expected agent {agent}" + + +def check_checkout(): + render(CHART, expect_source_error=True) + render(CHART, "--set-string", "image.tag=", expect_source_error=True) + registry, tag = "registry.example/gameplane", "checkout-123" + agent = "registry.example/custom-agent:123" + manifests = render(CHART, "--set-string", f"image.registry={registry},image.tag={tag}", + "--set-string", f"operator.agentImage={agent}") + check_images(manifests, registry, tag, agent) + render(CHART, "--set", "operator.enabled=false,api.enabled=false,web.enabled=false") + + # Packing a development checkout must retain the same requirement. + with tempfile.TemporaryDirectory() as out: + subprocess.run(["helm", "package", str(CHART), "--destination", out], check=True) + archive, = Path(out).glob("*.tgz") + render(archive, expect_source_error=True) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--release-chart", type=Path) + parser.add_argument("--release-version") + args = parser.parse_args() + if bool(args.release_chart) != bool(args.release_version): + parser.error("--release-chart and --release-version must be supplied together") + if args.release_chart: + check_images(render(args.release_chart), DEFAULT_REGISTRY, args.release_version) + check_images(render(args.release_chart, "--set-string", "image.tag=edge"), DEFAULT_REGISTRY, "edge") + else: + check_checkout() + + +if __name__ == "__main__": + main() diff --git a/deploy/kind/e2e.sh b/deploy/kind/e2e.sh index 913afffa7..a9e14a363 100755 --- a/deploy/kind/e2e.sh +++ b/deploy/kind/e2e.sh @@ -419,8 +419,8 @@ EOF # The port pool serves TestGameServer_PortPool* (port_pool_e2e_test.go). helm upgrade --install gameplane "${CHART_DIR}" \ --namespace gameplane-system --create-namespace \ - --set "image.registry=gameplane-test" \ - --set "image.tag=${TAG}" \ + --set-string "image.registry=gameplane-test" \ + --set-string "image.tag=${TAG}" \ --set "ingress.enabled=false" \ --set "web.enabled=false" \ --set "operator.agentImage=gameplane-test/agent:${TAG}" \ diff --git a/docs/argocd.md b/docs/argocd.md index c17e5d063..4826b2204 100644 --- a/docs/argocd.md +++ b/docs/argocd.md @@ -11,6 +11,11 @@ Pin both Applications to the same Gameplane release, or the same Git commit. Syn | CRDs | Helm chart `oci://ghcr.io/gameplanepanel/charts/gameplane-crds`, at the same version as the workload chart. Or the plain directory `charts/gameplane/charts/gameplane-crds/crds`. | Use `ServerSideApply=true` for the large schemas. Keep automated pruning off and sync this Application without prune. For Application deletion, preserve its resources by using non-cascading deletion. | | Workload | Helm chart `charts/gameplane` | Set `spec.source.helm.skipCrds: true` and include `examples/argocd-values.yaml` in `spec.source.helm.valueFiles`. The profile disables the CRD apply hook. Set the release name to `gameplane` and the destination namespace to `gameplane-system`. | +For a Git source, build and push images from the workload Application's pinned +commit. Set `image.registry` and `image.tag` in that Application's Helm +parameters, and update the tag whenever you change the commit. +[Source checkout instructions](install.md#install-from-a-source-checkout) + The two Applications share one commit, and the CRD Application must finish first: ```mermaid @@ -28,11 +33,12 @@ Provision the release namespace, CA and client Secret before syncing. Keep owner Carry the installation's `nativeRBAC` settings, additional game namespaces, and credentials namespace into the workload Application. For a single-cluster panel where GitOps owns catalogs, configure the reduced Kubernetes permissions described in the [native RBAC guide](native-rbac.md). -Argo CD ordinarily passes the destination cluster’s API capabilities to Helm. Verify that both `admissionregistration.k8s.io/v1/ValidatingAdmissionPolicy` and `admissionregistration.k8s.io/v1/ValidatingAdmissionPolicyBinding` are served and that admission is enabled. For an offline comparison, pass the discovered capabilities and the destination Kubernetes version. This example assumes both kinds on Kubernetes 1.34. +Argo CD ordinarily passes the destination cluster’s API capabilities to Helm. Verify that both `admissionregistration.k8s.io/v1/ValidatingAdmissionPolicy` and `admissionregistration.k8s.io/v1/ValidatingAdmissionPolicyBinding` are served and that admission is enabled. For an offline comparison, set `registry` and `tag` to the values from the workload Application and pass the discovered capabilities and destination Kubernetes version. This example assumes both kinds on Kubernetes 1.34. ```sh for run in 1 2; do helm template gameplane charts/gameplane -n gameplane-system \ + --set-string "image.registry=$registry" --set-string "image.tag=$tag" \ -f charts/gameplane/examples/argocd-values.yaml --kube-version 1.34.0 \ --api-versions admissionregistration.k8s.io/v1/ValidatingAdmissionPolicy \ --api-versions admissionregistration.k8s.io/v1/ValidatingAdmissionPolicyBinding \ diff --git a/docs/gateway-install.md b/docs/gateway-install.md index 8309975f4..c9a70d92b 100644 --- a/docs/gateway-install.md +++ b/docs/gateway-install.md @@ -89,9 +89,13 @@ namespace. The operator uses this port to start, stop and poll captures; the loc API uses it for files. Narrowing kubelet probe ports does not remove this allowance. Externally managed policies must permit the same control traffic. +Build the checkout images and set `registry` and `tag` as described in the +[source checkout instructions](install.md#install-from-a-source-checkout). + ```sh helm upgrade --install gameplane ./charts/gameplane \ --namespace gameplane-system --create-namespace \ + --set-string "image.registry=$registry" --set-string "image.tag=$tag" \ --values gateway-values.yaml ``` diff --git a/docs/install.md b/docs/install.md index afda771a5..752e0a014 100644 --- a/docs/install.md +++ b/docs/install.md @@ -59,8 +59,8 @@ flowchart TD ### Edge channel (latest edge build) -Every push to `master` publishes rolling `:edge` images. To track them, install -the chart and point images at the edge tag: +When an image's inputs change on `master`, CI publishes that component under +the rolling `:edge` tag. To try the edge images with a released chart, run: ```sh helm upgrade --install gameplane oci://ghcr.io/gameplanepanel/charts/gameplane \ @@ -69,8 +69,8 @@ helm upgrade --install gameplane oci://ghcr.io/gameplanepanel/charts/gameplane \ --set ingress.host=gameplane.your-domain.test ``` -`:edge` moves with `master`; pin a specific commit with `image.tag=sha-` -when you need reproducibility. +Only rebuilt components receive a `sha-` tag for that commit. For a +complete set of images from one revision, follow the checkout instructions below. ### Verifying image signatures @@ -91,14 +91,36 @@ trust continuity proof. Module bundles are verified the same way; the chart carries the key, so bundle verification is just a values flip — see [`module-authoring.md`](module-authoring.md#signing-official-bundles). -From source (during development), the chart in this repo always renders against -the local default image path: +### Install from a source checkout + +The checkout chart requires an explicit `image.tag`. From a clean checkout, +build and push the component images to a registry you can write to and your +cluster can pull from. Build for your workers' Linux architecture. The +example assumes the build host and workers use the same architecture and +uses the Git commit as the tag. It runs the telemetry receiver in the +development cluster. ```sh +registry=registry.example.com/gameplane # replace with your registry and repository prefix +tag=checkout-$(git rev-parse HEAD) +make images REGISTRY="$registry" TAG="$tag" +make dev-push REGISTRY="$registry" TAG="$tag" + helm upgrade --install gameplane ./charts/gameplane \ - --namespace gameplane-system --create-namespace + --namespace gameplane-system --create-namespace \ + --set-string "image.registry=$registry" --set-string "image.tag=$tag" \ + --set api.telemetry.receiver.enabled=true +kubectl -n gameplane-system rollout status deployment/gameplane-operator --timeout=5m +kubectl -n gameplane-system rollout status deployment/gameplane-api --timeout=5m ``` +When upgrading from another checkout, pass the new image tag even when using +`--reuse-values`. For a local kind cluster, follow the +[development quickstart](../README.md#quickstart-local-dev) to initialize the +submodules and build and load the checkout images with `make dev-up`. +To use published release images, +install the OCI chart at the matching release version as shown above. + > **Note:** GHCR packages are private on first publish. The maintainer makes the > `gameplane/operator`, `gameplane/api`, `gameplane/agent`, `charts/gameplane` and > `charts/gameplane-crds` packages public once (GHCR → package → *Package settings* → *Change visibility*) diff --git a/docs/oidc.md b/docs/oidc.md index 3e0d22f4d..8a54f1fae 100644 --- a/docs/oidc.md +++ b/docs/oidc.md @@ -406,9 +406,13 @@ Suppose you have a Keycloak realm with groups: **2. Deploy Gameplane with Helm values**: +For this checkout, use the `registry` and `tag` from the +[source checkout instructions](install.md#install-from-a-source-checkout). + ```bash helm install gameplane ./charts/gameplane \ --namespace gameplane \ + --set-string "image.registry=$registry" --set-string "image.tag=$tag" \ --set api.oidc.enabled=true \ --set api.oidc.issuer="https://keycloak.example.com/realms/master" \ --set api.oidc.clientID="gameplane" \ diff --git a/docs/sftp.md b/docs/sftp.md index 95add718d..ea88ad801 100644 --- a/docs/sftp.md +++ b/docs/sftp.md @@ -12,7 +12,10 @@ what they could already reach in the dashboard. ## Turn it on -SFTP is controlled by Helm values. Enable it with `helm upgrade --reuse-values`: +These examples use the same checkout that installed the release. +`--reuse-values` keeps its image registry and tag. When upgrading the checkout, +supply the [new build's tag](install.md#install-from-a-source-checkout). +Enable SFTP with Helm: ```sh helm upgrade gameplane charts/gameplane --reuse-values \ diff --git a/docs/standalone-panel.md b/docs/standalone-panel.md index 1e410cc8e..5790aa1fe 100644 --- a/docs/standalone-panel.md +++ b/docs/standalone-panel.md @@ -215,11 +215,14 @@ for retained backups. ## Central panel on Kubernetes The panel can also run in a Kubernetes cluster without using that cluster for -games or granting the API Kubernetes access. From this checkout: +games or granting the API Kubernetes access. Build the checkout images and set +`registry` and `tag` as shown in the +[source checkout instructions](install.md#install-from-a-source-checkout). ```sh helm upgrade --install gameplane charts/gameplane \ --namespace gameplane-system --create-namespace \ + --set-string "image.registry=$registry" --set-string "image.tag=$tag" \ --values charts/gameplane/examples/standalone-panel-values.yaml ``` diff --git a/test/e2e/game_worker_pool_e2e_test.go b/test/e2e/game_worker_pool_e2e_test.go index 12da43701..f1df2bc78 100644 --- a/test/e2e/game_worker_pool_e2e_test.go +++ b/test/e2e/game_worker_pool_e2e_test.go @@ -105,6 +105,7 @@ func TestGameWorkerPoolAndQuota(t *testing.T) { t.Fatal(err) } rendered, err := exec.CommandContext(ctx, "helm", "template", ns, chart, "-n", "gameplane-system", "-f", path, + "--set-string", "image.tag="+e.Tag, "--show-only", "templates/game-worker-admission.yaml", "--show-only", "templates/tenant-quotas.yaml").CombinedOutput() if err != nil { t.Fatalf("helm: %v: %s", err, rendered) diff --git a/test/e2e/helm_install_e2e_test.go b/test/e2e/helm_install_e2e_test.go index 73b3f89b8..c13c3f6c9 100644 --- a/test/e2e/helm_install_e2e_test.go +++ b/test/e2e/helm_install_e2e_test.go @@ -395,6 +395,7 @@ func TestHelmInstall_BringYourOwnMTLSCA(t *testing.T) { outBytes, err := exec.CommandContext(ctx, "helm", "template", "gameplane", filepath.Join(repoRoot, "charts", "gameplane"), "-n", "gameplane-system", + "--set-string", "image.tag="+envInstance.Tag, "--set", "api.agentMTLS.caSecretRef.name=my-custom-ca", "--set", "api.agentMTLS.clientCertRef.name=my-custom-client", ).CombinedOutput() @@ -543,6 +544,7 @@ func runHelmTemplate(ctx context.Context, t *testing.T, chartPath, ns string, ex args := append([]string{"template", "gameplane", chartPath, "--kube-context", envInstance.Context, "-n", ns, + "--set-string", "image.tag=" + envInstance.Tag, "-s", "templates/mtls.yaml", "--dry-run=server", "--is-upgrade", diff --git a/test/e2e/management_placement_e2e_test.go b/test/e2e/management_placement_e2e_test.go index ec4525dfa..7d0e96a30 100644 --- a/test/e2e/management_placement_e2e_test.go +++ b/test/e2e/management_placement_e2e_test.go @@ -82,6 +82,7 @@ func TestManagementPlacementAndDisruption(t *testing.T) { } selector := map[string]any{"app.kubernetes.io/name": "gameplane-web", "app.kubernetes.io/instance": ns} values := map[string]any{ + "image": map[string]string{"tag": e.Tag}, "operator": map[string]any{"enabled": false}, "api": map[string]any{"pdb": map[string]any{"enabled": true, "maxUnavailable": 1}}, "web": map[string]any{