Skip to content

Commit

Permalink
Add cluster creation Quickstart with no build tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
dzlier-gcp committed Mar 1, 2018
1 parent 09cf3cb commit e5664a2
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 0 deletions.
183 changes: 183 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# 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. [Table of contents](#table-of-contents)
1. [Setting up a Google Kubernetes Engine (GKE) cluster](#setting-up-a-google-kubernetes-engine-gke-cluster)
1. [Before you begin](#before-you-begin)
1. [Choosing a shell](#choosing-a-shell)
1. [Cloud shell](#cloud-shell)
1. [Local shell](#local-shell)
1. [Configuring gcloud](#configuring-gcloud)
1. [Creating the cluster](#creating-the-cluster)
1. [Creating the firewall](#creating-the-firewall)
1. [Setting up a Minikube cluster](#setting-up-a-minikube-cluster)
1. [Installing Minikube](#installing-minikube)
1. [Creating an agones profile](#creating-an-agones-profile)
1. [Starting Minikube](#starting-minikube)
1. [Enabling creation of RBAC resources](#enabling-creation-of-rbac-resources)
1. [Installing Agones](#installing-agones)

# 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.
1. Create or select a project.
1. Wait for the API and related services to be enabled. This can take several minutes.
1. [Enable billing][billing] for your project.

[billing]: https://support.google.com/cloud/answer/6293499#enable-billing

## Choosing a shell

To complete this quickstart, we can use either [Google Cloud Shell][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][gcloud] and [kubectl][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]: https://cloud.google.com/shell/
[gcloud]: https://cloud.google.com/sdk/gcloud/
[kubectl]: https://kubernetes.io/docs/user-guide/kubectl-overview/

### Cloud shell

To launch Cloud Shell, perform the following steps:

1. Go to [Google Cloud Platform Console][cloud]
1. From the top-right corner of the console, click the **Activate Google Cloud Shell** button: ![cloud shell](/docs/cloud-shell.png?raw=true)
1. A Cloud Shell session opens inside a frame at the bottom of the console. Use this shell to run `gcloud` and `kubectl` commands.

[cloud]: https://console.cloud.google.com/home/dashboard

### Local shell

To install `gcloud` and `kubectl`, perform the following steps:

1. [Install the Google Cloud SDK][gcloud-install], which includes the `gcloud` command-line tool.
1. After installing Cloud SDK, install the `kubectl` command-line tool by running the following command:

```bash
gcloud components install kubectl
```

[gcloud-install]: https://cloud.google.com/sdk/docs/quickstarts

## Configuring gcloud

We need to configure some default settings for gcloud, so it knows what project and geographical compute zone we'd like to use for our cluster.

Our Project ID is chosen or generated when we create the project. The compute zone will be something like `us-west1-a`. A full list can be found [here][zones].

```bash
gcloud config set project [PROJECT_ID]
gcloud config set compute/zone [COMPUTE_ZONE]
```

[zones]: https://cloud.google.com/compute/docs/regions-zones/#available

## Creating the cluster

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

```bash
gcloud container clusters create [CLUSTER_NAME] --cluster-version=v1.9.0 \
--no-enable-legacy-authorization \
--tags=game-server \
--enable-basic-auth \
--password=supersecretpassword \
--scopes=https://www.googleapis.com/auth/devstorage.read_only,compute-rw,cloud-platform
```

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.

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

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

[cluster]: https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-architecture
[vms]: https://cloud.google.com/compute/docs/instances/

### Creating the firewall

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

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

Now continue to [Enabling creation of RBAC resources](#enabling-creation-of-rbac-resources)

# Setting up a Minikube cluster

This will setup a [Minikube](https://github.com/kubernetes/minikube) cluster, running on an `agones` profile.

## Installing Minikube

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

[minikube]: https://github.com/kubernetes/minikube#installation
[vb]: https://www.virtualbox.org

## Creating an `agones` profile

We need a minikube profile for `agones`.

```bash
minikube profile agones
```

## Starting Minikube

The following command starts a local minikube cluster via virtualbox.

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

# Enabling creation of RBAC resources

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

```bash
# 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.

```bash
kubectl apply -f ../../install.yaml
```

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

[crds]: https://kubernetes.io/docs/concepts/api-extension/custom-resources/
Binary file added docs/cloud-shell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e5664a2

Please sign in to comment.