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. 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.
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.
[Agones Series – Part 2] Address and Port of the Game Server
508 posts | 48 followers
FollowAlibaba Cloud Native Community - October 19, 2022
Alibaba Cloud Native Community - October 19, 2022
Alibaba Cloud Native Community - October 19, 2022
Alibaba Cloud Native Community - October 19, 2022
Alibaba Cloud Community - October 21, 2022
Alibaba Cloud Community - June 24, 2022
508 posts | 48 followers
FollowProvides a control plane to allow users to manage Kubernetes clusters that run based on different infrastructure resources
Learn MoreAccelerate and secure the development, deployment, and management of containerized applications cost-effectively.
Learn MoreWhen demand is unpredictable or testing is required for new features, the ability to spin capacity up or down is made easy with Alibaba Cloud gaming solutions.
Learn MoreAlibaba Cloud Container Service for Kubernetes is a fully managed cloud container management service that supports native Kubernetes and integrates with other Alibaba Cloud products.
Learn MoreMore Posts by Alibaba Cloud Native Community