Skip to content

Populate Env Vars for GameServer init containers#4319

Merged
markmandel merged 5 commits intoagones-dev:mainfrom
giornetta:env-init-containers
Oct 31, 2025
Merged

Populate Env Vars for GameServer init containers#4319
markmandel merged 5 commits intoagones-dev:mainfrom
giornetta:env-init-containers

Conversation

@giornetta
Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind bug

What this PR does / Why we need it:
This MR adds code to populate environment variables for init containers defined in a GameServer spec.

This allows init containers to communicate with the SDK server during initialization, enabling use cases where setup logic needs to interact with Agones APIs before the main game server container starts.

Which issue(s) this PR fixes:
Closes #4241

@github-actions github-actions bot added kind/bug These are bugs. size/S labels Oct 30, 2025
Copy link
Copy Markdown
Collaborator

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

Thanks, we needed this!

/gcbrun

func (c *Controller) addSDKServerEnvVars(gs *agonesv1.GameServer, pod *corev1.Pod) {
sdkEnvVars := sdkEnvironmentVariables(gs)
if sdkEnvVars == nil {
// If a gameserver was created before 1.1 when we started defaulting the grpc and http ports,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wish I could remember why this is here 🤣

@markmandel
Copy link
Copy Markdown
Collaborator

/gcbrun

Copy link
Copy Markdown
Collaborator

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

LGTM!

@markmandel markmandel enabled auto-merge (squash) October 31, 2025 20:09
@markmandel
Copy link
Copy Markdown
Collaborator

/gcbrun

1 similar comment
@markmandel
Copy link
Copy Markdown
Collaborator

/gcbrun

@markmandel markmandel merged commit 9757f2c into agones-dev:main Oct 31, 2025
4 checks passed
@agones-bot
Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: 519cc5be-20c0-4c48-ba44-b229fbda7957

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/4319/head:pr_4319 && git checkout pr_4319
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.54.0-dev-d1a78ee

@agones-bot
Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: c189e602-98ca-445d-a1a4-ee897ee0b993

Status: FAILURE

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

@agones-bot
Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: 95b70e62-0bca-429c-bf2e-1511167673a7

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/4319/head:pr_4319 && git checkout pr_4319
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.54.0-dev-76f28ef

@giornetta giornetta deleted the env-init-containers branch November 1, 2025 17:21
@giornetta giornetta restored the env-init-containers branch November 1, 2025 17:22
@giornetta giornetta deleted the env-init-containers branch November 1, 2025 17:22
mnthe pushed a commit to mnthe/agones that referenced this pull request Mar 23, 2026
* populate env variables for init containers

* add newline

* move addEnvVars function to global scope

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

Labels

kind/bug These are bugs. size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AGONES_SDK_GRPC_PORT and AGONES_SDK_HTTP_PORT should also be populated for init containers

3 participants