Terraform을 사용하여 Google Kubernetes Engine Autopilot 클러스터 만들기

에서 우리는 네트워크 스택을 만들었습니다. 이 부분에서는 GKE Autopilot 클러스터를 구성합니다.

다음 리소스가 생성됩니다.
  • GKE Autopilot 클러스터



  • GKE Autopilot 클러스터



    GKE Autopilot 클러스터는 웹 서브넷에서 호스팅됩니다. 퍼블릭 API 서버 엔드포인트는 특정 범위의 IP 주소에서만 액세스할 수 있습니다.

    terraform 파일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 Autopilot 클러스터



    결론



    이제 GKE 클러스터가 활성화되었습니다. 에서는 Cloud SQL 인스턴스 설정에 중점을 둘 것입니다.

    좋은 웹페이지 즐겨찾기