Skip to content

Commit

Permalink
Terraform: Add FeatureGates into helm release (#1431)
Browse files Browse the repository at this point in the history
Add new variable feature_gates to change the Agones installation
parameter.

Co-authored-by: Mark Mandel <markmandel@google.com>
  • Loading branch information
aLekSer and markmandel authored Apr 2, 2020
1 parent 44bd71f commit 5ef8c77
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 15 deletions.
5 changes: 5 additions & 0 deletions build/includes/terraform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ terraform-clean:

# Creates a cluster and install release version of Agones controller
# Version could be specified by AGONES_VERSION
# All Feature gates are disabled
gcloud-terraform-cluster: GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT ?= 4
gcloud-terraform-cluster: GCP_CLUSTER_NODEPOOL_MACHINETYPE ?= n1-standard-4
gcloud-terraform-cluster: AGONES_VERSION ?= ''
gcloud-terraform-cluster: GCP_TF_CLUSTER_NAME ?= agones-tf-cluster
gcloud-terraform-cluster: LOG_LEVEL ?= debug
gcloud-terraform-cluster: $(ensure-build-image)
gcloud-terraform-cluster: FEATURE_GATES := ""
gcloud-terraform-cluster:
ifndef GCP_PROJECT
$(eval GCP_PROJECT=$(shell sh -c "gcloud config get-value project 2> /dev/null"))
Expand All @@ -41,6 +43,7 @@ endif
terraform apply -auto-approve -var agones_version="$(AGONES_VERSION)" \
-var name=$(GCP_TF_CLUSTER_NAME) -var machine_type="$(GCP_CLUSTER_NODEPOOL_MACHINETYPE)" \
-var values_file="" \
-var feature_gates=$(FEATURE_GATES) \
-var zone="$(GCP_CLUSTER_ZONE)" -var project="$(GCP_PROJECT)" \
-var log_level="$(LOG_LEVEL)" \
-var node_count=$(GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT)'
Expand All @@ -57,6 +60,7 @@ gcloud-terraform-install: PING_SERVICE_TYPE := "LoadBalancer"
gcloud-terraform-install: CRD_CLEANUP := true
gcloud-terraform-install: GCP_TF_CLUSTER_NAME ?= agones-tf-cluster
gcloud-terraform-install: LOG_LEVEL ?= debug
gcloud-terraform-install: FEATURE_GATES := "PlayerTracking=true&ContainerPortAllocation=true"
gcloud-terraform-install:
ifndef GCP_PROJECT
$(eval GCP_PROJECT=$(shell sh -c "gcloud config get-value project 2> /dev/null"))
Expand All @@ -72,6 +76,7 @@ endif
-var name=$(GCP_TF_CLUSTER_NAME) -var machine_type="$(GCP_CLUSTER_NODEPOOL_MACHINETYPE)" \
-var zone=$(GCP_CLUSTER_ZONE) -var project=$(GCP_PROJECT) \
-var log_level=$(LOG_LEVEL) \
-var feature_gates=$(FEATURE_GATES) \
-var node_count=$(GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT)'
GCP_CLUSTER_NAME=$(GCP_TF_CLUSTER_NAME) $(MAKE) gcloud-auth-cluster

Expand Down
26 changes: 16 additions & 10 deletions build/terraform/gke/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ variable "values_file" {
default = "../../../install/helm/agones/values.yaml"
}

// Note: This is the number of gameserver nodes. The Agones module will automatically create an additional
// two node pools with 1 node each for "agones-system" and "agones-metrics".
variable "node_count" {
default = "4"
}
variable "chart" {
default = "agones"
}
Expand All @@ -67,11 +62,6 @@ variable "zone" {
description = "The GCP zone to create the cluster in"
}

variable "network" {
default = "default"
description = "The name of the VPC network to attach the cluster and firewall rule to"
}

variable "pull_policy" {
default = "Always"
}
Expand All @@ -92,6 +82,21 @@ variable "log_level" {
default = "info"
}

// Note: This is the number of gameserver nodes. The Agones module will automatically create an additional
// two node pools with 1 node each for "agones-system" and "agones-metrics".
variable "node_count" {
default = "4"
}

variable "network" {
default = "default"
description = "The name of the VPC network to attach the cluster and firewall rule to"
}

variable "feature_gates" {
default = ""
}


module "gke_cluster" {
source = "../../../install/terraform/modules/gke"
Expand All @@ -112,6 +117,7 @@ module "helm_agones" {
agones_version = var.agones_version
values_file = var.values_file
chart = var.chart
feature_gates = var.feature_gates
host = module.gke_cluster.host
token = module.gke_cluster.token
cluster_ca_certificate = module.gke_cluster.cluster_ca_certificate
Expand Down
6 changes: 5 additions & 1 deletion examples/terraform-submodules/aks/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ variable "disk_size" {
variable "client_id" {
default = ""
}

variable "client_secret" {
default = ""
}
Expand All @@ -47,6 +46,10 @@ variable "log_level" {
default = "info"
}

variable "feature_gates" {
default = ""
}

module "aks_cluster" {
source = "git::https://github.com/googleforgames/agones.git//install/terraform/modules/aks/?ref=master"

Expand All @@ -64,6 +67,7 @@ module "helm_agones" {
agones_version = var.agones_version
values_file = ""
chart = "agones"
feature_gates = var.feature_gates
host = module.aks_cluster.host
token = module.aks_cluster.token
cluster_ca_certificate = module.aks_cluster.cluster_ca_certificate
Expand Down
5 changes: 5 additions & 0 deletions examples/terraform-submodules/eks/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ variable "log_level" {
default = "info"
}

variable "feature_gates" {
default = ""
}

module "eks_cluster" {
source = "git::https://github.com/googleforgames/agones.git//install/terraform/modules/eks/?ref=master"

Expand All @@ -66,6 +70,7 @@ module "helm_agones" {
agones_version = var.agones_version
values_file = ""
chart = "agones"
feature_gates = var.feature_gates
host = module.eks_cluster.host
token = data.aws_eks_cluster_auth.example.token
cluster_ca_certificate = module.eks_cluster.cluster_ca_certificate
Expand Down
5 changes: 5 additions & 0 deletions examples/terraform-submodules/gke/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ variable "log_level" {
default = "info"
}

variable "feature_gates" {
default = ""
}

module "gke_cluster" {
// ***************************************************************************************************
// Update ?ref= to the agones release you are installing. For example, ?ref=release-1.3.0 corresponds
Expand Down Expand Up @@ -88,6 +92,7 @@ module "helm_agones" {
agones_version = var.agones_version
values_file = ""
chart = "agones"
feature_gates = var.feature_gates
host = module.gke_cluster.host
token = module.gke_cluster.token
cluster_ca_certificate = module.gke_cluster.cluster_ca_certificate
Expand Down
5 changes: 5 additions & 0 deletions install/terraform/modules/helm/helm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ resource "helm_release" "agones" {
name = "agones.controller.logLevel"
value = var.log_level
}

set {
name = "agones.featureGates"
value = var.feature_gates
}

version = var.agones_version
namespace = "agones-system"
Expand Down
4 changes: 4 additions & 0 deletions install/terraform/modules/helm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ variable "log_level" {
default = "info"
}

variable "feature_gates" {
default = ""
}

variable "host" {}

variable "token" {}
Expand Down
8 changes: 8 additions & 0 deletions site/content/en/docs/Installation/Terraform/aks.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ kubectl get nodes
```

Configurable parameters:

- log_level - possible values: Fatal, Error, Warn, Info, Debug (default is "info")
- cluster_name - the name of the AKS cluster (default is "agones-terraform-example")
- agones_version - the version of agones to install (an empty string, which is the default, is the latest version from the [Helm repository](https://agones.dev/chart/stable))
- machine_type - node machine type for hosting game servers (default is "Standard_D2_v2")
- disk_size - disk size of the node
- region - the location of the cluster
- node_count - count of game server nodes for the default node pool (default is "4")
- feature_gates - a list of alpha and beta version features to enable. For example, "PlayerTracking=true&ContainerPortAllocation=true"

## Uninstall the Agones and delete AKS cluster

Expand Down
6 changes: 4 additions & 2 deletions site/content/en/docs/Installation/Terraform/eks.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ By editing `modules.tf` you can change the parameters that you need to. For inst

Configurable parameters:

- cluster_name - the name of the GKE cluster (default is "agones-terraform-example")
- agones_version - the version of agones to install (default is the latest version from the [Helm repository](https://agones.dev/chart/stable))
- cluster_name - the name of the EKS cluster (default is "agones-terraform-example")
- agones_version - the version of agones to install (an empty string, which is the default, is the latest version from the [Helm repository](https://agones.dev/chart/stable))
- machine_type - EC2 instance type for hosting game servers (default is "t2.large")
- region - the location of the cluster (default is "us-west2")
- node_count - count of game server nodes for the default node pool (default is "4")
- log_level - possible values: Fatal, Error, Warn, Info, Debug (default is "info")
- feature_gates - a list of alpha and beta version features to enable. For example, "PlayerTracking=true&ContainerPortAllocation=true"

Now you can create an EKS cluster and deploy Agones on EKS:
```
Expand Down
5 changes: 3 additions & 2 deletions site/content/en/docs/Installation/Terraform/gke.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ Configurable parameters:

- project - your Google Cloud Project ID (required)
- name - the name of the GKE cluster (default is "agones-terraform-example")
- agones_version - the version of agones to install (default is the latest version from the [Helm repository](https://agones.dev/chart/stable))
- agones_version - the version of agones to install (an empty string, which is the default, is the latest version from the [Helm repository](https://agones.dev/chart/stable))
- machine_type - machine type for hosting game servers (default is "n1-standard-4")
- node_count - count of game server nodes for the default node pool (default is "4")
- zone - the name of the [zone](https://cloud.google.com/compute/docs/regions-zones) you want your cluster to be
created in. (default is "us-west1-c")
created in (default is "us-west1-c")
- network - the name of the VPC network you want your cluster and firewall rules be connected to (default is "default")
- log_level - possible values: Fatal, Error, Warn, Info, Debug (default is "info")
- feature_gates - a list of alpha and beta version features to enable. For example, "PlayerTracking=true&ContainerPortAllocation=true"

{{% alert title="Warning" color="warning"%}}
On the lines that read `source = "git::https://github.com/googleforgames/agones.git//install/terraform/modules/gke/?ref=master"`
Expand Down

0 comments on commit 5ef8c77

Please sign in to comment.