Installing Agones on AWS Elastic Kubernetes Service using Terraform
You can use Terraform to provision your Amazon EKS (Elastic Kubernetes Service) cluster and install Agones on it using the Helm Terraform provider.
An example of the EKS submodule config file can be found here: Terraform configuration with Agones submodule
Copy this file into a separate folder.
Configure your AWS CLI tool CLI configure:
Initialise your terraform:
modules.tf you can change the parameters that you need to. For instance, the -
- cluster_name - the name of the EKS cluster (default is “agones-terraform-example”)
- agones_version - the version of agones to install (an empty string, which is the default, is the latest version from the Helm repository)
- machine_type - EC2 instance type for hosting game servers (default is “t2.large”)
- region - the location of the cluster (default is “us-west-2”)
- node_count - count of game server nodes for the default node pool (default is “4”)
- log_level - possible values: Fatal, Error, Warn, Info, Debug (default is “info”)
- feature_gates - a list of alpha and beta version features to enable. For example, “PlayerTracking=true&ContainerPortAllocation=true”
- gameserver_minPort - the lower bound of the port range which gameservers will listen on (default is “7000”)
- gameserver_maxPort - the upper bound of the port range which gameservers will listen on (default is “8000”)
- gameserver_namespaces - a list of namespaces which will be used to run gameservers (default is
["default"]). For example
["default", "xbox-gameservers", "mobile-gameservers"]
- force_update - whether or not to force the replacement/update of resource (default is true, false may be required to prevent immutability errors when updating the configuration)
Now you can create an EKS cluster and deploy Agones on EKS:
terraform apply [-var agones_version="1.11.0"]
After deploying the cluster with Agones, you can get or update your kubeconfig by using:
aws eks --region us-west-2 update-kubeconfig --name agones-cluster
With the following output:
Added new context arn:aws:eks:us-west-2:601646756426:cluster/agones-cluster to /Users/user/.kube/config
kubectl context to the recently created one:
kubectl config use-context arn:aws:eks:us-west-2:601646756426:cluster/agones-cluster
Check that you are authenticated against the recently created Kubernetes cluster:
kubectl get nodes
Uninstall the Agones and delete EKS cluster
Run the following commands to delete all Terraform provisioned resources:
terraform destroy -target module.helm_agones.helm_release.agones -auto-approve && sleep 60 terraform destroy
NoteThere is an issue with the AWS Terraform provider: https://github.com/terraform-providers/terraform-provider-aws/issues/9101 Due to this issue you should remove helm release first (as stated above), otherwise
terraform destroywill timeout and never succeed. Remove all created resources manually in that case, namely: 3 Auto Scaling groups, EKS cluster, and a VPC with all dependent resources.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.