Skip to content

Commit

Permalink
Added Helm support.
Browse files Browse the repository at this point in the history
Now you can deploy agones using
```bash
helm install --name my-release agones
```
Note that the build-image Dockerfile was
modified to download Helm and add it to the path

For more info see the documentation located
at `install/helm/README.md`
  • Loading branch information
fooock committed Apr 6, 2018
1 parent afd0e3d commit eed5609
Show file tree
Hide file tree
Showing 16 changed files with 561 additions and 1 deletion.
10 changes: 10 additions & 0 deletions build/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ ENV PATH /usr/local/go/bin:/go/bin:/opt/google-cloud-sdk/bin:$PATH
RUN gcloud components update && gcloud components install kubectl
RUN echo "source <(kubectl completion bash)" >> /root/.bashrc

# install Helm package manager
ENV HELM_VER 2.8.0
ENV HELM_URL https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VER}-linux-amd64.tar.gz
RUN curl -L ${HELM_URL} > /tmp/helm.tar.gz \
&& tar -zxvf /tmp/helm.tar.gz -C /tmp \
&& mv /tmp/linux-amd64/helm /usr/local/bin/helm \
&& chmod go+rx /usr/local/bin/helm \
&& rm /tmp/helm.tar.gz && rm -rf /tmp/linux-amd64
RUN echo "source <(helm completion bash)" >> /root/.bashrc

# install go tooling for development, building and testing
RUN go get -u github.com/golang/dep/cmd/dep && \
go get -u github.com/alecthomas/gometalinter && \
Expand Down
Binary file added docs/agones.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 17 additions & 1 deletion docs/installing_agones.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ In this quickstart, we will create a Kubernetes cluster, and populate it with th
1. [Starting Minikube](#starting-minikube)
1. [Enabling creation of RBAC resources](#enabling-creation-of-rbac-resources)
1. [Installing Agones](#installing-agones)
1. [Install with yaml](#install-with-yaml)
1. [Install using Helm](#install-using-helm)
1. [Confirming Agones started successfully](#confirming-agones-started-successfully)
1. [What's next](#whats-next)

Expand Down Expand Up @@ -175,12 +177,26 @@ kubectl create clusterrolebinding cluster-admin-binding \

# Installing Agones

Finally, we install Agones to the cluster.
This will install Agones in your cluster.

## Install with YAML

We can install Agones to the cluster using the [install.yaml file](agones-install-file)

[agones-install-file]: ../install/yaml/install.yaml

```bash
kubectl apply -f https://raw.githubusercontent.com/googlecloudplatform/agones/release-0.1/install.yaml
```

## Install using Helm

Also, we can install Agones using [Helm](helm) package manager. If you want more details and configuration
options see the [Helm installation guide for Agones](agones-install-guide)

[helm]: https://docs.helm.sh
[agones-install-guide]: ../install/helm/README.md

## Confirming Agones started successfully

To confirm Agones is up and running, run the following command:
Expand Down
80 changes: 80 additions & 0 deletions install/helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Install Agones using Helm

This chart install the Agones application and defines deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- [Helm](https://docs.helm.sh/helm/) package manager 2.8.0+
- Kubernetes 1.9+
- Role-based access controls (RBAC) activated
- MutatingAdmissionWebhook admission controller activated, see [recommendation](https://kubernetes.io/docs/admin/admission-controllers/#is-there-a-recommended-set-of-admission-controllers-to-use)

## Installing the Chart

> If you don't have `Helm` installed locally, or `Tiller` installed in your Kubernetes cluster, read the [Using Helm](https://docs.helm.sh/using_helm/) documentation to get started.
To install the chart with the release name `my-release`:

```bash
$ cd install/
$ helm install --name my-release agones
```

The command deploys Agones on the Kubernetes cluster with the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.


> **Tip**: List all releases using `helm list`
## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```bash
$ helm delete my-release
```

The command removes all the Kubernetes components associated with the chart and deletes the release.

## Configuration

The following tables lists the configurable parameters of the Agones chart and their default values.

| Parameter | Description | Default |
| ------------------------------------ | ----------------------------------------- | ---------------------------------------------------- |
| `namespace` | Namespace to use for Agones | `agones-system` |
| `serviceaccount.controller` | Service account name for the controller | `agones-controller` |
| `serviceaccount.sdk` | Service account name for the sdk | `agones-sdk` |
| `image.controller.repository` | Image repository for the controller | `gcr.io/agones-images/agones-controller` |
| `image.controller.tag` | Image tag for the controller | `0.1` |
| `image.controller.pullPolicy` | Image pull policy for the controller | `IfNotPresent` |
| `image.sdk.repository` | Image repository for the sdk | `gcr.io/agones-images/agones-sdk` |
| `image.sdk.tag` | Image tag for the sdk | `0.1` |
| `image.sdk.alwaysPull` | Tells if the sdk image should always be pulled | `false` |
| `minPort` | Minimum port to use for dynamic port allocation | `7000` |
| `maxPort` | Maximum port to use for dynamic port allocation | `8000` |
| `healthCheck.http.port` | Port to use for liveness probe service | `8080` |
| `healthCheck.initialDelaySeconds` | Initial delay before performing the first probe (in seconds) | `3` |
| `healthCheck.periodSeconds` | Seconds between every liveness probe (in seconds) | `3` |
| `healthCheck.failureThreshold` | Number of times before giving up (in seconds) | `3` |
| `healthCheck.timeoutSeconds` | Number of seconds after which the probe times out (in seconds) | `1` |

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

```bash
$ helm install --name my-release \
--set namespace=mynamespace,minPort=1000,maxPort=5000 agones
```

The above command sets the namespace where Agones is deployed to `mynamespace`. Additionally Agones will use a dynamic port allocation range of 1000-5000.

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

```bash
$ helm install --name my-release -f values.yaml agones
```

> **Tip**: You can use the default [values.yaml](agones/values.yaml)
## Confirm Agones is running

To confirm Agones is up and running, [go to the next section](../../docs/installing_agones#confirming-agones-started-successfully)
20 changes: 20 additions & 0 deletions install/helm/agones/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
appVersion: "0.1"
version: 0.1.0
name: agones
description: a library for hosting, running and scaling dedicated game servers on Kubernetes.
keywords:
- go
- golang
- dedicated-gameservers
- multiplayer
- game-development
home: https://agones.dev
sources:
- https://github.com/GoogleCloudPlatform/agones
maintainers:
- name: agones
email: agones-discuss@googlegroups.com
url: https://groups.google.com/forum/#!forum/agones-discuss
engine: gotpl
icon: https://github.com/GoogleCloudPlatform/agones/raw/master/docs/agones.png
29 changes: 29 additions & 0 deletions install/helm/agones/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
The Agones controller has been installed in the namespace {{ .Values.namespace }}.

You can watch the status by running 'kubectl --namespace {{ .Values.namespace }} get pods -o wide -w {{ .Values.serviceaccount.controller }}'

Once ready you can create your first GameServer using our examples:

'kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/agones/master/examples/simple-udp/server/gameserver.yaml'

An example GameServer that makes use of the controller:

apiVersion: "stable.agones.dev/v1alpha1"
kind: GameServer
metadata:
name: "simple-udp"
spec:
portPolicy: "dynamic"
containerPort: 7654
template:
spec:
containers:
- name: simple-udp
image: gcr.io/agones-images/udp-server:0.1

Finally don't forget to explore our documentation and usage guides on how to develop and host dedicated game servers on top of Agones. :

- [Create a Game Server](https://github.com/GoogleCloudPlatform/agones/blob/master/docs/create_gameserver.md)
- [Integrating the Game Server SDK](https://github.com/GoogleCloudPlatform/agones/tree/master/sdks)
- [GameServer Health Checking](https://github.com/GoogleCloudPlatform/agones/blob/master/docs/health_checking.md)
- [Accessing Agones via the Kubernetes API](https://github.com/GoogleCloudPlatform/agones/blob/master/docs/access_api.md)
32 changes: 32 additions & 0 deletions install/helm/agones/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "agones.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "agones.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "agones.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
48 changes: 48 additions & 0 deletions install/helm/agones/templates/controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: agones-controller
namespace: {{ .Values.namespace}}
labels:
component: controller
app: {{ template "agones.name" . }}
chart: {{ template "agones.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
stable.agones.dev/role: controller
app: {{ template "agones.name" . }}
chart: {{ template "agones.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
serviceAccountName: {{ .Values.serviceaccount.controller }}
containers:
- name: agones-controller
image: "{{ .Values.image.controller.repository }}:{{ .Values.image.controller.tag }}"
imagePullPolicy: {{ .Values.image.controller.pullPolicy }}
env:
- name: ALWAYS_PULL_SIDECAR # set the sidecar imagePullPolicy to Always
value: {{ .Values.image.sdk.alwaysPull | quote }}
# minimum port that can be exposed to GameServer traffic
- name: MIN_PORT
value: {{ .Values.minPort | quote }}
# maximum port that can be exposed to GameServer traffic
- name: MAX_PORT
value: {{ .Values.maxPort | quote }}
- name: SIDECAR # overwrite the GameServer sidecar image that is used
value: "{{ .Values.image.sdk.repository }}:{{ .Values.image.sdk.tag }}"
livenessProbe:
httpGet:
path: /live
port: {{ .Values.healthCheck.http.port }}
initialDelaySeconds: {{ .Values.healthCheck.initialDelaySeconds }}
periodSeconds: {{ .Values.healthCheck.periodSeconds }}
failureThreshold: {{ .Values.healthCheck.failureThreshold }}
timeoutSeconds: {{ .Values.healthCheck.timeoutSeconds }}
113 changes: 113 additions & 0 deletions install/helm/agones/templates/crds/gameserver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: gameservers.stable.agones.dev
labels:
component: crd
app: {{ template "agones.name" . }}
chart: {{ template "agones.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
group: stable.agones.dev
version: v1alpha1
scope: Namespaced
names:
kind: GameServer
plural: gameservers
shortNames:
- gs
singular: gameserver
validation:
openAPIV3Schema:
required:
- spec
properties:
spec:
required:
- containerPort
- template
properties:
template:
type: object
required:
- spec
properties:
spec:
type: object
required:
- containers
properties:
containers:
type: array
items:
type: object
required:
- image
properties:
name:
type: string
minLength: 0
maxLength: 63
pattern: "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"
image:
type: string
minLength: 1
minItems: 1
container:
title: The container name running the gameserver
description: if there is more than one container, specify which one is the game server
type: string
minLength: 0
maxLength: 63
pattern: "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"
portPolicy:
title: the port policy that will be applied to the game server
description: |
portPolicy has two options:
- "dynamic" (default) the system allocates a free hostPort for the gameserver, for game clients to connect to
- "static", user defines the hostPort that the game client will connect to. Then onus is on the user to ensure that the
port is available. When static is the policy specified, `hostPort` is required to be populated
type: string
enum:
- dynamic
- static
protocol:
title: Protocol being used. Defaults to UDP. TCP is the only other option
type: string
enum:
- UDP
- TCP
containerPort:
title: The port that is being opened on the game server process
type: integer
minimum: 0
maximum: 65535
hostPort:
title: The port exposed on the host
description: Only required when `portPolicy` is "static". Overwritten when portPolicy is "dynamic".
type: integer
minimum: 0
maximum: 65535
health:
type: object
title: Health checking for the running game server
properties:
disabled:
title: Disable health checking. defaults to false, but can be set to true
type: boolean
initialDelaySeconds:
title: Number of seconds after the container has started before health check is initiated. Defaults to 5 seconds
type: integer
minimum: 0
maximum: 2147483648
periodSeconds:
title: How long before the server is considered not healthy
type: integer
minimum: 0
maximum: 2147483648
failureThreshold:
title: Minimum consecutive failures for the health probe to be considered failed after having succeeded.
type: integer
minimum: 1
maximum: 2147483648
Loading

0 comments on commit eed5609

Please sign in to comment.