Skip to content

feat(#4668): restricted-compatible security context for the sdk sidecar - #4718

Open
GrowlyX wants to merge 10 commits into
agones-dev:mainfrom
GrowlyX:feat/sidecar-restricted-security-context
Open

feat(#4668): restricted-compatible security context for the sdk sidecar#4718
GrowlyX wants to merge 10 commits into
agones-dev:mainfrom
GrowlyX:feat/sidecar-restricted-security-context

Conversation

@GrowlyX

@GrowlyX GrowlyX commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind feature

What this PR does / Why we need it:

When running a Fleet in a namespace with pod-security.kubernetes.io/enforce set to restricted, provisioning fails because the Agones SDK sidecar container doesn't satisfy "restricted" pod security requirements.

This is fixed by adding capabilities.drop: ["ALL"] and a seccompProfile.type: RuntimeDefault to the sidecar container. This is fully configurable through the helm variables set in agones.image.sdk.securityContext, or the SIDECAR_SECURTY_CONTEXT env.

The behavior of SIDECAR_RUN_AS_USER remains unchanged if NO SIDECAR_SECURTY_CONTEXT, but the value of the SIDECAR_SECURTY_CONTEXT/helm supersecedes the value of SIDECAR_RUN_AS_USER if both are set.

Which issue(s) this PR fixes:

Closes #4668

Did you use AI tools in preparing this PR?:

Y

Special notes for your reviewer:

N/A

The sdk sidecar container now drops all capabilities and uses the
RuntimeDefault seccomp profile by default, so GameServers can run in
namespaces enforcing the restricted Pod Security Standard.

The full sidecar security context is configurable through the
agones.image.sdk.securityContext Helm value, passed to the controller
as JSON via SIDECAR_SECURITY_CONTEXT / --sidecar-security-context.

Closes agones-dev#4668

Signed-off-by: Subham K. <me@growly.gg>
@GrowlyX GrowlyX changed the title feat: restricted-compatible security context for the sdk sidecar feat(#4668): restricted-compatible security context for the sdk sidecar Sep 5, 2026
@markmandel
markmandel requested a lite review from Copilot September 5, 2026 02:39
@markmandel

Copy link
Copy Markdown
Member

/gcbrun

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change set is coherent and well-covered (unit + e2e) and should reliably enable PSA restricted compatibility, with only a minor flag-help wording nit noted.

Pull request overview

Updates the Agones GameServer SDK sidecar to be compatible by default with Kubernetes Pod Security Admission restricted, while allowing operators to override the sidecar container SecurityContext via Helm or controller configuration.

Changes:

  • Add a restricted-compatible default SecurityContext for the SDK sidecar (drop all caps + seccompProfile: RuntimeDefault) and pass it through controller config.
  • Expose sidecar security context configuration via Helm (agones.image.sdk.securityContext) and controller env/flag (SIDECAR_SECURITY_CONTEXT / --sidecar-security-context).
  • Add unit and e2e coverage plus documentation updates for Pod Security Standards and the new Helm value.
File summaries
File Description
test/e2e/gameserver_test.go Adds an e2e test that verifies a GameServer becomes Ready under PSA restricted with the sidecar’s compliant security context.
site/content/en/docs/Installation/Install Agones/helm.md Documents the new Helm value agones.image.sdk.securityContext (version-gated) and links relevant Kubernetes docs.
site/content/en/docs/Guides/Best Practices/_index.md Adds best-practices guidance for running under Pod Security Standards and notes how to override the sidecar context.
pkg/gameservers/controller.go Introduces a default sidecar SecurityContext and wires controller-side configuration to apply it to sidecar containers.
pkg/gameservers/controller_test.go Extends controller unit tests to assert the new default context fields and configurability/copy behavior.
install/yaml/install.yaml Updates the generated install manifest to use SIDECAR_SECURITY_CONTEXT with a restricted-compatible default JSON value.
install/helm/agones/values.yaml Adds default agones.image.sdk.securityContext values compatible with PSA restricted.
install/helm/agones/templates/controller.yaml Switches controller env wiring from SIDECAR_RUN_AS_USER to SIDECAR_SECURITY_CONTEXT (templated via toJson).
cmd/controller/main.go Adds parsing/wiring for --sidecar-security-context / SIDECAR_SECURITY_CONTEXT and passes it into the GameServer controller.
cmd/controller/main_test.go Adds tests for parsing sidecar security context (default fallback, custom JSON, invalid JSON).
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/controller/main.go Outdated
@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: bb32d3ad-34fd-4d2d-9d93-a92ed4adda9b

Status: FAILURE

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@github-actions github-actions Bot added the kind/feature New features for Agones label Sep 5, 2026
The baseline and restricted Pod Security Standards forbid hostPort,
so the GameServer in the test cannot use a Dynamic port. Document the
constraint, and clarify the --sidecar-run-as-user help text.

Signed-off-by: Subham K. <me@growly.gg>
@markmandel

Copy link
Copy Markdown
Member

/gcbrun

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: f2b116d7-3dd5-4dcc-a2cb-f559df5d768f

Status: FAILURE

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

…e2e test

On GKE Autopilot, Agones defaults the Pod seccomp profile to Unconfined
unless the template sets one, which the restricted Pod Security Standard
rejects. Document this, and log GameServer events when a GameServer fails
to become Ready in e2e tests.

Signed-off-by: Subham K. <me@growly.gg>
@markmandel

Copy link
Copy Markdown
Member

/gcbrun

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: 9d8174a8-aa62-4d42-b29f-d9bef7d9e466

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

git fetch https://github.com/googleforgames/agones.git pull/4718/head:pr_4718 && git checkout pr_4718
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.61.0-dev-6c9dfa3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not compatible with restricted pod security

4 participants