SaaS 런타임으로 서비스 인스턴스 배포

SaaS 런타임을 사용하여 서비스 인스턴스를 배포하는 방법을 알아봅니다. 이 빠른 시작 예시에서 서비스 인스턴스는 VM입니다.

시작하기 전에

  1. Google 계정에 로그인합니다.

    아직 계정이 없으면 새 계정을 등록하세요.

  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the SaaS Runtime, Artifact Registry, Infrastructure Manager, Developer Connect, Cloud Build, and Cloud Storage APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  5. Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles.
    2. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    3. Select your project.
    4. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    5. Click Create and continue.
    6. Grant the Project > Owner role to the service account.

      To grant the role, find the Select a role list, then select Project > Owner.

    7. Click Continue.
    8. Click Done to finish creating the service account.

  6. Google Cloud CLI를 설치합니다.

  7. 외부 ID 공급업체(IdP)를 사용하는 경우 먼저 제휴 ID로 gcloud CLI에 로그인해야 합니다.

  8. gcloud CLI를 초기화하려면, 다음 명령어를 실행합니다.

    gcloud init
  9. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  10. Verify that billing is enabled for your Google Cloud project.

  11. Enable the SaaS Runtime, Artifact Registry, Infrastructure Manager, Developer Connect, Cloud Build, and Cloud Storage APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  12. Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles.
    2. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    3. Select your project.
    4. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    5. Click Create and continue.
    6. Grant the Project > Owner role to the service account.

      To grant the role, find the Select a role list, then select Project > Owner.

    7. Click Continue.
    8. Click Done to finish creating the service account.

  13. Google Cloud CLI를 설치합니다.

  14. 외부 ID 공급업체(IdP)를 사용하는 경우 먼저 제휴 ID로 gcloud CLI에 로그인해야 합니다.

  15. gcloud CLI를 초기화하려면, 다음 명령어를 실행합니다.

    gcloud init

SaaS 러너 서비스 계정에 권한 부여

SaaS 런타임은 두 개 이상의 서비스 계정을 사용합니다. 이전 섹션에서 서비스 계정을 만들었으며 SaaS 런타임 API를 사용 설정하면 SaaS 런타임에서 다른 서비스 계정을 만듭니다.

SaaS 런타임에서 만든 서비스 계정은 service-PROJECT-NUMBER@gcp-sa-saasservicemgmt.iam.gserviceaccount.com입니다. 여기서 PROJECT-NUMBER은 프로젝트 번호입니다.

다음과 같이 하여 이 서비스 계정에 필요한 권한을 부여합니다.

  1. SaaS 런타임 > 개요 > 시작하기 페이지를 엽니다.

    SaaS 런타임 시작하기로 이동

  2. SaaS 런타임 계정에 필요한 권한이 부여되지 않았습니다라는 메시지가 표시된 배너에서 권한 부여를 클릭합니다.

Terraform 구성을 사용하여 서비스 인스턴스 정의

Terraform 구성을 사용하여 서비스 인스턴스에 배포할 인프라를 정의해야 합니다. 이 빠른 시작에서는 VM을 배포합니다.

VM을 정의하는 Terraform 구성을 만들려면 다음 단계를 따르세요.

  1. 로컬 머신에 terraform-vm라는 디렉터리를 만듭니다.

  2. terraform-vm 내에서 다음 네 개의 Terraform 파일을 만듭니다.

    1. 다음 콘텐츠로 versions.tf라는 파일을 만듭니다.

      terraform {
        required_version = "1.5.7"
        required_providers {
          google = {
            source  = "hashicorp/google"
            version = "~> 4.0"
          }
        }
      }
      
    2. 다음 콘텐츠로 outputs.tf라는 파일을 만듭니다.

      output "instance_name" {
        description = "Name of the instance"
        value       = google_compute_instance.vm_instance.name
      }
      
      output "instance_external_ip" {
        description = "External IP of the instance"
        value       = google_compute_instance.vm_instance.network_interface[0].access_config[0].nat_ip
      }
      
      output "instance_self_link" {
        description = "Self-link of the instance"
        value       = google_compute_instance.vm_instance.self_link
      }
      
    3. 다음 콘텐츠로 variables.tf라는 파일을 만듭니다.

      variable "region" {
        description = "The Google Cloud region"
        type        = string
        default     = "us-central1"
      }
      
      variable "zone" {
        description = "The Google Cloud zone"
        type        = string
        default     = "us-central1-a"
      }
      
      variable "instance_name" {
        description = "Name for the Compute Engine instance"
        type        = string
        default = "saas-runtime-vm-instance"
      }
      
      variable "machine_type" {
        description = "Machine type for the Compute Engine instance"
        type        = string
        default = "e2-medium"
      }
      
      variable "disk_size" {
        description = "Boot disk size in GB"
        type        = number
        default = 10
      }
      
      variable "actuation_sa" {
        description = "The email of the Actuation Service Account"
        type        = string
      }
      
      variable "tenant_project_id" {
        description = "The project ID of the tenant project"
        type        = string
      }
      
      variable "tenant_project_number" {
        description = "The project number of the tenant project"
        type        = number
      }
      
    4. 다음 콘텐츠로 main.tf라는 파일을 만듭니다.

      resource "google_compute_instance" "vm_instance" {
        project      = var.tenant_project_id
        name         = var.instance_name
        machine_type = var.machine_type
        zone         = var.zone
      
        boot_disk {
          initialize_params {
            image = "debian-cloud/debian-11"
            size  = var.disk_size
          }
        }
      
        network_interface {
          network = "default"
          access_config {
            # Ephemeral public IP - empty block is okay here
          }
        }
      
        tags = ["allow-ssh"]
      }
      
  3. 이러한 네 개의 Terraform 구성 파일이 포함된 zip 보관 파일을 만들려면 터미널에서 terraform-vm 디렉터리로 이동하여 다음 명령어를 실행합니다.

    zip terraform-files.zip main.tf outputs.tf variables.tf versions.tf
    

    이제 Terraform 구성 파일 4개가 모두 포함된 terraform-files.zip라는 이름의 zip 보관 파일이 있습니다.

Artifact Registry에서 저장소 만들기

SaaS 런타임을 사용하려면 Artifact Registry에 저장소가 있어야 합니다. 이 저장소를 만들려면 다음을 실행하세요.

  1. 콘솔에서 Artifact Registry로 이동합니다.

    Artifact Registry로 이동

  2. 저장소 만들기를 클릭합니다.

  3. 이름vm-quickstart-repo를 입력합니다.

  4. 형식Docker로 선택된 상태를 유지합니다.

  5. 리전us-central1 (Iowa)을 선택합니다.

  6. 만들기를 클릭합니다.

SaaS 제품 만들기

배포하려는 VM과 저장소를 정의하는 Terraform 구성이 있습니다. 이제 SaaS 런타임을 사용하여 배포 단위를 모델링하고 VM을 배포할 수 있습니다.

SaaS 제품 리소스 만들기

  1. 콘솔에서 SaaS 런타임 > SaaS 제품으로 이동합니다.

    SaaS 제품으로 이동

  2. 만들기를 클릭합니다.

  3. SaaS 제품 이름 필드에 vm-quickstart-saas-offering를 입력합니다.

  4. 리전 필드에서 us-central1 리전을 선택한 다음 확인을 클릭합니다.

  5. 만들기를 클릭합니다.

SaaS 제품에 대해 선택한 리전은 SaaS 제품의 배포가 호스팅되는 위치입니다. 이 빠른 시작의 예에서 SaaS 제품은 단일 VM이므로 이러한 리전은 VM이 프로비저닝되고 호스팅되는 위치입니다.

이러한 VM에 액세스하는 최종 사용자가 있는 경우 여기에서 지정한 리전에 배포된 VM에 액세스하게 됩니다.

배포 단위 모델링

SaaS 제품을 모델링하려면 단위 종류라는 구성요소를 만듭니다. 단위 종류는 배포하고 관리할 서비스 내의 구성요소를 정의합니다. 예를 들어 VM용 단위 종류가 하나 있고 해당 VM에서 실행되는 애플리케이션용 단위 종류가 두 번째로 있을 수 있습니다.

이 빠른 시작에서는 VM에 대한 하나의 단위 종류를 만듭니다.

단위 종류를 만들려면 다음 단계를 따르세요.

  1. 콘솔에서 SaaS 런타임 > 단위 종류로 이동합니다.

    단위 종류로 이동

  2. 만들기를 선택합니다.

  3. 청사진 만들기 페이지에서 다음을 수행합니다.

    1. 업로드를 선택합니다.
    2. VM을 정의하는 Terraform 구성을 업로드하려면 다음 단계를 따르세요.
      1. 파일 선택기 필드에서 찾아보기를 선택합니다.
      2. 이전에 만든 zip 보관 파일인 terraform-files.zip로 이동하여 선택합니다.
      3. 열기를 선택합니다.
    3. 다음: 청사진 구성을 클릭합니다.
  4. 스토어 청사진 페이지에서 다음을 수행합니다.

    1. Artifact Registry를 선택합니다.
      1. Artifact Registry에서 저장소 선택 필드에서 찾아보기를 선택합니다.
      2. 이전에 만든 저장소인 vm-quickstart-repo을 선택합니다.
      3. 선택을 클릭합니다.
    2. 아티팩트 이미지 이름 필드에 vm-quickstart-blueprint을 입력합니다.
    3. Infrastructure Manager Terraform 버전에서 1.5.7을 선택합니다.
    4. Cloud Build 서비스 계정에서 시작하기 전에 섹션에서 만든 서비스 계정을 선택합니다.
    5. 다음: 단위 종류 세부정보를 클릭합니다.
  5. 단위 종류 속성 구성 페이지에서 다음을 수행합니다.

    1. 단위 종류 이름vm-quickstart-unit-kind를 입력합니다.
    2. SaaS 제품에서 이전에 만든 SaaS 제품 리소스인 vm-quickstart-saas-offering을 선택합니다.
    3. 다음: 출시 구성을 클릭합니다.
  6. 버전 이름vm-quickstart-first-release를 입력합니다.

  7. 만들기를 클릭합니다.

서비스 인스턴스 프로비저닝

단위 종류에 속하는 리소스를 프로비저닝하려면 단위를 만듭니다. 단위를 만들면 SaaS Runtime은 단위 종류에 연결된 Terraform 구성에 정의된 리소스를 프로비저닝합니다. 리소스는 SaaS 제품에 포함된 각 리전에서 프로비저닝됩니다.

이 빠른 시작의 예에서는 VM이 us-central1 리전에 프로비저닝됩니다.

  1. 단위를 만듭니다.

    1. 콘솔에서 SaaS 런타임 > 단위로 이동합니다.

      단위로 이동

    2. 만들기를 선택합니다.

    3. 단위 만들기 페이지에서 다음을 수행합니다.

      1. 단위 이름vm-quickstart-unit를 입력합니다.
      2. SaaS 제품에서 이전에 만든 SaaS 제품 리소스(vm-quickstart-saas-offering)를 선택합니다.
      3. 리전에서 us-central1를 선택합니다.
      4. 단위 종류에서 이전에 만든 단위 종류(vm-quickstart-unit-kind)를 선택합니다.
      5. 만들기를 선택합니다.
  2. VM을 프로비저닝하려면 다음 단계를 따르세요.

    1. 단위 세부정보 페이지에서 프로비저닝을 선택합니다.
    2. 출시 버전 필드에서 vm-quickstart-first-release을 선택합니다.
    3. 서비스 계정에서 시작하기 전에 섹션에서 만든 서비스 계정을 선택합니다.
    4. 테넌트 프로젝트를 추가합니다.

      1. 테넌트 프로젝트 변수 추가를 선택합니다.
      2. 이 빠른 시작에 사용 중인 Google Cloud 프로젝트를 선택합니다. SaaS 런타임이 VM을 배포할 때 이 프로젝트에 배포합니다.
    5. 프로비저닝을 선택합니다.

SaaS 런타임은 SaaS 제품에 지정된 리전에 VM을 프로비저닝합니다. 단위에서 지정한 리전 중 하나에 단위를 만들 수 있습니다. 이 빠른 시작에서는 하나의 리전 (us-central1)을 지정했으며 이 리전에서 VM이 프로비저닝됩니다.

배포된 VM 보기

이제 SaaS 런타임을 사용하여 VM을 배포했습니다.

이 빠른 시작에서 배포한 VM을 보려면 다음 단계를 따르세요.

  1. 콘솔에서 SaaS 런타임 > 단위 > 단위 세부정보 페이지로 이동합니다.

    단위로 이동

  2. 단위 이름(vm-quickstart-unit)을 클릭합니다.

  3. Unit details(단위 세부정보) 페이지에서 다음을 수행합니다.

    1. 상태가 다음과 같은지 확인합니다.

      • VM이 프로비저닝된 경우 Ready
      • 작업이 아직 진행 중인 경우 프로비저닝
    2. 변수 섹션을 펼칩니다.

    3. 출력 변수에서 인스턴스에 연결하는 데 사용할 수 있는 외부 IP를 확인할 수 있습니다.

  4. Compute Engine에서 VM을 볼 수도 있습니다.

    1. 콘솔에서 Compute Engine > VM 인스턴스 페이지로 이동합니다.

      VM 인스턴스로 이동

    2. VM 인스턴스 아래에 VM이 나열되어 있습니다.

삭제

이 페이지에서 사용한 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 다음 단계를 수행합니다.

프로젝트 삭제

새 Google Cloud 프로젝트에 솔루션을 배포했고 프로젝트가 더 이상 필요하지 않으면 다음 단계에 따라 이를 삭제합니다.

  1. Google Cloud 콘솔에서 리소스 관리 페이지로 이동합니다.

    리소스 관리로 이동

  2. 프로젝트 목록에서 삭제할 프로젝트를 선택하고 삭제를 클릭합니다.
  3. 프롬프트에서 프로젝트 ID를 입력한 후 종료를 클릭합니다.

다음 단계