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 834d74a commit 1fc20c3
Show file tree
Hide file tree
Showing 26 changed files with 738 additions and 45 deletions.
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,16 @@ Participation in this project comes under the [Contributor Covenant Code of Cond
- Once review has occurred, please rebase your PR down to a single commit. This will ensure a nice clean Git history.
- Finally - *Thanks* for considering submitting code to Agones!

## Continuous Integration

Continuous integration is provided by [Google Cloud Container Builder](https://cloud.google.com/container-builder/),
through the [cloudbuilder.yaml](./cloudbuild.yaml) file found at the root of the directory.

Build success/failure with relevant details are pushed automatically to pull requests via the not (yet 😉) opensourced
build system.

See the [Container Builder documentation](https://cloud.google.com/container-builder/docs/) for more details on
how to edit and expand the build process.

### Additional Resources
- [How to write a good Git Commit message](https://chris.beams.io/posts/git-commit/)
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Agones
[![GoDoc](https://godoc.org/agones.dev/agones?status.svg)](https://godoc.org/agones.dev/agones)
[![Go Report Card](https://goreportcard.com/badge/github.com/GoogleCloudPlatform/agones)](https://goreportcard.com/report/github.com/GoogleCloudPlatform/agones)

Agones is a library for hosting, running and scaling [dedicated game servers](https://en.wikipedia.org/wiki/Game_server#Dedicated_server) on [Kubernetes](https://kubernetes.io).

Expand All @@ -14,6 +15,10 @@ This software is currently alpha, and subject to change. Not to be used in produ
- Manage GameServer lifecycles - including health checking and connection information.
- Client SDKs for integration with dedicated game servers to work with Agones.

## Why does this project exist?
For more details on why this project was written, read the
[announcement blog post](https://cloudplatform.googleblog.com/2018/03/introducing-Agones-open-source-multiplayer-dedicated-game-server-hosting-built-on-Kubernetes.html).

## Requirements
- Kubernetes cluster version 1.9+
- [Minikube](https://github.com/kubernetes/minikube) and [Google Kubernetes Engine](https://cloud.google.com/kubernetes-engine/) have been tested
Expand Down Expand Up @@ -69,6 +74,9 @@ See the tools in the [build](build/README.md) directory for testing and building

Agones is in active development - we would love your help in shaping its future!

## This all sounds great, but can you explain Kubernetes to me?
[You should totally read this comic, and interactive tutorial](https://cloud.google.com/kubernetes-engine/kubernetes-comic/)

## Licence

Apache 2.0
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
1 change: 0 additions & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# Google Cloud Builder CI configuration
#

# right now, do nothing.
steps:
- name: "ubuntu"
args: ["bash", "-c", "echo 'FROM gcr.io/cloud-builders/docker\nRUN apt-get install make\nENTRYPOINT [\"/usr/bin/make\"]' > Dockerfile.build"]
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
16 changes: 11 additions & 5 deletions examples/simple-udp/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,22 @@ func main() {
if err != nil {
log.Fatalf("Could not connect: %v", err)
}
defer conn.Close()

defer func() {
err = conn.Close()
if err != nil {
log.Fatalf("Could not close connection: %v", err)
}
}()

go func() {
b := make([]byte, bufferSize)
for {
n, err := conn.Read(b)
if err != nil {
log.Fatalf("Could not read packet: %v", err)
n, errRead := conn.Read(b)
if errRead != nil {
log.Fatalf("Could not read packet: %v", errRead)
}
log.Printf("Recieved Packet: %s", b[:n])
log.Printf("Received Packet: %s", b[:n])
}
}()

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 }}
Loading

0 comments on commit 1fc20c3

Please sign in to comment.