Men-deploy instance MySQL dengan App Lifecycle Manager

Pelajari cara men-deploy instance Cloud SQL menggunakan App Lifecycle Manager.

Sebelum memulai

  1. Login ke Akun Google Anda.

    Jika Anda belum memilikinya, Daftar untuk membuat akun baru.

  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 App Lifecycle Manager, Artifact Registry, Cloud Build, Cloud Storage, Developer Connect, Infrastructure Manager, Design Center, App Hub, Cloud Resource Manager, Identity and Access Management, Cloud Asset Inventory, Cloud Monitoring, Cloud Logging, and Service Health 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. 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. Install the Google Cloud CLI.

  7. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  8. To initialize the gcloud CLI, run the following command:

    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 App Lifecycle Manager, Artifact Registry, Cloud Build, Cloud Storage, Developer Connect, Infrastructure Manager, Design Center, App Hub, Cloud Resource Manager, Identity and Access Management, Cloud Asset Inventory, Cloud Monitoring, Cloud Logging, and Service Health 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

  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. Install the Google Cloud CLI.

  14. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  15. To initialize the gcloud CLI, run the following command:

    gcloud init
  16. Berikan izin yang diperlukan kepada akun layanan App Lifecycle Manager:
    1. Buka App Lifecycle Manager > Ringkasan Mulai.

      Buka Mulai menggunakan App Lifecycle Manager

    2. Di banner dengan pesan Izin yang diperlukan untuk akun App Lifecycle Manager belum diberikan, klik Berikan izin.

Membuat model penawaran Cloud SQL Anda menggunakan template komposit

Di bagian ini, Anda akan menggunakan App Lifecycle Manager untuk memodelkan template komposit (sql-quickstart-template) yang terdiri dari instance Cloud SQL menggunakan Application Design Center.

  1. Di konsol Google Cloud , buka App Lifecycle Manager > Penawaran aplikasi.

    Buka Penawaran aplikasi

  2. Klik Create.

  3. Di kolom Nama penawaran Aplikasi, ketik: my-sql-quickstart-saas-offering.

  4. Di drop-down Region, pilih region:

    • us-central1
    • us-east1
    • us-east5

    Klik Ok.

  5. Klik Create. Mungkin perlu waktu beberapa menit untuk membuat my-sql-quickstart-saas-offering.

    Halaman Detail penawaran aplikasi akan terbuka.

  6. Di halaman Detail penawaran aplikasi, klik Buat template baru.

  7. Di halaman Create a new composite template:

    1. Di kotak Template ID, masukkan sql-quickstart-template.
    2. Klik Create template. App Lifecycle Manager akan memerlukan waktu beberapa menit untuk membuat template gabungan.

      Setelah App Lifecycle Manager berhasil membuat template, Anda akan melihat detailnya di bagian Connected application template pada halaman App offering details.

  8. Di bagian Template aplikasi terhubung, buka Kelola template > Konfigurasi di kanvas.

    App Design Center akan terbuka di jendela konsol Google Cloud .

  9. Di area Components, temukan dan klik template Cloud SQL (My SQL).

    Komponen Cloud SQL (MySQL) ditambahkan ke kanvas.

  10. Klik Lanjutkan > Deploy dalam skala besar dengan App Lifecycle Manager.

    App Lifecycle Manager akan terbuka di jendela konsol Google Cloud .

  11. Di bagian Connected application template, klik Update template revision.

  12. Di halaman Update template revision, pilih r-2 di drop-down Revision.

  13. Klik Update. Bagian Connected application template menampilkan Importing Application Template.

    Mungkin perlu waktu beberapa menit bagi App Lifecycle Manager untuk mengimpor revisi template. Setelah revisi selesai diimpor, Anda akan melihat daftar jenis unit yang diisi di tab Jenis unit.

Menyediakan instance Cloud SQL menggunakan App Lifecycle Manager

Di bagian ini, Anda akan membuat dan menyediakan unit (my-sql-quickstart-unit) dengan instance Cloud SQL di region us-central1.

  1. Di halaman App offering details di my-sql-quickstart-saas-offering, klik Provision.

    Halaman Provision akan terbuka.

  2. Di halaman Provision, pilih us-central1 di drop-down Region.

    Klik Tambahkan untuk menambahkan unit ke penawaran Aplikasi Anda.

  3. Di panel Add unit to provision:

    1. Di kotak Unit name, ketik my-sql-quickstart-unit-1.
    2. Di menu drop-down Unit kind, pilih jenis unit sql-quickstart-template.
    3. Di drop-down Release, pilih (r-3).
    4. Di menu drop-down Service account, pilih akun layanan yang Anda buat di bagian Sebelum memulai.
  4. Klik Tambahkan variabel project tenant.

    1. Pilih project Anda untuk menyediakan resource.
  5. Di bagian Other input variables pada panel Add unit to provision:

    1. Klik drop-down sql-my-sql-1_database_version.

      • Di kotak Variable value, ketik MYSQL_8_0.

      Klik Done.

    2. Klik drop-down sql-my-sql-1_name.

      • Di kotak Variable value, ketik my-sql-db-1.

      Klik Done.

    3. Klik drop-down sql-my-sql-1_project_id.

      • Di kotak Nilai variabel, ketik project ID Anda.

      Klik Done.

    4. Klik drop-down sql-my-sql-1_region.

      • Di kotak Variable value, ketik us-central1.

      Klik Done.

    Klik Tambahkan. Anda akan melihat my-sql-quickstart-unit-1 di tabel Unit yang akan disediakan.

  6. Klik Sediakan untuk menyediakan my-sql-quickstart-unit-1 yang akan membuat instance Cloud SQL aktif di penawaran Aplikasi Anda.

    Mungkin perlu waktu beberapa menit hingga App Lifecycle Manager menyediakan my-sql-quickstart-unit-1.

Melihat instance Cloud SQL yang di-deploy

Sekarang Anda telah menggunakan App Lifecycle Manager untuk men-deploy instance Cloud SQL.

Untuk melihat instance Cloud SQL yang Anda deploy dalam panduan memulai ini:

  1. Di konsol Google Cloud , buka halaman App Lifecycle Manager > Units > Unit details.

    Buka Unit

  2. Klik nama unit Anda: my-sql-quickstart-unit-1.

  3. Di halaman Detail unit:

    1. Pastikan State adalah:

      • Ready jika instance Cloud SQL disediakan.
      • Provisioning jika operasi masih berlangsung.

Pembersihan

Agar akun Google Cloud Anda tidak dikenai biaya untuk resource yang digunakan pada halaman ini, ikuti langkah-langkah berikut.

Menghapus project

Jika Anda men-deploy instance Cloud SQL di project Google Cloud baru, dan tidak lagi memerlukan project tersebut, hapus dengan melakukan langkah-langkah berikut:

  1. Di konsol Google Cloud , buka halaman Manage resources.

    Buka Kelola resource

  2. Pada daftar project, pilih project yang ingin Anda hapus, lalu klik Hapus.
  3. Pada layar perintah, ketik project ID, lalu klik Matikan.

Langkah berikutnya