פריסת אפליקציה באמצעות App Lifecycle Manager

בעזרת App Lifecycle Manager אתם יכולים להגדיר אוטומציה לפריסה ולניהול של מחזור החיים של אפליקציות עם כמה רכיבים, וכך להקצות סביבות עקביות ב- Google Cloud. במדריך למתחילים הזה תתכננו תבנית של אפליקציה משולבת עם Cloud Run ו-Cloud Storage ב-Application Design Center, ואז תקצו יחידה פעילה.

לפני שמתחילים

  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 App Lifecycle Manager, Artifact Registry, Cloud Build, Cloud Run, Cloud Storage, Developer Connect, Infrastructure Manager, App Design Center, App Hub, 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. 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

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

  8. Enable the App Lifecycle Manager, Artifact Registry, Cloud Build, Cloud Run, Cloud Storage, Developer Connect, Infrastructure Manager, App Design Center, App Hub, 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

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

  10. נותנים לחשבון השירות של App Lifecycle Manager את ההרשאות הנדרשות:
    1. במסוף Google Cloud , נכנסים לדף App Lifecycle Manager‏ > Overview‏ > Get started.

      איך מתחילים לעבוד עם App Lifecycle Manager

    2. אם מופיע הבאנר עם ההודעה The required permissions for App Lifecycle Manager account haven't been granted, לוחצים על Grant permissions.

עיצוב המוצר באמצעות תבנית מורכבת

משתמשים ב-App Lifecycle Manager וב-Application Design Center כדי לעצב תבנית מורכבת (run-storage-quickstart) שמחברת בין שירות Cloud Run לקטגוריה של Cloud Storage.

הגדרת מוצר ה-SaaS

  1. במסוף Google Cloud , נכנסים אל App Lifecycle Manager ‏> SaaS offering.

    מעבר למוצר SaaS

  2. לוחצים על יצירה.

  3. בשדה SaaS offering name, מזינים run-storage-quickstart-offering.

  4. ברשימה Region, בוחרים את האזורים הבאים ולוחצים על OK:

    • us-central1
    • us-east1
    • us-east5
  5. לוחצים על יצירה. יצירת run-storage-quickstart-offering נמשכת כמה דקות.

    אחרי שיוצרים את מוצר ה-SaaS, נפתח הדף SaaS offering details.

יצירת תבנית מורכבת

  1. בדף SaaS offering details, לוחצים על Create new template.
  2. בדף Create a new composite template, מגדירים את התבנית:

    1. בשדה Template ID, מזינים את הערך run-storage-quickstart.
    2. לוחצים על יצירת תבנית.

      כשהכלי App Lifecycle Manager מסיים ליצור את התבנית המורכבת, הפרטים שלה מופיעים בקטע Connected application template בדף SaaS offering details.

  3. בקטע Connected application template, לוחצים על Manage template ואז על Configure in canvas.

    הכלי App Design Center נפתח במסוף Google Cloud .

  4. באזור Components, מוסיפים את הרכיבים הבאים לאזור העריכה:

    1. לוחצים על Cloud Run (Service) כדי להוסיף רכיב cloud-run-1 לאזור השרטוט.
    2. לוחצים על Cloud Storage כדי להוסיף רכיב cloud-storage-1 לאזור העריכה.
  5. ב-canvas, גוררים מהרכיב cloud-run-1 לרכיב cloud-storage-1 כדי ליצור חיבור.

    כשמחברים את הרכיבים, חשבון השירות של Cloud Run מועבר לקישור של קטגוריית Cloud Storage ב-IAM עם התפקיד roles/storage.objectAdmin.

  6. ב-canvas, לוחצים על הרכיב cloud-run-1 כדי לפתוח את החלונית Configuration:

    1. באזור Containers (מאגרי תגים), מרחיבים את Container 1 (מאגר תגים 1).
    2. בשדה Container Image, מזינים את קובץ האימג' של קונטיינר הציבורי לדוגמה us-docker.pkg.dev/cloudrun/container/hello:latest.
    3. לוחצים על Save.
  7. לוחצים על המשך > פריסה בקנה מידה נרחב באמצעות App Lifecycle Manager.

    ‫App Lifecycle Manager נפתח במסוף Google Cloud .

  8. בקטע Connected application template, לוחצים על Update template revision.

  9. בדף Update template revision, בוחרים באפשרות r-2 ברשימה Revision ולוחצים על Update.

    בקטע Connected application template מופיע הכיתוב Importing Application Template. בסיום הייבוא, סוג היחידה u-native-components שנוצר מופיע בכרטיסייה Unit kinds.

הקצאת האפליקציה באמצעות App Lifecycle Manager

  1. בדף SaaS offering details של run-storage-quickstart-offering, לוחצים על Provision.

    הדף הקצאה נפתח.

  2. בדף Provision, בוחרים את us-central1 ברשימה Region ולוחצים על Add.

  3. בחלונית הוספת יחידה להקצאה, מגדירים את היחידה:

    1. בשדה Unit name, מזינים run-storage-quickstart-unit-1.
    2. ברשימה Unit kind, בוחרים את סוג היחידה u-native-components.
    3. ברשימה Release, בוחרים את הגרסה שנוצרה לגרסת התבנית.
    4. ברשימה Service account, בוחרים את חשבון השירות לביצוע פעולות שיצרתם בקטע לפני שמתחילים. ‫Infra Manager משתמש בחשבון השירות הזה כדי להקצות את שירות Cloud Run ואת הקטגוריה של Cloud Storage.
  4. לוחצים על Add tenant project variables ובוחרים את הפרויקט שבו App Lifecycle Manager משתמש כדי להקצות את המשאבים.

  5. באזור Other input variables, לוחצים על Add input variable ומזינים ערכים למשתני הקלט הבאים של הרכיב:

    • ‫Name: cloud-run-1_project_id, ‏Variable type: String, ו-Variable value: מזהה הפרויקט
    • שם: cloud-run-1_location, סוג המשתנה: String, וגם ערך המשתנה: us-central1
    • שם: cloud-run-1_service_name, סוג המשתנה: String, וגם ערך המשתנה: quickstart-web
    • ‫Name: cloud-storage-1_project_id, ‏Variable type: String, ו-Variable value: מזהה הפרויקט
    • שם: cloud-storage-1_location, סוג המשתנה: String, וגם ערך המשתנה: us-central1
    • Name: cloud-storage-1_name, Variable type: String, ו-Variable value: שם קטגוריה ייחודי באופן גלובלי, כמו PROJECT_ID-quickstart-bkt
  6. לוחצים על הוספה. היחידה run-storage-quickstart-unit-1 מופיעה בטבלה יחידות להקצאה.

  7. לוחצים על Provision כדי לפרוס את run-storage-quickstart-unit-1.

    ההקצאה של שירות Cloud Run וקטגוריה של Cloud Storage נמשכת כמה דקות.

  8. כדי להקצות יחידות נוספות באזורים אחרים, בוחרים את האזור מהרשימה Region ולוחצים על Add.

הצגת היחידה שנפרסה

מוודאים ש-App Lifecycle Manager הקצה את היחידה ואת המשאבים שלה.

  1. במסוף Google Cloud , נכנסים לדף App Lifecycle Manager ‏> Units.

    מעבר אל "יחידות"

  2. לוחצים על run-storage-quickstart-unit-1 כדי לפתוח את הדף Unit details.

  3. בדף Unit details, בודקים את השדה State:

    • ‫Ready: השירות של Cloud Run והקטגוריה של Cloud Storage הוקצו.
    • הקצאה: פעולת הפריסה עדיין מתבצעת.

הסרת המשאבים

כדי לא לצבור חיובים בחשבון Google Cloud על המשאבים שבהם השתמשתם בדף הזה, מבצעים את הפעולות הבאות.

מחיקת הפרויקט

אם פרסתם את משאבי האפליקציה בפרויקט Google Cloud חדש ואתם לא צריכים יותר את הפרויקט, אתם יכולים למחוק אותו:

  1. במסוף Google Cloud , נכנסים לדף Manage resources.

    כניסה לדף Manage resources

  2. ברשימת הפרויקטים, בוחרים את הפרויקט שרוצים למחוק ולוחצים על Delete.
  3. בהודעה שמופיעה, מזינים את מזהה הפרויקט ולוחצים על Shut down.

המאמרים הבאים