を使用してGoogle Kubernetesエンジン自動操縦クラスタを作成する


我々はネットワークスタックを作成しました.この部分でgkeオートパイロットクラスタを設定します.
次のリソースが作成されます.
  • オートパイロット・クラスター

  • オートパイロット・クラスター


    当社のGKEオートパイロットクラスタは、Webサブネットでホストされています.パブリックAPIサーバのエンドポイントは、特定のIPアドレスからアクセスできます.
    地形ファイルの作成infra/plan/gke.tf :
    resource "google_container_cluster" "private" {
      provider                 = google-beta
    
      name                     = "private"
      location                 = var.region
    
      network                  = google_compute_network.custom.name
      subnetwork               = google_compute_subnetwork.web.id
    
      private_cluster_config {
        enable_private_endpoint = false
        enable_private_nodes    = true
        master_ipv4_cidr_block  = var.gke_master_ipv4_cidr_block
      }
    
      master_authorized_networks_config {
        dynamic "cidr_blocks" {
            for_each = var.authorized_source_ranges
            content {
                cidr_block = cidr_blocks.value
            }
        }
       }
    
      maintenance_policy {
        recurring_window {
          start_time = "2021-06-18T00:00:00Z"
          end_time   = "2050-01-01T04:00:00Z"
          recurrence = "FREQ=WEEKLY"
        }
      }
    
      # Enable Autopilot for this cluster
      enable_autopilot = true
    
      # Configuration of cluster IP allocation for VPC-native clusters
      ip_allocation_policy {
        cluster_secondary_range_name  = "pods"
        services_secondary_range_name = "services"
      }
    
      # Configuration options for the Release channel feature, which provide more control over automatic upgrades of your GKE clusters.
      release_channel {
        channel = "REGULAR"
      }
    }
    
    コンプリートファイルinfra/plan/variable.tf :
    variable "gke_master_ipv4_cidr_block" {
      type    = string
      default = "172.23.0.0/28"
    }
    
    クラスターを展開しましょう
    cd infra/plan
    
    gcloud services enable container.googleapis.com --project $PROJECT_ID
    terraform apply
    
    クラスタが作成され、正しく動作しているかどうかを調べましょう.
    オートパイロット・クラスター

    結論


    我々のGKEクラスタは現在アクティブです.ここでは、クラウドSQLインスタンスの設定に集中します.