SaaS 제품 설계 및 배포

Application Design Center 및 App Lifecycle Manager를 사용하면 각 고객의 인프라를 수동으로 구성하지 않고도 멀티 테넌트 SaaS 전송을 표준화하고 확장할 수 있습니다. App Design Center에서 재사용 가능한 Terraform 모듈을 복합 애플리케이션 템플릿으로 조합한 다음 App Lifecycle Manager에서 해당 템플릿을 관리형 SaaS 제품으로 패키징합니다.

이 튜토리얼에서는 격리된 테넌트 환경을 프로비저닝하고 점진적 업데이트 및 출시를 자동화합니다. 이 워크플로는 플랫폼 엔지니어, 엔터프라이즈 설계자, DevOps 운영자를 대상으로 합니다.

목표

  • Cloud Run 및 Cloud Storage Terraform 모듈이 포함된 GitHub 저장소를 준비합니다.
  • Developer Connect를 사용하여 GitHub 저장소를 Google Cloud 에 연결합니다.
  • Terraform 모듈을 가져와 App Design Center에서 구성요소 템플릿을 만들고 카탈로그화합니다.
  • 구성요소 템플릿이 포함된 복합 애플리케이션 템플릿을 설계합니다.
  • 템플릿을 패키징하고 App Lifecycle Manager에서 고객 환경을 배포합니다.
  • 고객 환경 전반에서 점진적 출시를 자동화합니다.

비용

이 문서에서는 비용이 청구될 수 있는 Google Cloud구성요소를 사용합니다.

프로젝트 사용량을 기준으로 예상 비용을 산출하려면 가격 계산기를 사용하세요.

Google Cloud 신규 사용자는 무료 체험판을 사용할 수 있습니다.

이 문서에 설명된 태스크를 완료했으면 만든 리소스를 삭제하여 청구가 계속되는 것을 방지할 수 있습니다. 자세한 내용은 삭제를 참조하세요.

시작하기 전에

  1. Google Cloud 계정에 로그인합니다. Google Cloud를 처음 사용하는 경우 계정을 만들고 Google 제품의 실제 성능을 평가해 보세요. 신규 고객에게는 워크로드를 실행, 테스트, 배포하는 데 사용할 수 있는 $300의 무료 크레딧이 제공됩니다.
  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 Developer Connect, Secret Manager, App Lifecycle Manager, Infrastructure Manager, and Cloud Run APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  5. 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

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

  7. Enable the Developer Connect, Secret Manager, App Lifecycle Manager, Infrastructure Manager, and Cloud Run APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  8. 프로젝트에 다음 Identity and Access Management(IAM) 역할이 있는지 확인합니다.
    • Application Design Center 관리자(roles/designcenter.admin) 및 서비스 사용량 관리자(roles/serviceusage.serviceUsageAdmin)를 사용하여 설정을 수행합니다.
    • SaaS 서비스 관리 관리자(roles/saasservicemgmt.admin)
    • Developer Connect 관리자(roles/developerconnect.admin)
    • 서비스 계정을 만들고 IAM 역할을 부여하는 프로젝트 IAM 관리자(roles/resourcemanager.projectIamAdmin) 또는 보안 관리자(roles/iam.securityAdmin)
    • Cloud Run 관리자(roles/run.admin)
    • 스토리지 관리자(roles/storage.admin)
    • 서비스 계정 관리자(roles/iam.serviceAccountAdmin)
  9. Google Cloud CLI를 설치한 후 초기화합니다.
    gcloud init
    beta 구성요소가 설치되어 있는지 확인합니다.
    gcloud components install beta
  10. 단일 프로젝트 애플리케이션 관리 경계를 사용하여 프로젝트에서 Application Design Center 설정을 완료합니다. 설정은 애플리케이션 관리를 사용 설정하고, Terraform의 스토리지 버킷을 프로비저닝하고, default-space 공간과 default-catalog 카탈로그를 만듭니다.
  11. 로컬 머신에 Git을 설치합니다.
  12. 저장소를 만들고 개인 액세스 토큰을 생성할 수 있는 권한이 있는 GitHub 계정이 있는지 확인합니다.

환경 및 소스 저장소 설정

이 튜토리얼의 환경을 설정하려면 변수 값을 지정하고 GitHub 저장소를 구성합니다.

튜토리얼 변수 지정

이 튜토리얼과 명령어 터미널에서 변수를 설정합니다.

  1. 다음 변수를 설정하여 이 튜토리얼의 명령어를 업데이트합니다.

    변수 설명 값
    PROJECT_ID Google Cloud 프로젝트 ID PROJECT_ID
    REGION App Design Center 리소스, Developer Connect, App Lifecycle Manager 제품, 테넌트 인프라의 배포 리전 us-central1
  2. 명령어 터미널에서 활성 Google Cloud 프로젝트를 구성합니다.

    gcloud config set project PROJECT_ID
    
  3. Google Cloud 프로젝트 번호를 검색하여 환경 변수에 저장합니다.

    PROJECT_NUM=$(gcloud projects describe PROJECT_ID --format="value(projectNumber)")
    

Terraform 구성 파일 만들기

Cloud Run 및 Cloud Storage용 모듈식 Terraform 정의를 작성합니다. 나중에 이러한 모듈을 App Design Center로 가져와 재사용 가능한 아키텍처 구성요소로 패키징합니다.

  1. Terraform 모듈의 로컬 디렉터리 구조를 만듭니다.

    mkdir -p adc-alm-starter/infra/cloud-run
    mkdir -p adc-alm-starter/infra/cloud-storage
    cd adc-alm-starter
    
  2. infra/cloud-run/main.tf에서 Cloud Run 모듈 정의를 만듭니다.

    terraform {
      required_version = ">= 1.5.0"
      required_providers {
        google = {
          source  = "hashicorp/google"
          version = ">= 5.0.0"
        }
      }
    }
    
    variable "project_id" {
      type        = string
      description = "The Google Cloud project ID."
    }
    
    variable "region" {
      type        = string
      description = "The deployment region."
      default     = "us-central1"
    }
    
    variable "service_name" {
      type        = string
      description = "Name of the Cloud Run service."
      default     = "sample-app"
    }
    
    variable "bucket_name" {
      type        = string
      description = "Name of the Cloud Storage bucket to connect."
      default     = ""
    }
    
    resource "google_service_account" "app_sa" {
      account_id   = "${var.service_name}-sa"
      display_name = "Service Account for ${var.service_name}"
      project      = var.project_id
    }
    
    resource "google_cloud_run_v2_service" "app_service" {
      name                = var.service_name
      location            = var.region
      project             = var.project_id
      deletion_protection = false
    
      template {
        service_account = google_service_account.app_sa.email
        containers {
          image = "us-docker.pkg.dev/cloudrun/container/hello"
          env {
            name  = "STORAGE_BUCKET"
            value = var.bucket_name
          }
          resources {
            limits = {
              cpu    = "1"
              memory = "512Mi"
            }
          }
        }
      }
    }
    
    output "service_url" {
      description = "URL of the deployed Cloud Run service."
      value       = google_cloud_run_v2_service.app_service.uri
    }
    
    output "service_account_email" {
      description = "Email of the Cloud Run service account."
      value       = google_service_account.app_sa.email
    }
    
  3. infra/cloud-run/metadata.yaml에서 모듈 메타데이터 정의를 만듭니다.

    apiVersion: blueprints.cloud.google.com/v1alpha1
    kind: BlueprintMetadata
    metadata:
      name: cloud-run-component
    spec:
      info:
        title: Cloud Run Component
        version: 0.1.0
        actuationTool:
          flavor: Terraform
          version: ">= 1.5.0"
      interfaces:
        variables:
          - name: project_id
            description: The Google Cloud project ID.
            varType: string
            required: true
          - name: region
            description: The deployment region.
            varType: string
            defaultValue: us-central1
          - name: service_name
            description: Name of the Cloud Run service.
            varType: string
            defaultValue: sample-app
          - name: bucket_name
            description: Name of the Cloud Storage bucket to connect.
            varType: string
            defaultValue: ""
        outputs:
          - name: service_url
            description: URL of the deployed Cloud Run service.
          - name: service_account_email
            description: Email of the Cloud Run service account.
    
  4. infra/cloud-storage/main.tf에서 Cloud Storage 모듈 정의를 만듭니다.

    terraform {
      required_version = ">= 1.5.0"
      required_providers {
        google = {
          source  = "hashicorp/google"
          version = ">= 5.0.0"
        }
        random = {
          source  = "hashicorp/random"
          version = ">= 3.5.0"
        }
      }
    }
    
    variable "project_id" {
      type        = string
      description = "The Google Cloud project ID."
    }
    
    variable "region" {
      type        = string
      description = "The deployment region."
      default     = "us-central1"
    }
    
    variable "bucket_name_prefix" {
      type        = string
      description = "Prefix for the Cloud Storage bucket."
      default     = "app-data"
    }
    
    variable "writer_service_account" {
      type        = string
      description = "Service account email granted objectAdmin permissions."
      default     = ""
    }
    
    resource "random_id" "bucket_suffix" {
      byte_length = 4
    }
    
    resource "google_storage_bucket" "bucket" {
      name                        = "${var.bucket_name_prefix}-${random_id.bucket_suffix.hex}"
      location                    = var.region
      project                     = var.project_id
      uniform_bucket_level_access = true
      force_destroy               = true
    }
    
    resource "google_storage_bucket_iam_member" "writer_grant" {
      count  = var.writer_service_account != "" ? 1 : 0
      bucket = google_storage_bucket.bucket.name
      role   = "roles/storage.objectAdmin"
      member = "serviceAccount:${var.writer_service_account}"
    }
    
    output "bucket_name" {
      description = "Name of the created storage bucket."
      value       = google_storage_bucket.bucket.name
    }
    
  5. infra/cloud-storage/metadata.yaml에서 모듈 메타데이터 정의를 만듭니다.

    apiVersion: blueprints.cloud.google.com/v1alpha1
    kind: BlueprintMetadata
    metadata:
      name: cloud-storage-component
    spec:
      info:
        title: Cloud Storage Component
        version: 0.1.0
        actuationTool:
          flavor: Terraform
          version: ">= 1.5.0"
      interfaces:
        variables:
          - name: project_id
            description: The Google Cloud project ID.
            varType: string
            required: true
          - name: region
            description: The deployment region.
            varType: string
            defaultValue: us-central1
          - name: bucket_name_prefix
            description: Prefix for the Cloud Storage bucket.
            varType: string
            defaultValue: app-data
          - name: writer_service_account
            description: Service account email granted objectAdmin permissions.
            varType: string
            defaultValue: ""
        outputs:
          - name: bucket_name
            description: Name of the created storage bucket.
    

GitHub로 Terraform 푸시

Terraform 구성을 GitHub 저장소에 커밋하고 Developer Connect를 통해 저장소를 Google Cloud 에 연결합니다. 이 연결을 통해 앱 디자인 센터는 소스 제어에서 직접 인프라 버전을 가져올 수 있는 안전한 액세스 권한을 얻습니다.

  1. 웹브라우저에서 adc-alm-starter이라는 새 GitHub 저장소를 만듭니다.

  2. GitHub에서 세분화된 개인 액세스 토큰을 만들어 git push 명령어를 인증합니다. adc-alm-starter 저장소를 선택하고 콘텐츠: 읽기 및 쓰기 권한을 부여합니다.

  3. 명령어 터미널에서 adc-alm-starter 디렉터리의 Git을 초기화하고 파일을 커밋한 후 GitHub에 푸시합니다.

    cd adc-alm-starter
    git init
    git add infra/
    git commit -m "feat: initialize Cloud Run and Cloud Storage modules"
    git branch -M main
    git remote add origin https://github.com/GITHUB_USER_OR_ORG/adc-alm-starter.git
    git push -u origin main
    

    인증을 요청하는 메시지가 표시되면 GitHub 사용자 이름과 개인 액세스 토큰을 입력합니다.

  4. Google Cloud 콘솔에서 Developer Connect 페이지로 이동합니다.

    Developer Connect로 이동

  5. GitHub 계정의 us-central1 리전에 연결을 만들고 저장소를 연결합니다. 자세한 내용은 GitHub에 연결을 참조하세요.

  6. 연결된 저장소의 연결 ID 및 Git 저장소 링크 ID를 식별하고 다음 변수를 업데이트합니다.

    • CONNECTION_ID: Developer Connect 연결 식별자입니다.
    • GIT_REPO_LINK_ID: 연결된 Git 저장소 식별자입니다.

App Design Center에서 템플릿 작성

Google Cloud 인프라를 설계하려면 Terraform 모듈을 App Design Center에 구성요소 템플릿으로 가져옵니다. 그런 다음 구성요소를 포함하는 복합 애플리케이션 템플릿을 만듭니다.

공간 및 카탈로그 확인

Google Cloud 콘솔에서 App Design Center 설정을 완료하면 기본 공간과 카탈로그가 자동으로 생성됩니다.

gcloud CLI로 설정을 완료한 경우 다음을 수행합니다.

  1. default-space이 리전에 있는지 확인합니다.

    gcloud design-center spaces describe "default-space" \
        --location="us-central1"
    

    default-space를 앱 디자인 센터 스페이스 ID로 바꿉니다.

  2. 스페이스가 없으면 스페이스와 카탈로그를 만듭니다.

    gcloud design-center spaces create "default-space" \
        --location="us-central1" \
        --display-name="Default Space"
    
    gcloud design-center spaces catalogs create "default-catalog" \
        --space="default-space" \
        --location="us-central1" \
        --display-name="Default Catalog"
    

    default-catalog를 카탈로그 ID로 바꿉니다.

구성요소 템플릿 만들기

구성요소 템플릿은 개별 Terraform 모듈을 멀티 서비스 애플리케이션 템플릿에 추가할 수 있는 구성요소로 변환합니다.

Git 저장소의 Terraform 모듈을 기반으로 구성요소 템플릿을 만듭니다.

  1. Cloud Run의 카탈로그 템플릿을 만듭니다.

    gcloud design-center spaces catalogs templates create "cloud-run-component" \
        --space="default-space" \
        --catalog="default-catalog" \
        --location="us-central1" \
        --display-name="Cloud Run Component" \
        --template-category=component-template
    

    cloud-run-component를 Cloud Run 구성요소 템플릿의 식별자로 바꿉니다.

  2. Cloud Storage용 카탈로그 템플릿을 만듭니다.

    gcloud design-center spaces catalogs templates create "cloud-storage-component" \
        --space="default-space" \
        --catalog="default-catalog" \
        --location="us-central1" \
        --display-name="Cloud Storage Component" \
        --template-category=component-template
    

    cloud-storage-component를 Cloud Storage 구성요소 템플릿 식별자로 바꿉니다.

  3. Git 저장소에서 Cloud Run Terraform 모듈을 가져와 템플릿 버전을 만듭니다.

    gcloud design-center spaces catalogs templates revisions create r-1 \
        --template="cloud-run-component" \
        --catalog="default-catalog" \
        --space="default-space" \
        --location="us-central1" \
        --developer-connect-repo="projects/PROJECT_ID/locations/us-central1/connections/CONNECTION_ID/gitRepositoryLinks/GIT_REPO_LINK_ID" \
        --developer-connect-repo-dir="infra/cloud-run" \
        --developer-connect-repo-ref="refs/heads/main"
    

    다음을 바꿉니다.

    • CONNECTION_ID: Developer Connect 연결 ID입니다.
    • GIT_REPO_LINK_ID: 연결된 Git 저장소 링크 ID입니다.
  4. Git 저장소에서 Cloud Storage Terraform 모듈을 가져와 템플릿 버전을 만듭니다.

    gcloud design-center spaces catalogs templates revisions create r-1 \
        --template="cloud-storage-component" \
        --catalog="default-catalog" \
        --space="default-space" \
        --location="us-central1" \
        --developer-connect-repo="projects/PROJECT_ID/locations/us-central1/connections/CONNECTION_ID/gitRepositoryLinks/GIT_REPO_LINK_ID" \
        --developer-connect-repo-dir="infra/cloud-storage" \
        --developer-connect-repo-ref="refs/heads/main"
    

    다음을 바꿉니다.

    • CONNECTION_ID: Developer Connect 연결 ID입니다.
    • GIT_REPO_LINK_ID: 연결된 Git 저장소 링크 ID입니다.
  5. 공간의 공유 템플릿을 나열하여 공유 템플릿 ID를 가져옵니다.

    gcloud design-center spaces shared-templates list \
        --space="default-space" \
        --location="us-central1"
    

    명령어 출력에서 cloud-run-component 및 cloud-storage-component 모두에 대해 name 필드(projects/PROJECT_ID/locations/us-central1/spaces/default-space/sharedTemplates/SHARED_TEMPLATE_ID)의 SHARED_TEMPLATE_ID 세그먼트를 기록합니다.

복합 애플리케이션 템플릿 만들기

구성요소 템플릿을 복합 애플리케이션 템플릿으로 결합하고 파라미터 연결을 구성합니다. App Lifecycle Manager는 복합 템플릿을 사용하여 애플리케이션 토폴로지를 SaaS 제품으로 관리합니다. Cloud Run 서비스가 Cloud Storage에 액세스하는 데 필요한 버킷 이름과 IAM 권한을 자동으로 수신하도록 출력과 입력을 지정합니다.

  1. 복합 애플리케이션 템플릿을 만듭니다.

    gcloud design-center spaces application-templates create "run-storage-app" \
        --space="default-space" \
        --location="us-central1" \
        --display-name="Cloud Run and Storage Multi-Tenant Application" \
        --composition-type=composite
    

    run-storage-app를 복합 애플리케이션 템플릿 식별자로 바꿉니다.

  2. 애플리케이션 템플릿에 Cloud Run 구성요소를 추가합니다.

    gcloud design-center spaces application-templates components create cloud-run-comp \
        --application-template="run-storage-app" \
        --space="default-space" \
        --location="us-central1" \
        --shared-template-revision-uri="projects/PROJECT_ID/locations/us-central1/spaces/default-space/sharedTemplates/RUN_SHARED_TEMPLATE_ID/revisions/r-1"
    

    RUN_SHARED_TEMPLATE_ID를 검색한 cloud-run-component 공유 템플릿 ID로 바꿉니다.

  3. 애플리케이션 템플릿에 Cloud Storage 구성요소를 추가합니다.

    gcloud design-center spaces application-templates components create cloud-storage-comp \
        --application-template="run-storage-app" \
        --space="default-space" \
        --location="us-central1" \
        --shared-template-revision-uri="projects/PROJECT_ID/locations/us-central1/spaces/default-space/sharedTemplates/STORAGE_SHARED_TEMPLATE_ID/revisions/r-1"
    

    STORAGE_SHARED_TEMPLATE_ID를 검색한 cloud-storage-component 공유 템플릿 ID로 바꿉니다.

  4. Cloud Run 서비스에서 Cloud Storage 버킷으로 연결을 만듭니다. 이렇게 하면 버킷 출력이 서비스 환경 변수에 연결되고 서비스 계정에 IAM 액세스 권한이 부여됩니다.

    gcloud design-center spaces application-templates components connections create run-to-storage \
        --component=cloud-run-comp \
        --application-template="run-storage-app" \
        --space="default-space" \
        --location="us-central1" \
        --destination-component-uri="projects/PROJECT_ID/locations/us-central1/spaces/default-space/applicationTemplates/run-storage-app/components/cloud-storage-comp" \
        --source-component-parameters='[{"key": "bucket_name", "value": "module.cloud-storage-comp.bucket_name"}]' \
        --destination-component-parameters='[{"key": "writer_service_account", "value": "module.cloud-run-comp.service_account_email"}]'
    
  5. 애플리케이션 템플릿을 커밋하여 변경 불가능한 템플릿 버전을 생성합니다.

    gcloud design-center spaces application-templates commit "run-storage-app" \
        --space="default-space" \
        --location="us-central1"
    

    명령어 출력에서 생성된 버전 식별자(예: r-1)를 확인합니다. 이 식별자는 App Lifecycle Manager에서 SaaS 제품을 만들 때 참조합니다.


App Lifecycle Manager로 고객 환경 배포

App Lifecycle Manager를 사용하여 애플리케이션 템플릿을 배포 가능한 제품으로 변환하고 각 고객에게 전용 환경을 프로비저닝합니다.

애플리케이션 템플릿 패키징

App Lifecycle Manager에 템플릿 버전을 등록하여 배포 가능한 SaaS 제품을 만듭니다.

  1. us-central1에서 SaaS 제품을 만듭니다.

    gcloud beta app-lifecycle-manager saas create "saas-run-storage" \
        --location="us-central1" \
        --locations=name="us-central1" \
        --application-template="projects/PROJECT_ID/locations/us-central1/spaces/default-space/applicationTemplates/run-storage-app" \
        --application-template-revision="projects/PROJECT_ID/locations/us-central1/spaces/default-space/applicationTemplates/run-storage-app/revisions/r-1"
    

    saas-run-storage를 SaaS 솔루션 식별자로 바꿉니다.

  2. 생성된 출시 버전을 나열하여 출시 ID, 단위 종류, 입력 변수를 가져옵니다.

    gcloud beta app-lifecycle-manager releases list \
        --location="us-central1"
    

    App Lifecycle Manager는 복합 템플릿의 청사진을 비동기식으로 빌드하고 패키징합니다. 목록이 비어 있으면 몇 분 정도 기다린 후 명령어를 다시 실행합니다.

    이 명령어는 다음 정보를 출력합니다.

    • name 필드(예: projects/PROJECT_ID/locations/us-central1/releases/r-r-1-06c6a0). 후행 세그먼트는 RELEASE_ID입니다(예: r-r-1-06c6a0).
    • unitKind 필드(예: projects/PROJECT_ID/locations/us-central1/unitKinds/u-native-components-e97e0c). 후행 세그먼트는 UNIT_KIND_ID입니다(예: u-native-components-e97e0c).

배포 서비스 계정 만들기

App Lifecycle Manager에 사용자를 대신하여 리소스를 프로비저닝할 수 있는 권한을 부여하는 서비스 계정을 만듭니다.

  1. 작동 서비스 계정을 만듭니다.

    gcloud iam service-accounts create "tenant-actuation-sa" \
        --display-name="Tenant Actuation Service Account"
    

    tenant-actuation-sa을 작동 서비스 계정 이름으로 바꿉니다.

  2. 서비스 계정 이메일을 구성하고 App Lifecycle Manager 서비스 에이전트 ID를 가져옵니다.

    ACTUATION_SA="tenant-actuation-sa@PROJECT_ID.iam.gserviceaccount.com"
    ALM_P4SA="service-${PROJECT_NUM}@gcp-sa-saasservicemgmt.iam.gserviceaccount.com"
    INFRA_MANAGER_P4SA="service-${PROJECT_NUM}@gcp-sa-config.iam.gserviceaccount.com"
    
  3. 작동 서비스 계정에 테넌트 인프라를 만들고 관리하는 데 필요한 역할을 부여합니다.

    gcloud projects add-iam-policy-binding "PROJECT_ID" \
        --member="serviceAccount:${ACTUATION_SA}" \
        --role="roles/run.admin" \
        --condition=None
    
    gcloud projects add-iam-policy-binding "PROJECT_ID" \
        --member="serviceAccount:${ACTUATION_SA}" \
        --role="roles/storage.admin" \
        --condition=None
    
    gcloud projects add-iam-policy-binding "PROJECT_ID" \
        --member="serviceAccount:${ACTUATION_SA}" \
        --role="roles/iam.serviceAccountAdmin" \
        --condition=None
    
    gcloud projects add-iam-policy-binding "PROJECT_ID" \
        --member="serviceAccount:${ACTUATION_SA}" \
        --role="roles/iam.serviceAccountUser" \
        --condition=None
    
    gcloud projects add-iam-policy-binding "PROJECT_ID" \
        --member="serviceAccount:${ACTUATION_SA}" \
        --role="roles/config.admin" \
        --condition=None
    
  4. App Lifecycle Manager 및 Infra Manager 서비스 에이전트에 작동 서비스 계정을 가장할 수 있는 권한을 부여합니다.

    gcloud iam service-accounts add-iam-policy-binding "${ACTUATION_SA}" \
        --member="serviceAccount:${ALM_P4SA}" \
        --role="roles/iam.serviceAccountUser" \
        --condition=None
    
    gcloud iam service-accounts add-iam-policy-binding "${ACTUATION_SA}" \
        --member="serviceAccount:${ALM_P4SA}" \
        --role="roles/iam.serviceAccountTokenCreator" \
        --condition=None
    
    gcloud iam service-accounts add-iam-policy-binding "${ACTUATION_SA}" \
        --member="serviceAccount:${INFRA_MANAGER_P4SA}" \
        --role="roles/iam.serviceAccountUser" \
        --condition=None
    

고객을 위한 환경 배포

고객 환경을 만들고 전용 인프라 배포를 트리거합니다.

  1. 생성된 단위 종류를 사용하여 격리된 고객 테넌트를 나타내는 환경 Unit을 만듭니다.

    gcloud beta app-lifecycle-manager units create "tenant-1" \
        --location="us-central1" \
        --unit-kind="UNIT_KIND_ID"
    

    tenant-1를 테넌시 유닛 식별자로 바꿉니다.

  2. 단위 작업을 트리거하여 테넌트 인프라를 프로비저닝합니다.

    gcloud beta app-lifecycle-manager unit-operations create provision-tenant-1 \
        --location="us-central1" \
        --unit="projects/PROJECT_ID/locations/us-central1/units/tenant-1" \
        --provision \
        --provision-release="RELEASE_ID" \
        --provision-input-variables=variable=project_id,value="PROJECT_ID",type=string \
        --provision-input-variables=variable=project_number,value="${PROJECT_NUM}",type=string \
        --provision-input-variables=variable=actuation_sa,value="${ACTUATION_SA}",type=string \
        --provision-input-variables=variable=cloud-run-comp_project_id,value="PROJECT_ID",type=string \
        --provision-input-variables=variable=cloud-run-comp_region,value="us-central1",type=string \
        --provision-input-variables=variable=cloud-storage-comp_project_id,value="PROJECT_ID",type=string \
        --provision-input-variables=variable=cloud-storage-comp_region,value="us-central1",type=string
    
  3. SUCCEEDED에 도달할 때까지 프로비저닝 상태를 모니터링하는 단위 작업을 설명합니다.

    gcloud beta app-lifecycle-manager unit-operations describe provision-tenant-1 \
        --location="us-central1"
    

고객 환경 전반에서 업데이트 자동화

출시를 사용하여 모든 고객 환경에 애플리케이션 업데이트를 안전하게 배포합니다.

업데이트 전략 선택

모두 한 번에 배포하거나 단계별로 배포하는 등 업데이트가 고객 환경에 전달되는 방식을 정의합니다.

  1. RolloutKind를 만들어 단위의 조정 전략을 정의합니다.

    gcloud beta app-lifecycle-manager rollout-kinds create "progressive-rollout" \
        --location="us-central1" \
        --unit-kind="projects/PROJECT_ID/locations/us-central1/unitKinds/UNIT_KIND_ID" \
        --rollout-orchestration-strategy="Google.Cloud.Simple.AllAtOnce"
    

    progressive-rollout을 출시 종류 식별자로 바꿉니다.

업데이트 배포 및 추적

출시를 시작하고 배포가 완료될 때까지 진행 상황을 모니터링합니다.

  1. 롤아웃을 트리거하여 대상 테넌시 유닛에 출시 버전을 배포합니다.

    gcloud beta app-lifecycle-manager rollouts create "rollout-v1" \
        --location="us-central1" \
        --rollout-kind="projects/PROJECT_ID/locations/us-central1/rolloutKinds/progressive-rollout" \
        --release="projects/PROJECT_ID/locations/us-central1/releases/RELEASE_ID"
    

    rollout-v1를 출시 식별자로 바꿉니다.

  2. 출시를 설명하여 활성 실행을 검사하고 상태가 SUCCEEDED에 도달하는지 확인합니다.

    gcloud beta app-lifecycle-manager rollouts describe "rollout-v1" \
        --location="us-central1"
    

    출시 출력은 테넌시 유닛이 대상 템플릿 버전으로 업데이트되었음을 확인합니다.

삭제

이 튜토리얼에서 사용된 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 리소스가 포함된 프로젝트를 삭제하거나 프로젝트를 유지하고 개별 리소스를 삭제하세요.

프로젝트 삭제

Google Cloud 프로젝트 삭제:

gcloud projects delete PROJECT_ID

개별 리소스 삭제

기존 프로젝트에 튜토리얼 리소스를 배포한 경우 예기치 않은 청구를 방지하기 위해 종속 항목 역순으로 개별 리소스를 삭제합니다.

  1. 고객 환경 인프라를 프로비저닝 해제하고 완료될 때까지 기다립니다.

    gcloud beta app-lifecycle-manager unit-operations create deprovision-tenant-1 \
        --location="us-central1" \
        --unit="projects/PROJECT_ID/locations/us-central1/units/tenant-1" \
        --deprovision
    
    gcloud beta app-lifecycle-manager unit-operations describe deprovision-tenant-1 \
        --location="us-central1"
    
  2. App Lifecycle Manager 고객 환경을 삭제합니다.

    gcloud beta app-lifecycle-manager units delete "tenant-1" \
        --location="us-central1" \
        --quiet
    
  3. App Lifecycle Manager 출시 및 출시 버전 리소스를 역 종속 항목 순서로 삭제합니다.

    gcloud beta app-lifecycle-manager rollouts delete "rollout-v1" \
        --location="us-central1" \
        --quiet
    
    gcloud beta app-lifecycle-manager rollout-kinds delete "progressive-rollout" \
        --location="us-central1" \
        --quiet
    
    gcloud beta app-lifecycle-manager releases delete "RELEASE_ID" \
        --location="us-central1" \
        --quiet
    
    gcloud beta app-lifecycle-manager unit-kinds delete "UNIT_KIND_ID" \
        --location="us-central1" \
        --quiet
    
    gcloud beta app-lifecycle-manager saas delete "saas-run-storage" \
        --location="us-central1" \
        --quiet
    
  4. App Design Center 애플리케이션 템플릿, 카탈로그 항목, 스페이스를 삭제합니다.

    gcloud design-center spaces application-templates delete "run-storage-app" \
        --space="default-space" \
        --location="us-central1" \
        --force \
        --quiet
    
    gcloud design-center spaces catalogs templates delete "cloud-run-component" \
        --space="default-space" \
        --catalog="default-catalog" \
        --location="us-central1" \
        --force \
        --quiet
    
    gcloud design-center spaces catalogs templates delete "cloud-storage-component" \
        --space="default-space" \
        --catalog="default-catalog" \
        --location="us-central1" \
        --force \
        --quiet
    
    gcloud design-center spaces delete "default-space" \
        --location="us-central1" \
        --force \
        --quiet
    
  5. Developer Connect Git 저장소 링크 및 연결을 삭제합니다.

    gcloud developer-connect connections git-repository-links delete "GIT_REPO_LINK_ID" \
        --connection="CONNECTION_ID" \
        --location="us-central1" \
        --quiet
    
    gcloud developer-connect connections delete "CONNECTION_ID" \
        --location="us-central1" \
        --quiet
    
  6. 작동 서비스 계정을 삭제합니다.

    gcloud iam service-accounts delete "${ACTUATION_SA}" \
        --quiet
    

다음 단계