Switch branches/tags
Nothing to show
Find file Copy path
df40107 Mar 5, 2018
210 lines (149 sloc) 8.31 KB

Install and configure Agones on Kubernetes

In this quickstart, we will create a Kubernetes cluster, and populate it with the resource types that power Agones.

Table of contents

  1. Setting up a Google Kubernetes Engine (GKE) cluster
    1. Before you begin
    2. Choosing a shell
      1. Cloud shell
      2. Local shell
    3. Creating the cluster
      1. Creating the firewall
  2. Setting up a Minikube cluster
    1. Installing Minikube
    2. Creating an agones profile
    3. Starting Minikube
  3. Enabling creation of RBAC resources
  4. Installing Agones
    1. Confirming Agones started successfully
  5. What's next

Setting up a Google Kubernetes Engine (GKE) cluster

Follow these steps to create a cluster and install Agones directly on Google Kubernetes Engine (GKE).

Before you begin

Take the following steps to enable the Kubernetes Engine API:

  1. Visit the Kubernetes Engine page in the Google Cloud Platform Console.
  2. Create or select a project.
  3. Wait for the API and related services to be enabled. This can take several minutes.
  4. Enable billing for your project.
    • If you are not an existing GCP user, you may be able to enroll for a $300 US Free Trial credit.

Choosing a shell

To complete this quickstart, we can use either Google Cloud Shell or a local shell.

Google Cloud Shell is a shell environment for managing resources hosted on Google Cloud Platform (GCP). Cloud Shell comes preinstalled with the gcloud and kubectl command-line tools. gcloud provides the primary command-line interface for GCP, and kubectl provides the command-line interface for running commands against Kubernetes clusters.

If you prefer using your local shell, you must install the gcloud and kubectl command-line tools in your environment.

Cloud shell

To launch Cloud Shell, perform the following steps:

  1. Go to Google Cloud Platform Console
  2. From the top-right corner of the console, click the Activate Google Cloud Shell button: cloud shell
  3. A Cloud Shell session opens inside a frame at the bottom of the console. Use this shell to run gcloud and kubectl commands.
  4. Set a compute zone in your geographical region with the following command. The compute zone will be something like us-west1-a. A full list can be found here.
    gcloud config set compute/zone [COMPUTE_ZONE]

Local shell

To install gcloud and kubectl, perform the following steps:

  1. Install the Google Cloud SDK, which includes the gcloud command-line tool.
  2. Initialize some default configuration by running the following command.
    • When asked Do you want to configure a default Compute Region and Zone? (Y/n)?, enter Y and choose a zone in your geographical region of choice.
    gcloud init
  3. Install the kubectl command-line tool by running the following command:
    gcloud components install kubectl

Creating the cluster

A cluster consists of at least one cluster master machine and multiple worker machines called nodes: Compute Engine virtual machine instances that run the Kubernetes processes necessary to make them part of the cluster.

gcloud container clusters create [CLUSTER_NAME] --cluster-version=1.9.2-gke.1 \
  --no-enable-legacy-authorization \
  --tags=game-server \
  --enable-basic-auth \
  --password=supersecretpassword \

Flag explanations:

  • cluster-version: Agones requires Kubernetes version 1.9+. Once the default version reaches 1.9, this will no longer be necessary.
  • no-enable-legacy-authorization: This enables RBAC, the authorization scheme used by Agones to control access to resources.
  • tags: Defines the tags that will be attached to new nodes in the cluster. This is to grant access through ports via the firewall created in the next step.
  • enable-basic-auth/password: Sets the master auth scheme for interacting with the cluster.
  • scopes: Defines the Oauth scopes required by the nodes.
  • num-nodes: The number of nodes to be created in each of the cluster's zones. Default: 3
  • machine-type: The type of machine to use for nodes. Default: n1-standard-1.

Finally, let's tell gcloud that we are speaking with this cluster, and get auth credentials for kubectl to use.

gcloud config set container/cluster [CLUSTER_NAME]
gcloud container clusters get-credentials [CLUSTER_NAME]

Creating the firewall

We need a firewall to allow UDP traffic to nodes tagged as game-server via ports 7000-8000.

gcloud compute firewall-rules create game-server-firewall \
  --allow udp:7000-8000 \
  --target-tags game-server \
  --description "Firewall to allow game server udp traffic"

Continue to Enabling creation of RBAC resources

Setting up a Minikube cluster

This will setup a Minikube cluster, running on an agones profile.

Installing Minikube

First, install Minikube, which may also require you to install a virtualisation solution, such as VirtualBox as well.

Creating an agones profile

Let's use a minikube profile for agones.

minikube profile agones

Starting Minikube

The following command starts a local minikube cluster via virtualbox.

minikube start --kubernetes-version v1.9.0 --vm-driver virtualbox \
  --extra-config=apiserver.Admission.PluginNames=NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota \

Enabling creation of RBAC resources

To install Agones, a service account needs permission to create some special RBAC resource types.

# Kubernetes Engine
kubectl create clusterrolebinding cluster-admin-binding \
  --clusterrole cluster-admin --user `gcloud config get-value account`
# Minikube
kubectl create clusterrolebinding cluster-admin-binding \
  --clusterrole=cluster-admin --serviceaccount=kube-system:default

Installing Agones

Finally, we install Agones to the cluster.

kubectl apply -f

Confirming Agones started successfully

To confirm Agones is up and running, run the following command:

kubectl describe --namespace agones-system pods

It should describe the single pod created in the agones-system namespace, with no error messages or status. The Conditions section should look like this:

  Type           Status
  Initialized    True 
  Ready          True 
  PodScheduled   True

That's it! This creates the Custom Resource Definitions that power Agones and allows us to define resources of type GameServer.

What's next