agones.dev/agones@v1.53.0/examples/terraform-submodules/oke/module.tf (about)

     1  // Copyright 2024 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 agones_version="1.17.0"]
    18  
    19  terraform {
    20    required_version = ">= 1.2.0"
    21    required_providers {
    22      oci = {
    23        source  = "oracle/oci"
    24        version = ">= 5.28.0"
    25      }
    26    }
    27  }
    28  
    29  module "oke_cluster" {
    30    source  = "oracle-terraform-modules/oke/oci"
    31    version = ">= 5.1.8"
    32  
    33    region      = var.region
    34    home_region = var.home_region
    35    tenancy_id  = var.tenancy_id
    36    user_id     = var.user_id
    37  
    38    providers = {
    39      oci      = oci
    40      oci.home = oci.home
    41    }
    42  
    43    # general oci parameters
    44    compartment_id = var.compartment_id
    45  
    46    # ssh keys
    47    ssh_private_key_path = var.ssh_private_key_path
    48    ssh_public_key_path  = var.ssh_public_key_path
    49  
    50    # Resource creation
    51    assign_dns           = true
    52    create_vcn           = true
    53    create_bastion       = true
    54    create_cluster       = true
    55    create_operator      = true
    56    create_iam_resources = true
    57  
    58    # oke cluster options
    59    cluster_name            = var.cluster_name
    60    cluster_type            = var.cluster_type
    61    cni_type                = var.preferred_cni
    62    control_plane_is_public = var.oke_control_plane == "public"
    63    kubernetes_version      = var.kubernetes_version
    64  
    65    # node pools
    66    worker_pools = {
    67      node_pool_1 = {
    68        shape            = "VM.Standard.E4.Flex",
    69        ocpus            = 2,
    70        memory           = 32,
    71        size             = var.node_count,
    72        boot_volume_size = 150,
    73      }
    74    }
    75  
    76    # security
    77    bastion_allowed_cidrs             = ["0.0.0.0/0"]
    78    control_plane_allowed_cidrs       = ["0.0.0.0/0"]
    79    allow_worker_ssh_access           = true
    80    assign_public_ip_to_control_plane = true
    81  }
    82  
    83  data "oci_containerengine_cluster_kube_config" "oke_cluster_kubeconfig" {
    84    cluster_id = module.oke_cluster.cluster_id
    85  }
    86  
    87  resource "local_file" "kubeconfig" {
    88    content         = data.oci_containerengine_cluster_kube_config.oke_cluster_kubeconfig.content
    89    filename        = "${path.module}/generated/kubeconfig"
    90    file_permission = "0600"
    91  }
    92  
    93  resource "oci_core_network_security_group_security_rule" "worker_ingress_rule" {
    94    network_security_group_id = module.oke_cluster.worker_nsg_id
    95    direction                 = "INGRESS"
    96    protocol                  = "17"
    97    source                    = "0.0.0.0/0"
    98    source_type               = "CIDR_BLOCK"
    99  
   100    udp_options {
   101      destination_port_range {
   102        #Required
   103        max = 8000
   104        min = 7000
   105      }
   106    }
   107  }
   108  
   109  resource "oci_core_network_security_group_security_rule" "worker_egress_rule" {
   110    network_security_group_id = module.oke_cluster.worker_nsg_id
   111    direction                 = "EGRESS"
   112    protocol                  = "all"
   113    destination               = "0.0.0.0/0"
   114    destination_type          = "CIDR_BLOCK"
   115  }
   116  
   117  module "helm_agones" {
   118    // ***************************************************************************************************
   119    // Update ?ref= to the agones release you are installing. For example, ?ref=release-1.17.0 corresponds
   120    // to Agones version 1.17.0
   121    // ***************************************************************************************************
   122    source = "git::https://github.com/googleforgames/agones.git//install/terraform/modules/oke-helm3/?ref=main"
   123  
   124    udp_expose         = "false"
   125    agones_version     = var.agones_version
   126    values_file        = ""
   127    feature_gates      = var.feature_gates
   128    log_level          = var.log_level
   129    cluster_kebuconfig = data.oci_containerengine_cluster_kube_config.oke_cluster_kubeconfig.content
   130  }