diff --git a/build/README.md b/build/README.md index 279bee8cf7..3bb64bc34f 100644 --- a/build/README.md +++ b/build/README.md @@ -51,13 +51,13 @@ Table of Contents * [make grafana-portforward](#make-grafana-portforward) * [make controller-portforward](#make-controller-portforward) * [make pprof-cpu-web](#make-pprof-cpu-web) - * [make pprof-heap-web](#make-pprof-heap-web) + * [make pprof-heap-web](#make-pprof-heap-web) * [make shell](#make-shell) * [make godoc](#make-godoc) * [make build-controller-image](#make-build-controller-image) * [make build-agones-sdk-image](#make-build-agones-sdk-image) * [make gen-install](#make-gen-install) - * [make gen-embedded-openapi](#make-gen-embedded-openapi) + * [make gen-embedded-openapi](#make-gen-embedded-openapi) * [make gen-crd-client](#make-gen-crd-client) * [make gen-sdk-grpc](#make-gen-sdk-grpc) * [Build Image Targets](#build-image-targets) @@ -201,12 +201,14 @@ configuration found in the `build/terraform/gke` directory. You can customize GKE cluster via environment variables or by using a [`local-includes`](./local-includes) file. See the table below for available customizations : -| Parameter | Description | Default | -|---------------------------------------|-------------------------------------------------------------------------------|---------------| -| `GCP_CLUSTER_NAME` | The name of the cluster | `test-cluster` | -| `GCP_CLUSTER_ZONE` | The name of the Google Compute Engine zone in which the cluster will resides. | `us-west1-c` | -| `GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT`| The number of nodes to create in this cluster. | `4` | -| `GCP_CLUSTER_NODEPOOL_MACHINETYPE` | The name of a Google Compute Engine machine type. | `n1-standard-4` | +| Parameter | Description | Default | +|------------------------------------------------|-------------------------------------------------------------------------------|-----------------| +| `GCP_CLUSTER_NAME` | The name of the cluster | `test-cluster` | +| `GCP_CLUSTER_ZONE` | The name of the Google Compute Engine zone in which the cluster will resides. | `us-west1-c` | +| `GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT` | The number of nodes to create in this cluster. | `4` | +| `GCP_CLUSTER_NODEPOOL_MACHINETYPE` | The name of a Google Compute Engine machine type. | `n1-standard-4` | +| `GCP_CLUSTER_NODEPOOL_WINDOWSINITIALNODECOUNT` | The number of Windows nodes to create in this cluster. | `0` | +| `GCP_CLUSTER_NODEPOOL_WINDOWSMACHINETYPE` | The name of a Google Compute Engine machine type for Windows nodes. | `n1-standard-4` | If you would like to change more settings, feel free to edit the [`cluster.yml.jinja`](./gke-test-cluster/cluster.yml.jinja) file before running this command. @@ -282,7 +284,7 @@ It's worth noting that Minikube does let you [reuse its Docker daemon](https://g and build directly on Minikube, but in this case this approach is far simpler, and makes cross-platform support for the build system much easier. -To push your own images into the cluster, take a look at Minikube's +To push your own images into the cluster, take a look at Minikube's [Pushing Images](https://minikube.sigs.k8s.io/docs/handbook/pushing/) guide. Running end-to-end tests on Minikube is done via the `make minikube-test-e2e` target. This target use the same `make test-e2e` but also setup some prerequisites for use with a Minikube cluster. @@ -670,7 +672,7 @@ Use this instead of `make install`, as it disables PullAlways on the install.yam #### `make minikube-push` -Push the local Agones Docker images that have already been built +Push the local Agones Docker images that have already been built via `make build` or `make build-images` into the "agones" minikube instance with `minikube cache add` #### `make minikube-setup-prometheus` diff --git a/build/includes/google-cloud.mk b/build/includes/google-cloud.mk index 94799a2e39..4cd83081dd 100644 --- a/build/includes/google-cloud.mk +++ b/build/includes/google-cloud.mk @@ -26,9 +26,14 @@ gcloud-init: ensure-build-config # Creates and authenticates a small, 6 node GKE cluster to work against (2 nodes are used for agones-metrics and agones-system) gcloud-test-cluster: GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT ?= 4 gcloud-test-cluster: GCP_CLUSTER_NODEPOOL_MACHINETYPE ?= n1-standard-4 +gcloud-test-cluster: GCP_CLUSTER_NODEPOOL_WINDOWSINITIALNODECOUNT ?= 0 +gcloud-test-cluster: GCP_CLUSTER_NODEPOOL_WINDOWSMACHINETYPE ?= n1-standard-4 gcloud-test-cluster: $(ensure-build-image) $(MAKE) gcloud-terraform-cluster GCP_TF_CLUSTER_NAME="$(GCP_CLUSTER_NAME)" GCP_CLUSTER_ZONE="$(GCP_CLUSTER_ZONE)" \ - GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT="$(GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT)" GCP_CLUSTER_NODEPOOL_MACHINETYPE="$(GCP_CLUSTER_NODEPOOL_MACHINETYPE)" + GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT="$(GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT)" \ + GCP_CLUSTER_NODEPOOL_MACHINETYPE="$(GCP_CLUSTER_NODEPOOL_MACHINETYPE)" \ + GCP_CLUSTER_NODEPOOL_WINDOWSINITIALNODECOUNT="$(GCP_CLUSTER_NODEPOOL_WINDOWSINITIALNODECOUNT)" \ + GCP_CLUSTER_NODEPOOL_WINDOWSMACHINETYPE="$(GCP_CLUSTER_NODEPOOL_WINDOWSMACHINETYPE)" $(MAKE) gcloud-auth-cluster clean-gcloud-test-cluster: $(ensure-build-image) diff --git a/build/includes/terraform.mk b/build/includes/terraform.mk index c8616455f0..d88aef8db1 100644 --- a/build/includes/terraform.mk +++ b/build/includes/terraform.mk @@ -37,6 +37,8 @@ terraform-clean: # Alpha 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: GCP_CLUSTER_NODEPOOL_WINDOWSINITIALNODECOUNT ?= 0 +gcloud-terraform-cluster: GCP_CLUSTER_NODEPOOL_WINDOWSMACHINETYPE ?= n1-standard-4 gcloud-terraform-cluster: AGONES_VERSION ?= '' gcloud-terraform-cluster: GCP_TF_CLUSTER_NAME ?= agones-tf-cluster gcloud-terraform-cluster: LOG_LEVEL ?= debug @@ -52,7 +54,9 @@ gcloud-terraform-cluster: -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)' + -var node_count=$(GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT) \ + -var windows_node_count=$(GCP_CLUSTER_NODEPOOL_WINDOWSINITIALNODECOUNT) \ + -var windows_machine_type=$(GCP_CLUSTER_NODEPOOL_WINDOWSMACHINETYPE)' GCP_CLUSTER_NAME=$(GCP_TF_CLUSTER_NAME) $(MAKE) gcloud-auth-cluster # Creates a cluster and install current version of Agones controller @@ -60,6 +64,8 @@ gcloud-terraform-cluster: # Unifies previous `make gcloud-test-cluster` and `make install` targets gcloud-terraform-install: GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT ?= 4 gcloud-terraform-install: GCP_CLUSTER_NODEPOOL_MACHINETYPE ?= n1-standard-4 +gcloud-terraform-install: GCP_CLUSTER_NODEPOOL_WINDOWSINITIALNODECOUNT ?= 0 +gcloud-terraform-install: GCP_CLUSTER_NODEPOOL_WINDOWSMACHINETYPE ?= n1-standard-4 gcloud-terraform-install: ALWAYS_PULL_SIDECAR := true gcloud-terraform-install: IMAGE_PULL_POLICY := "Always" gcloud-terraform-install: PING_SERVICE_TYPE := "LoadBalancer" @@ -82,7 +88,9 @@ gcloud-terraform-install: -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)' + -var node_count=$(GCP_CLUSTER_NODEPOOL_INITIALNODECOUNT) \ + -var windows_node_count=$(GCP_CLUSTER_NODEPOOL_WINDOWSINITIALNODECOUNT) \ + -var windows_machine_type=$(GCP_CLUSTER_NODEPOOL_WINDOWSMACHINETYPE)' GCP_CLUSTER_NAME=$(GCP_TF_CLUSTER_NAME) $(MAKE) gcloud-auth-cluster gcloud-terraform-destroy-cluster: GCP_PROJECT ?= $(current_project) diff --git a/build/terraform/e2e/module.tf b/build/terraform/e2e/module.tf index aa072ebd3b..1472b4fa9c 100644 --- a/build/terraform/e2e/module.tf +++ b/build/terraform/e2e/module.tf @@ -28,11 +28,11 @@ module "gke_cluster" { source = "../../../install/terraform/modules/gke" cluster = { - "name" = "e2e-test-cluster" - "zone" = "us-west1-c" - "machineType" = "n1-standard-4" - "initialNodeCount" = 8 - "project" = var.project + "name" = "e2e-test-cluster" + "zone" = "us-west1-c" + "machineType" = "n1-standard-4" + "initialNodeCount" = 8 + "project" = var.project } firewallName = "gke-game-server-firewall" @@ -50,15 +50,15 @@ provider "helm" { resource "helm_release" "consul" { chart = "stable/consul" - name = "consul" + name = "consul" set { - name = "Replicas" + name = "Replicas" value = "1" } set { - name = "uiService.type" + name = "uiService.type" value = "ClusterIP" } } diff --git a/build/terraform/gke/module.tf b/build/terraform/gke/module.tf index f2c50d3415..a9649ece8e 100644 --- a/build/terraform/gke/module.tf +++ b/build/terraform/gke/module.tf @@ -37,6 +37,10 @@ variable "machine_type" { default = "n1-standard-4" } +variable "windows_machine_type" { + default = "n1-standard-4" +} + variable "name" { default = "agones-tf-cluster" } @@ -87,6 +91,10 @@ variable "log_level" { variable "node_count" { default = "4" } +// Note: This is the number of gameserver Windows nodes. +variable "windows_node_count" { + default = "0" +} variable "network" { default = "default" @@ -101,12 +109,14 @@ module "gke_cluster" { source = "../../../install/terraform/modules/gke" cluster = { - "name" = var.name - "zone" = var.zone - "machineType" = var.machine_type - "initialNodeCount" = var.node_count - "project" = var.project - "network" = var.network + "name" = var.name + "zone" = var.zone + "machineType" = var.machine_type + "initialNodeCount" = var.node_count + "windowsMachineType" = var.windows_machine_type + "windowsInitialNodeCount" = var.windows_node_count + "project" = var.project + "network" = var.network } } diff --git a/build/terraform/prow/module.tf b/build/terraform/prow/module.tf index fcb2ec01b4..8d512be778 100644 --- a/build/terraform/prow/module.tf +++ b/build/terraform/prow/module.tf @@ -21,10 +21,10 @@ variable "project" { } resource "google_container_cluster" "prow-build-cluster" { - name = "prow-build-cluster" - project = var.project - location = "us-west1-c" - description = "Prow cluster to run tests for Agones" + name = "prow-build-cluster" + project = var.project + location = "us-west1-c" + description = "Prow cluster to run tests for Agones" min_master_version = "1.18" initial_node_count = 8 node_config { diff --git a/examples/terraform-submodules/gke/module.tf b/examples/terraform-submodules/gke/module.tf index ce6b3073c2..e69efcb430 100644 --- a/examples/terraform-submodules/gke/module.tf +++ b/examples/terraform-submodules/gke/module.tf @@ -69,6 +69,14 @@ variable "feature_gates" { default = "" } +variable "windows_node_count" { + default = "0" +} + +variable "windows_machine_type" { + default = "n1-standard-4" +} + module "gke_cluster" { // *************************************************************************************************** // Update ?ref= to the agones release you are installing. For example, ?ref=release-1.8.0 corresponds @@ -77,13 +85,15 @@ module "gke_cluster" { source = "git::https://github.com/googleforgames/agones.git//install/terraform/modules/gke/?ref=main" cluster = { - "name" = var.name - "zone" = var.zone - "machineType" = var.machine_type - "initialNodeCount" = var.node_count - "project" = var.project - "network" = var.network - "subnetwork" = var.subnetwork + "name" = var.name + "zone" = var.zone + "machineType" = var.machine_type + "initialNodeCount" = var.node_count + "project" = var.project + "network" = var.network + "subnetwork" = var.subnetwork + "windowsInitialNodeCount" = var.windows_node_count + "windowsMachineType" = var.windows_machine_type } } diff --git a/install/terraform/modules/aks/aks.tf b/install/terraform/modules/aks/aks.tf index bc69ebb403..d2d4b85952 100644 --- a/install/terraform/modules/aks/aks.tf +++ b/install/terraform/modules/aks/aks.tf @@ -89,8 +89,8 @@ resource "azurerm_kubernetes_cluster_node_pool" "system" { os_disk_size_gb = var.disk_size enable_auto_scaling = false node_taints = ["agones.dev/agones-system=true:NoExecute"] - node_labels = { - "agones.dev/agones-system":"true" + node_labels = { + "agones.dev/agones-system" : "true" } } @@ -102,8 +102,8 @@ resource "azurerm_kubernetes_cluster_node_pool" "metrics" { os_disk_size_gb = var.disk_size enable_auto_scaling = false node_taints = ["agones.dev/agones-metrics=true:NoExecute"] - node_labels = { - "agones.dev/agones-metrics":"true" + node_labels = { + "agones.dev/agones-metrics" : "true" } } diff --git a/install/terraform/modules/gke/cluster.tf b/install/terraform/modules/gke/cluster.tf index b1fa0bcb52..5bc6dea879 100644 --- a/install/terraform/modules/gke/cluster.tf +++ b/install/terraform/modules/gke/cluster.tf @@ -22,14 +22,16 @@ data "google_client_config" "default" {} # A list of all parameters used in interpolation var.cluster # Set values to default if not key was not set in original map locals { - project = lookup(var.cluster, "project", "agones") - zone = lookup(var.cluster, "zone", "us-west1-c") - name = lookup(var.cluster, "name", "test-cluster") - machineType = lookup(var.cluster, "machineType", "n1-standard-4") - initialNodeCount = lookup(var.cluster, "initialNodeCount", "4") - network = lookup(var.cluster, "network", "default") - subnetwork = lookup(var.cluster, "subnetwork", "") - kubernetesVersion = lookup(var.cluster, "kubernetesVersion", "1.18") + project = lookup(var.cluster, "project", "agones") + zone = lookup(var.cluster, "zone", "us-west1-c") + name = lookup(var.cluster, "name", "test-cluster") + machineType = lookup(var.cluster, "machineType", "n1-standard-4") + initialNodeCount = lookup(var.cluster, "initialNodeCount", "4") + network = lookup(var.cluster, "network", "default") + subnetwork = lookup(var.cluster, "subnetwork", "") + kubernetesVersion = lookup(var.cluster, "kubernetesVersion", "1.18") + windowsInitialNodeCount = lookup(var.cluster, "windowsInitialNodeCount", "0") + windowsMachineType = lookup(var.cluster, "windowsMachineType", "n1-standard-4") } # echo command used for debugging purpose @@ -37,10 +39,16 @@ locals { resource "null_resource" "test-setting-variables" { provisioner "local-exec" { command = < 0 ? [1] : [] + content { + # Enable Alias IPs to allow Windows Server networking. + cluster_ipv4_cidr_block = "/14" + services_ipv4_cidr_block = "/20" + } + } + dynamic "node_pool" { + for_each = tonumber(local.windowsInitialNodeCount) > 0 ? [1] : [] + content { + name = "windows" + node_count = local.windowsInitialNodeCount + version = local.kubernetesVersion + + management { + auto_upgrade = false + } + + node_config { + image_type = "WINDOWS_LTSC" + machine_type = local.windowsMachineType + + oauth_scopes = [ + "https://www.googleapis.com/auth/devstorage.read_only", + "https://www.googleapis.com/auth/logging.write", + "https://www.googleapis.com/auth/monitoring", + "https://www.googleapis.com/auth/service.management.readonly", + "https://www.googleapis.com/auth/servicecontrol", + "https://www.googleapis.com/auth/trace.append", + ] + + tags = ["game-server"] + } + } + } timeouts { create = "30m" update = "40m" diff --git a/install/terraform/modules/gke/variables.tf b/install/terraform/modules/gke/variables.tf index 499838c644..3af166b299 100644 --- a/install/terraform/modules/gke/variables.tf +++ b/install/terraform/modules/gke/variables.tf @@ -25,14 +25,16 @@ variable "cluster" { type = map default = { - "zone" = "us-west1-c" - "name" = "test-cluster" - "machineType" = "n1-standard-4" - "initialNodeCount" = "4" - "project" = "agones" - "network" = "default" - "subnetwork" = "" - "kubernetesVersion" = "1.18" + "zone" = "us-west1-c" + "name" = "test-cluster" + "machineType" = "n1-standard-4" + "initialNodeCount" = "4" + "project" = "agones" + "network" = "default" + "subnetwork" = "" + "kubernetesVersion" = "1.18" + "windowsInitialNodeCount" = "0" + "windowsMachineType" = "n1-standard-4" } } diff --git a/install/terraform/modules/helm3/helm.tf b/install/terraform/modules/helm3/helm.tf index 0a36f12af3..7d15855c88 100644 --- a/install/terraform/modules/helm3/helm.tf +++ b/install/terraform/modules/helm3/helm.tf @@ -18,11 +18,11 @@ terraform { required_version = ">= 0.12.6" required_providers { - helm = { + helm = { version = "~> 1.2" - source = "hashicorp/helm" + source = "hashicorp/helm" } - } + } } provider "helm" { kubernetes { @@ -34,13 +34,13 @@ provider "helm" { } resource "helm_release" "agones" { - name = "agones" - repository = "https://agones.dev/chart/stable" - force_update = var.force_update - chart = var.chart - timeout = 420 - version = var.agones_version - namespace = "agones-system" + name = "agones" + repository = "https://agones.dev/chart/stable" + force_update = var.force_update + chart = var.chart + timeout = 420 + version = var.agones_version + namespace = "agones-system" create_namespace = true # Use terraform of the latest >=0.12 version @@ -112,5 +112,5 @@ resource "helm_release" "agones" { name = "gameservers.maxPort" value = var.gameserver_maxPort } - + } diff --git a/install/terraform/modules/helm3/variables.tf b/install/terraform/modules/helm3/variables.tf index cefee11bc3..b87c1cc952 100644 --- a/install/terraform/modules/helm3/variables.tf +++ b/install/terraform/modules/helm3/variables.tf @@ -82,5 +82,5 @@ variable "gameserver_maxPort" { variable "gameserver_namespaces" { default = ["default"] - type = list(string) + type = list(string) } \ No newline at end of file diff --git a/test/terraform/cluster.tf b/test/terraform/cluster.tf index 99c4ce25ed..4cc8c058b3 100644 --- a/test/terraform/cluster.tf +++ b/test/terraform/cluster.tf @@ -27,11 +27,11 @@ variable "values_file" { module "gke_helm" { - source = "../../build/terraform/gke/" + source = "../../build/terraform/gke/" - values_file = var.values_file - project = var.project - name = var.name + values_file = var.values_file + project = var.project + name = var.name } // Additional resources for terratests