Minecraft dedicated game server cluster hosting solution using GKE and Agones.
Suitable for both ephemeral and eternal game servers
This public DNS zone will be used to assign A and SRV DNS record to Minecraft GameServers
gcloud dns managed-zones create agones-minecraft \
--description="agones-mc-dns-controller managed DNS zone" \
--dns-name=<DOMAIN> \
--visibility=publicPoint an owned domain to the zone's NS record. This is done on the domain name registrar.
gcloud dns managed-zones describe agones-minecraftWorld archives will be storage on GCP Cloud Storage buckets. Object storage offers better portability, easier management, and an overall better price over volumes.
The following command will make a bucket named agones-minecraft-mc-worlds. This will make a single bucket that will contain all archives.
gsutil mb -l us-central1 gs://agones-minecraft-mc-worlds
Creates GKE cluster with 2 n2-standard-4 (4 x vCPU, 16GB), tags for firewall, and necessary scopes for Cloud DNS and Cloud Storage
gcloud container clusters create minecraft --cluster-version=1.18 \
--tags=mc \
--scopes=gke-default,storage-rw,"https://www.googleapis.com/auth/ndev.clouddns.readwrite" \
--num-nodes=2 \
--no-enable-autoupgrade \
--machine-type=n2-standard-4Set cluster as default and get credentials for kubectl
gcloud config set container/cluster minecraft
gcloud container clusters get-credentials minecraftPlayers will connect to GameServer Pods using controller allocated hostPorts. Assign firewall rules to open all Agones allocatable ports. TCP is for Java and UDP is for Bedrock servers
gcloud compute firewall-rules create mc-server-firewall \
--allow tcp:7000-8000,udp:7000-8000 \
--target-tags mc \
--description "Firewall rule to allow mc server tcp traffic"kubectl create namespace agones-system
kubectl apply -f https://raw.githubusercontent.com/googleforgames/agones/release-1.14.0/install/yaml/install.yamlor
helm repo add agones https://agones.dev/chart/stable
helm repo update
helm install agones --namespace agones-system --create-namespace agones/agoneskubectl get pods -n agones-systemThis controller is a fork of kubernetes-sigs/external-dns custom support for Agones GameServer sources. It will manage A and SRV records for Agones GameServers and Fleets allowing players to connect using a unique subdomain.
kubectl apply -f https://raw.githubusercontent.com/saulmaldonado/agones-minecraft/main/k8s/external-dns.ymlFleets will deploy and manage a set of Ready GameServers that can immediately be allocated for players to connect to.
# replace 'example.com' with the domain of the managed zone
sed 's/<DOMAIN>/example.com/' k8s/mc-server-fleet.yml | kubectl apply -f -Full Java server fleet example
Allocating a server will make sure it does not get shutdown in the event of fleet scaling or rolling restart.
kubectl create -f k8s/allocation.ymlPlayers can connect using unique subdomain
<GAMESERVER_NAME>.<MANAGED_ZONE_DOMAIN>example:
NAME STATE ADDRESS PORT NODE
mc-dj4jq-52tsd Allocated 35.232.46.5 7701 gke-minecraft-default-pool-47e5fdf8-5h9q
external-dns.alpha.kubernetes.io/hostname: saulmaldonado.me.
mc-dj4jq-52tsd.saulmaldonado.me
Fleets will deploy and manage a set of Ready GameServers that can immediately be allocated for players to connect to.
# replace 'example.com' with the domain of the managed zone
sed 's/<DOMAIN>/example.com/' k8s/mc-bedrock-fleet.yml | kubectl apply -f -Full Bedrock server fleet example
Allocating a server will make sure it does not get shutdown in the event of fleet scaling or rolling restart.
kubectl create -f k8s/bedrock-allocation.ymlPlayers can connect using unique subdomain and allocated port (bedrock does not support SRV records)
<GAMESERVER_NAME>.<MANAGED_ZONE_DOMAIN>:<GAMESERVER_PORT>example:
NAME STATE ADDRESS PORT NODE
mc-dj4jq-52tsd Allocated 35.232.46.5 7701 gke-minecraft-default-pool-47e5fdf8-5h9q
external-dns.alpha.kubernetes.io/hostname: saulmaldonado.me.
address: mc-dj4jq-52tsd.saulmaldonado.me
port: 7701