Skip to content

AGONES_SDK_GRPC_PORT and AGONES_SDK_HTTP_PORT should also be populated for init containers #4241

@stevefan1999-personal

Description

@stevefan1999-personal

What happened:
The environment variables AGONES_SDK_GRPC_PORT and AGONES_SDK_HTTP_PORT are not being injected into init containers of GameServer pods. These variables are correctly populated for the main game server container but are missing from any init containers defined in the GameServer specification.

What you expected to happen:
Both AGONES_SDK_GRPC_PORT and AGONES_SDK_HTTP_PORT environment variables should be automatically injected into all containers within the GameServer pod, including init containers. This would allow init containers to interact with the Agones SDK during the initialization phase, enabling use cases such as:

  • Pre-game configuration validation via SDK
  • Health check setup before main container starts
  • Game state initialization that requires SDK communication

How to reproduce it (as minimally and precisely as possible):

  1. Create a GameServer with an init container:
apiVersion: agones.dev/v1
kind: GameServer
metadata:
  name: test-gameserver
spec:
  ports:
  - name: default
    containerPort: 7654
  template:
    spec:
      initContainers:
      - name: init-container
        image: alpine:latest
        command: ["/bin/sh", "-c"]
        args: 
        - |
          echo "AGONES_SDK_GRPC_PORT: $AGONES_SDK_GRPC_PORT"
          echo "AGONES_SDK_HTTP_PORT: $AGONES_SDK_HTTP_PORT"
          env | grep AGONES
      containers:
      - name: simple-game-server
        image: us-docker.pkg.dev/agones-images/examples/simple-game-server:latest
  1. Apply the GameServer: kubectl apply -f gameserver.yaml
  2. Check init container logs: kubectl logs <pod-name> -c init-container
  3. Observe that AGONES_SDK_GRPC_PORT and AGONES_SDK_HTTP_PORT are empty or not present
  4. Compare with main container: kubectl exec <pod-name> -c simple-game-server -- env | grep AGONES
  5. Notice that the main container has these variables properly set

Anything else we need to know?:

  • This issue prevents init containers from using the Agones SDK client libraries
  • Workaround currently requires hardcoding the default ports (9357 for gRPC, 9358 for HTTP) in init containers
  • The SDK sidecar is running and accessible during init container execution, but without the port environment variables, SDK clients cannot automatically connect

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting-maintainerBlock issues from being stale/obsolete/closedgood first issueThese are great first issues. If you are looking for a place to start, start here!help wantedWe would love help on these issues. Please come help us!kind/bugThese are bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions