×
Community Blog [Agones Series – Part 1] The First Bite of Agones

[Agones Series – Part 1] The First Bite of Agones

Part 1 of the Agones Series describes Agones and the process of running Agones on Alibaba Cloud Container Service (ACK) to deploy game servers.

By Qiuyang Liu (Liming)

Agones is a framework designed to deploy, run, and scale game servers on Kubernetes., Please see the official website and GitHub for more information. This article describes how to deploy and use Agones on Alibaba Cloud ACK.

1

Install Agones on ACK

1.  First, create the required Agones namespace:

$ kubectl create namespace agones-system

2.  Install the corresponding version of Agones through the configuration file. Here, I chose version 1.23:

$ kubectl apply -f https://raw.githubusercontent.com/googleforgames/agones/release-1.23.0/install/yaml/install.yaml

After the installation, the following resources are available in the namespace:

get deploy -n agones-system
NAME                READY   UP-TO-DATE   AVAILABLE   AGE
agones-allocator    3/3     3            3           3d
agones-controller   1/1     1            1           3d
agones-ping         2/2     2            2           3d

kubectl get po -n agones-system
NAME                                 READY   STATUS    RESTARTS   AGE
agones-allocator-554c79cffc-6dpzp    1/1     Running   0          3d
agones-allocator-554c79cffc-jlp5t    1/1     Running   0          3d
agones-allocator-554c79cffc-kbn5w    1/1     Running   0          3d
agones-controller-864dd7dbc4-2ghs8   1/1     Running   0          3d
agones-ping-77b7dc578c-9dfk7         1/1     Running   0          3d
agones-ping-77b7dc578c-hhvff         1/1     Running   0          3d

kubectl get svc -n agones-system
NAME                               TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)            AGE
agones-allocator                   LoadBalancer   172.16.157.137   47.105.53.1       443:30302/TCP      3d
agones-allocator-metrics-service   ClusterIP      172.16.238.137               8080/TCP           3d
agones-controller-service          ClusterIP      172.16.150.98                443/TCP,8080/TCP   3d
agones-ping-http-service           LoadBalancer   172.16.253.193   118.190.206.167   80:30770/TCP       3d
agones-ping-udp-service            LoadBalancer   172.16.10.63     47.104.240.179    50000:32691/UDP    3d

Note: Alibaba Cloud cannot connect to gcr.io. I pulled the same image I made on the node in advance and then labeled gcr with the same name tag, thus bypassing this problem.

Deploy a Game Server on Agones

Here, we use the Unity example (path: agones/examples/unity-sample) in the official Agones GitHub to import the project to Unity Editor. Build server and client separately.

Use the Dockerfile in the project to create a service image:

FROM ubuntu:18.04

WORKDIR /unity

# Need to build with UnityEditor in advance.
COPY Builds/Server/ ./

# [Workaround] Wait until the sidecar is ready.
CMD sleep 2 && ./UnitySimpleServer.x86_64

After uploading it to the image repository, we start to deploy the game server. The deployment method is simple; just apply yaml:

apiVersion: "agones.dev/v1"
kind: GameServer
metadata:
  name: "unity-simple-server"
spec:
  ports:
  - name: default
    portPolicy: Dynamic
    containerPort: 7777
  template:
    spec:
      containers:
      - name: unity-simple-server
        #Use the game server image just created.
        image: xxx:xx 

Soon, gs will complete the deployment.

kubectl get gs
NAME                  STATE   ADDRESS         PORT   NODE                  AGE
unity-simple-server   Ready   120.27.21.131   7050   cn-xxx.192.xx.xx.48   2d

We use the client to connect to the game server through ADDRESS and PORT. Let's see how it works:

The entered sentence was displayed on the screen, indicating that the game service is running normally.

0 0 0
Share on

You may also like

Comments

Related Products