-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploying agones using two options: 1. From repository release charts by specifying version. 2. Local version using Chart.yaml file with values.yaml.
- Loading branch information
Showing
6 changed files
with
352 additions
and
12 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
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,193 @@ | ||
# 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/" | ||
} | ||
|
||
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 = "../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)}" | ||
} | ||
} | ||
|
||
# In Terraform version 0.12 Interpolation would only evaluate one branch of a condition | ||
# https://github.com/hashicorp/terraform/issues/15605 | ||
# so we can remove this and change values in helm_release to: | ||
# | ||
# values = [ | ||
# "${length(var.values_file) == 0 ? "" : file("${var.values_file}"))}" | ||
# ] | ||
data "null_data_source" "values_file" { | ||
count = "${length(var.values_file) == 0 ? 0 : 1}" | ||
inputs = { | ||
"values" = "${file("${var.values_file}")}" | ||
} | ||
} | ||
|
||
data "google_client_config" "current" {} | ||
|
||
data "helm_repository" "agones" { | ||
depends_on = ["kubernetes_cluster_role_binding.tiller"] | ||
name = "agones" | ||
url = "https://agones.dev/chart/stable" | ||
} | ||
|
||
|
||
# TODO: remove - not needed in Terraform 0.12 | ||
locals { | ||
values = { | ||
params = "${join("", data.null_data_source.values_file.*.outputs.values)}" | ||
} | ||
} | ||
|
||
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 = [ | ||
# Switch to in terraform 0.12 | ||
# "${length(var.values_file) == 0 ? "" : file("${var.values_file}"))}" | ||
"${length(var.values_file) == 0 ? "" : local.values["params"]}" | ||
] | ||
|
||
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 project="<YOUR_GCP_ProjectID>" -var agones_version="0.9.0" | ||
variable "password" { | ||
default= "" | ||
} | ||
variable "agones_version" { | ||
default="0.9.0" | ||
} | ||
variable "project" {default = "agones"} | ||
module "agones" { | ||
source = "git::https://github.com/GoogleCloudPlatform/agones.git//build/?ref=master" | ||
|
||
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" | ||
} |
Oops, something went wrong.