agones.dev/agones@v1.53.0/build/terraform/gke/module.tf (about)

     1  // Copyright 2019 Google LLC All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  
    16  // Run:
    17  //  terraform apply -var project="<YOUR_GCP_ProjectID>" [-var agones_version="1.17.0"]
    18  
    19  terraform {
    20    required_version = ">= 1.0.0"
    21    required_providers {
    22      google = {
    23        source  = "hashicorp/google"
    24        version = "~> 4.25.0"
    25      }
    26    }
    27  }
    28  
    29  variable "project" {
    30    default = ""
    31  }
    32  
    33  // Install latest version of agones
    34  variable "agones_version" {
    35    default = ""
    36  }
    37  
    38  variable "machine_type" {
    39    default = "e2-standard-4"
    40  }
    41  
    42  variable "windows_machine_type" {
    43    default = "e2-standard-4"
    44  }
    45  
    46  variable "name" {
    47    default = "agones-tf-cluster"
    48  }
    49  
    50  variable "values_file" {
    51    default = "../../../install/helm/agones/values.yaml"
    52  }
    53  
    54  variable "chart" {
    55    default = "agones"
    56  }
    57  
    58  variable "crd_cleanup" {
    59    default = "true"
    60  }
    61  
    62  variable "ping_service_type" {
    63    default = "LoadBalancer"
    64  }
    65  
    66  variable "location" {
    67    default     = "us-west1-c"
    68    description = "The GCP location to create the cluster in"
    69  }
    70  
    71  variable "zone" {
    72    default     = ""
    73    description = "The GCP zone to create the cluster in (deprecated, use `location`)"
    74  }
    75  
    76  variable "pull_policy" {
    77    default = "Always"
    78  }
    79  
    80  variable "image_registry" {
    81    default = "us-docker.pkg.dev/agones-images/release"
    82  }
    83  
    84  variable "always_pull_sidecar" {
    85    default = "true"
    86  }
    87  
    88  variable "image_pull_secret" {
    89    default = ""
    90  }
    91  
    92  variable "log_level" {
    93    default = "info"
    94  }
    95  
    96  variable "autoscale" {
    97    default = "false"
    98  }
    99  
   100  variable "min_node_count" {
   101    default = "1"
   102  }
   103  
   104  variable "max_node_count" {
   105    default = "5"
   106  }
   107  
   108  // Note: This is the number of gameserver nodes. The Agones module will automatically create an additional
   109  // two node pools with 1 node each for "agones-system" and "agones-metrics".
   110  variable "node_count" {
   111    default = "4"
   112  }
   113  // Note: This is the number of gameserver Windows nodes.
   114  variable "windows_node_count" {
   115    default = "0"
   116  }
   117  
   118  variable "network" {
   119    default     = "default"
   120    description = "The name of the VPC network to attach the cluster and firewall rule to"
   121  }
   122  
   123  variable "feature_gates" {
   124    default = ""
   125  }
   126  
   127  variable "enable_image_streaming" {
   128    default = "true"
   129  }
   130  
   131  module "gke_cluster" {
   132    source = "../../../install/terraform/modules/gke"
   133  
   134    cluster = {
   135      "name"                    = var.name
   136      "location"                = var.location
   137      "zone"                    = var.zone
   138      "machineType"             = var.machine_type
   139      "initialNodeCount"        = var.node_count
   140      "enableImageStreaming"    = var.enable_image_streaming
   141      "windowsMachineType"      = var.windows_machine_type
   142      "windowsInitialNodeCount" = var.windows_node_count
   143      "project"                 = var.project
   144      "network"                 = var.network
   145      "autoscale"               = var.autoscale
   146      "minNodeCount"            = var.min_node_count
   147      "maxNodeCount"            = var.max_node_count
   148    }
   149  }
   150  
   151  module "helm_agones" {
   152    source = "../../../install/terraform/modules/helm3"
   153  
   154    agones_version         = var.agones_version
   155    values_file            = var.values_file
   156    chart                  = var.chart
   157    feature_gates          = var.feature_gates
   158    host                   = module.gke_cluster.host
   159    token                  = module.gke_cluster.token
   160    cluster_ca_certificate = module.gke_cluster.cluster_ca_certificate
   161    image_registry         = var.image_registry
   162    image_pull_secret      = var.image_pull_secret
   163    crd_cleanup            = var.crd_cleanup
   164    ping_service_type      = var.ping_service_type
   165    log_level              = var.log_level
   166  }
   167  
   168  output "host" {
   169    value = module.gke_cluster.host
   170  }
   171  output "token" {
   172    value     = module.gke_cluster.token
   173    sensitive = true
   174  }
   175  output "cluster_ca_certificate" {
   176    value = module.gke_cluster.cluster_ca_certificate
   177  }