fix(agones): make the kind gate's Agones lifecycle actually work

Several independent causes, all of which had to be right before the
Fleet could reach Ready.

The supervisor pointed --sdk-base-url at 127.0.0.1:9357, which is the
Agones sidecar's gRPC port; its HTTP surface is 9358, and that is what
AGONES_SDK_HTTP_PORT carries and what agones_sdk.gd reads. An HTTP
client against the gRPC port could never have worked, in kind or in
production.

The supervisor also treated the sidecar's first incomplete /gameserver
response as fatal. The sidecar accepts requests before the controller
populates status.address and status.ports, so this produced a restart
loop precisely during normal Agones startup. It now polls until the
endpoint is assigned or ReadyTimeout elapses.

server_boot.gd started ServerControl and the Agones SDK only under
--allocated-mode, but the kind smoke deliberately strips that flag, so
nothing served the readiness probe and the GameServer could never become
Ready. Lifecycle now keys on AGONES_SDK_HTTP_PORT, which Agones injects
into every managed container, while allocation and roster semantics stay
tied to --allocated-mode. The SDK node is added to the tree
non-deferred, since start_health() creates a Timer immediately.

Fleet: Agones assigns its own SDK service account and masks that token
from the game container while keeping it for the injected sidecar, so
the manifest must not pin serviceAccountName or
automountServiceAccountToken. Godot stores user:// under HOME, so HOME
points at the writable runtime volume to keep the root filesystem
read-only, and fsGroup makes that volume writable for the non-root user.

Namespace: Agones' Dynamic port policy injects a hostPort, which both
the baseline and restricted Pod Security Standards forbid, so the
workload namespace enforces privileged while continuing to audit and
warn against restricted.

NetworkPolicy: the injected sidecar reaches the Kubernetes API over
HTTPS, and NetworkPolicy applies to the whole Pod rather than to the
container whose token was masked.

The kind runner creates the namespace before Helm so Agones can install
its per-namespace SDK RBAC, scopes gameservers.namespaces to it, forces
the allocator and ping Services to ClusterIP because LoadBalancer
ingress never becomes ready in plain kind, and labels the node so the
production Fleet's on-demand/zone constraints are exercised rather than
edited out of the rendered manifest.
This commit is contained in:
Josh Creek
2026-09-05 20:50:01 +01:00
parent 8aa4af3a3a
commit ca70568fad
11 changed files with 159 additions and 40 deletions
+10 -3
View File
@@ -43,19 +43,22 @@ spec:
labelSelector:
matchLabels:
app.kubernetes.io/name: game-server
serviceAccountName: match-server
automountServiceAccountToken: false
# Leave serviceAccountName unset: Agones assigns its SDK account and
# masks that account's token from this public game-server container,
# while retaining it in the injected SDK sidecar that needs API access.
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
fsGroup: 10001
fsGroupChangePolicy: OnRootMismatch
seccompProfile:
type: RuntimeDefault
containers:
- name: game-server
image: ghcr.io/cosmic-clash/game-server@sha256:0000000000000000000000000000000000000000000000000000000000000000
args:
- --sdk-base-url=http://127.0.0.1:9357
- --sdk-base-url=http://127.0.0.1:9358
- --ready-url=http://127.0.0.1:7780/ready
- --drain-url=http://127.0.0.1:7780/drain
- --initial-connect-ready-url=http://127.0.0.1:7780/initial-connect-ready
@@ -86,6 +89,10 @@ spec:
- --join-authorisations-key-file=/run/secrets/cosmic-clash/join-signing-keys.json
- --readiness-port=7780
env:
# Godot stores user:// beneath HOME. Point it at the writable
# runtime volume while retaining a read-only root filesystem.
- name: HOME
value: /run/cosmic-clash
- name: COSMIC_CLASH_SERVER_ID
valueFrom:
fieldRef:
+5 -2
View File
@@ -3,7 +3,10 @@ kind: Namespace
metadata:
name: cosmic-clash
labels:
pod-security.kubernetes.io/enforce: restricted
# Agones' Dynamic port policy injects a hostPort into every GameServer
# Pod. Kubernetes' built-in baseline and restricted policies both forbid
# host ports, so this workload namespace must enforce privileged while
# continuing to surface restricted-policy deviations in audit and warnings.
pod-security.kubernetes.io/enforce: privileged
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/warn: restricted
+6
View File
@@ -90,6 +90,12 @@ spec:
ports:
- protocol: TCP
port: 8080
# The injected Agones SDK sidecar updates its GameServer through the
# kubernetes.default HTTPS Service. Its token is masked from the public
# game-server container by Agones, but NetworkPolicy applies to the Pod.
- ports:
- protocol: TCP
port: 443
- ports:
- protocol: UDP
port: 53
-7
View File
@@ -7,13 +7,6 @@ automountServiceAccountToken: false
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: match-server
namespace: cosmic-clash
automountServiceAccountToken: false
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: allocator
namespace: cosmic-clash