Skip to main content

Agones Headless Game Server Fleet Deployment

✍ Last Updated : September 19, 2022

🚪 Prequisite Knowledge (Optional)

Upload[Agones InInstallation](Agones ProgressInstallation dc97a0baa4c3476895d16e7acadb5864.md)

[Building Unity Headless Docker Image](Building Unity Headless Docker Image 45ec56a4f4bb4e9a88414df175ae7885.md)

[Dedicated Game Server Orchestration 101](Dedicated Game Server Orchestration 101 8894e7781b594083ae1a1a93405851a1.md)

[Agones](Agones a9782a164f514f0e8541ce619fc49a5a.md)

❓ Key Question / Problem / Issue

  1. How to setup agones Headless Server Fleet ?
  2. how to check if configured fleet is running properly

✅ Expected Output/Definition of Done

  1. Simple Guideline on how to configure agones headless server deployment fleet

🎁 Resulting Solution

Solution Prequisite :

  1. Headless Server image registered within docker local container registry
    1. this local container registry need to be accessible within minikube accessible container registry
  2. Headless server image named unity-headless

Open Ports

For your client to be able to connect to the headless container, you need to set the ports your headless is listening to by adding it into the file Deployment/fleet.yaml

apiVersion: 'agones.dev/v1'
kind: Fleet
metadata:
  name: unity-headless-fleet
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: unity-headless
    spec:
      ports:
        **- name: fusion
          containerPort: 27015
          protocol: UDP
        - name: mirror
          containerPort: 7777
          protocol: UDP**
      health:
        initialDelaySeconds: 30
        periodSeconds: 60
      sdkServer:
        logLevel: Info
        grpcPort: 9357
        httpPort: 9358
      template:
        spec:
          containers:
            - name: unity-headless
              image: unity-headless # Headless Server Image names
              imagePullPolicy: Never # make sure it only fetch the image from local registry
---
apiVersion: 'autoscaling.agones.dev/v1'
kind: FleetAutoscaler
metadata:
  name: unity-headless-fleet-autoscaler
spec:
  fleetName: unity-headless-fleet
  policy:
    type: Buffer
    buffer:
      bufferSize: 2
      minReplicas: 0
      maxReplicas: 10

in this example

  • fusion with port 27015 protocol UDP
  • mirror with port 7777 protocol UDP

if you are using multiple ports or protocols

        - name: fusion
          containerPort: 27015
          protocol: UDP
        - name: mirror
          containerPort: 7777
          protocol: UDP
        - name: someotherport
          containerPort: 27020
          protocol: TCP

for more info read https://agones.dev/site/docs/reference/gameserver/

Deploy Headless Docker Image

After successfully creating your image, you now can deploy your headless into your local cluster

run

kubectl delete fleetautoscaler unity-headless-fleet-autoscaler
kubectl delete fleet unity-headless-fleet
kubectl apply -f Deployment\fleet.yaml

result

Error from server (NotFound): fleetautoscalers.autoscaling.agones.dev "unity-headless-fleet-autoscaler" not found
Error from server (NotFound): fleets.agones.dev "unity-headless-fleet" not found
fleet.agones.dev/unity-headless-fleet created
fleetautoscaler.autoscaling.agones.dev/unity-headless-fleet-autoscaler created

don’t worry if you see an error saying Error from server (NotFound), that’s normal if you never deployed the headless before

Check Deployment

To check if your headless is successfully deployed

run

kubectl get gameserver

result

NAME                               STATE   ADDRESS        PORT   NODE     AGE
unity-headless-fleet-2cj4x-grj82   Ready   192.168.49.2   7624   agones   39s
unity-headless-fleet-2cj4x-wt2nb   Ready   192.168.49.2   7259   agones   39s

there should be 2 instances of the headless running

We also provided a sample unity project with AgonesSDK implemented

This unity project also implemented an example API call to SampleAPI which will be explained next