-
Notifications
You must be signed in to change notification settings - Fork 820
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploying agones from default chart.
- Loading branch information
Showing
5 changed files
with
308 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
# Copyright 2019 Google LLC All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
resource "kubernetes_service_account" "tiller" { | ||
metadata { | ||
name = "tiller" | ||
namespace = "kube-system" | ||
} | ||
depends_on = ["google_container_cluster.primary"] | ||
|
||
automount_service_account_token = true | ||
} | ||
|
||
resource "kubernetes_cluster_role_binding" "tiller" { | ||
depends_on = ["kubernetes_service_account.tiller"] | ||
metadata { | ||
name = "tiller" | ||
} | ||
|
||
role_ref { | ||
kind = "ClusterRole" | ||
name = "cluster-admin" | ||
api_group = "rbac.authorization.k8s.io" | ||
} | ||
|
||
subject { | ||
kind = "ServiceAccount" | ||
name = "tiller" | ||
|
||
api_group = "" | ||
namespace = "kube-system" | ||
} | ||
} | ||
variable "chart" { | ||
default = "../install/helm/agones/chart" | ||
} | ||
|
||
variable "agones_version" { | ||
default = "0.9.0" | ||
} | ||
|
||
variable "crd_cleanup" { | ||
default = "true" | ||
} | ||
variable "image_registry" { | ||
default = "gcr.io/agones-images" | ||
} | ||
variable "pull_policy" { | ||
default = "Always" | ||
} | ||
variable "always_pull_sidecar" { | ||
default = "true" | ||
} | ||
variable "image_pull_secret" { | ||
default = "" | ||
} | ||
variable "ping_service_type" { | ||
default = "LoadBalancer" | ||
} | ||
|
||
variable "values_file" { | ||
default = "$${file("../install/helm/agones/values.yaml")}" | ||
} | ||
data "google_client_config" "default" {} | ||
|
||
provider "kubernetes" { | ||
version = "~> 1.5" | ||
load_config_file = false | ||
host = "https://${google_container_cluster.primary.endpoint}" | ||
token = "${data.google_client_config.default.access_token}" | ||
cluster_ca_certificate = "${base64decode(google_container_cluster.primary.master_auth.0.cluster_ca_certificate)}" | ||
} | ||
|
||
provider "helm" { | ||
version = "~> 0.7" | ||
|
||
debug = true | ||
install_tiller = true | ||
service_account = "${kubernetes_service_account.tiller.metadata.0.name}" | ||
tiller_image = "gcr.io/kubernetes-helm/tiller:v2.12.3" | ||
|
||
kubernetes { | ||
load_config_file = false | ||
host = "https://${google_container_cluster.primary.endpoint}" | ||
token = "${data.google_client_config.default.access_token}" | ||
cluster_ca_certificate = "${base64decode(google_container_cluster.primary.master_auth.0.cluster_ca_certificate)}" | ||
} | ||
} | ||
|
||
data "google_client_config" "current" {} | ||
|
||
data "helm_repository" "agones" { | ||
depends_on = ["kubernetes_cluster_role_binding.tiller"] | ||
name = "agones" | ||
url = "https://agones.dev/chart/stable" | ||
} | ||
|
||
resource "helm_release" "agones" { | ||
depends_on = ["null_resource.helm_init", "kubernetes_cluster_role_binding.tiller"] | ||
name = "agones" | ||
force_update = "true" | ||
repository = "${data.helm_repository.agones.metadata.0.name}" | ||
chart = "${var.chart}" | ||
timeout = 180 | ||
values = [ | ||
"${var.values_file}" | ||
] | ||
|
||
set { | ||
name = "crds.CleanupOnDelete" | ||
value = "${var.crd_cleanup}" | ||
} | ||
set { | ||
name = "agones.image.tag" | ||
value = "${var.agones_version}" | ||
} | ||
set { | ||
name = "agones.image.registry" | ||
value = "${var.image_registry}" | ||
} | ||
set { | ||
name = "agones.image.controller.pullPolicy" | ||
value = "${var.pull_policy}" | ||
} | ||
set { | ||
name = "agones.image.sdk.alwaysPull" | ||
value = "${var.always_pull_sidecar}" | ||
} | ||
set { | ||
name = "agones.image.controller.pullSecret" | ||
value = "${var.image_pull_secret}" | ||
} | ||
set { | ||
name = " agones.ping.http.serviceType" | ||
value = "${var.ping_service_type}" | ||
} | ||
set { | ||
name = "agones.ping.udp.serviceType" | ||
value = "${var.ping_service_type}" | ||
} | ||
version = "${var.agones_version}" | ||
namespace = "agones-system" | ||
} | ||
|
||
provider "null" { | ||
version = "~> 2.1" | ||
} | ||
|
||
# Creates folder with repositories so that helm provider would not fail | ||
resource "null_resource" "helm_init" { | ||
triggers = { | ||
always_run = "${timestamp()}" | ||
} | ||
provisioner "local-exec" { | ||
command = "helm init --client-only" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2019 Google LLC All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
|
||
// Run: | ||
// terraform apply -var agones_version="0.9.0" | ||
variable "password" { | ||
default= "" | ||
} | ||
variable "agones-version" { | ||
default="0.9.0" | ||
} | ||
module "agones" { | ||
#source = "git::https://github.com/GoogleCloudPlatform/agones.git//build/?ref=master" | ||
source = "git::https://github.com/alekser/agones.git//build/?ref=feature/helm-terraform" | ||
|
||
password = "${var.password}" | ||
cluster = { | ||
"zone" = "us-west1-c" | ||
"name" = "test-cluster" | ||
"machineType" = "n1-standard-4" | ||
"initialNodeCount" = "4" | ||
"legacyAbac" = false | ||
"project" = "${var.project}" | ||
} | ||
agones_version = "${var.agones_version}" | ||
values_file="" | ||
chart="agones" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
title: "Install Agones using Terraform" | ||
linkTitle: "Install with Terraform" | ||
weight: 4 | ||
description: > | ||
This chart install the Agones application and defines deployment on a [Kubernetes](http://kubernetes.io) cluster using the Terraform. | ||
--- | ||
|
||
## Prerequisites | ||
|
||
- Terraform v0.11.13 | ||
- [Helm](https://docs.helm.sh/helm/) package manager 2.10.0+ | ||
- Access to Google Cloud Kubernetes Engine | ||
- `gcloud` utility installed | ||
- Git | ||
|
||
## Installing the Agones as Terraform submodule | ||
|
||
You can use Terraform to provision your GKE cluster and install agones on it using Helm Terraform provider. | ||
|
||
The example of submodule configuration could be found here: | ||
{{< ghlink href="examples/terraform-submodule/module.tf" >}}Terraform configuration with Agones submodule{{< /ghlink >}} | ||
|
||
First you should run: | ||
``` | ||
terraform init | ||
``` | ||
|
||
It would use git to clone the current master of Agones, and use `./build` folder as starting point of Agones submodule, which contains all necessary Terraform configuration files. | ||
|
||
Next step you should make sure that you authenticate using gcloud: | ||
``` | ||
gcloud auth application-default login | ||
``` | ||
|
||
Now you are able to deploy properly configured GKE cluster and specify release version of Agones you want to use: | ||
``` | ||
terraform apply -var password="1234567890123456" -var project="<YOUR_GCP_ProjectID>" -var agones_version="0.9.0" | ||
``` | ||
|
||
Run next command to setup your kubectl: | ||
``` | ||
gcloud container clusters get-credentials --zone us-west1-c test-cluster | ||
``` | ||
|
||
You would see: | ||
``` | ||
Fetching cluster endpoint and auth data. | ||
kubeconfig entry generated for test-cluster. | ||
``` | ||
|
||
Check that your has access to kubernetes cluster: | ||
``` | ||
kubectl get nodes | ||
``` | ||
|
||
Make sure you have 6 nodes in `Ready` state. | ||
|
||
## Uninstall the Agones and delete GKE cluster | ||
|
||
Run next command to delete all Terraform provisioned resources: | ||
``` | ||
terraform destroy -var password="1234567890123456" -var project="<YOUR_GCP_ProjectID>" -var agones_version="0.9.0" | ||
``` |