פריסת אפליקציה באמצעות App Lifecycle Manager
בעזרת App Lifecycle Manager אתם יכולים להפוך את הפריסה והניהול של מחזור החיים של אפליקציות עם כמה רכיבים לאוטומטיים, וכך להקצות סביבות עקביות ב- Google Cloud. במדריך למתחילים הזה תלמדו איך ליצור מודל של תבנית לאפליקציה מורכבת באמצעות Cloud Run ו-Cloud Storage ב-Application Design Center, ואז להקצות יחידה פעילה.
לפני שמתחילים
-
נכנסים לחשבון Google.
אם עדיין אין חשבון, יוצרים חשבון חדש.
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
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.enablepermission. 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.-
Create a service account:
-
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. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
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. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
-
Ensure that you have the Create Service Accounts IAM role
(
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
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.enablepermission. 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.-
Create a service account:
-
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. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
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. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
-
Ensure that you have the Create Service Accounts IAM role
(
- נותנים לחשבון השירות של App Lifecycle Manager את ההרשאות הנדרשות:
במסוף Google Cloud , נכנסים לדף App Lifecycle Manager > Overview > Get started.
- אם מופיע הבאנר עם ההודעה 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
במסוף Google Cloud , נכנסים אל App Lifecycle Manager > SaaS offering.
לוחצים על יצירה.
בשדה SaaS offering name, מזינים
run-storage-quickstart-offering.ברשימה Region, בוחרים את האזורים הבאים ולוחצים על OK:
us-central1us-east1us-east5
לוחצים על יצירה. יצירת
run-storage-quickstart-offeringנמשכת כמה דקות.אחרי שיוצרים את מוצר ה-SaaS, נפתח הדף SaaS offering details.
יצירת תבנית מורכבת
- בדף SaaS offering details, לוחצים על Create new template.
בדף Create a new composite template, מגדירים את התבנית:
- בשדה Template ID, מזינים
run-storage-quickstart. לוחצים על יצירת תבנית.
כשהכלי App Lifecycle Manager מסיים ליצור את התבנית המורכבת, הפרטים שלה מופיעים בקטע Connected application template בדף SaaS offering details.
- בשדה Template ID, מזינים
בקטע Connected application template, לוחצים על Manage template ואז על Configure in canvas.
App Design Center נפתח במסוף Google Cloud .
באזור Components, מוסיפים את הרכיבים הבאים לאזור העריכה:
- לוחצים על Cloud Run (Service) כדי להוסיף רכיב
cloud-run-1לאזור השרטוט. - לוחצים על Cloud Storage כדי להוסיף רכיב
cloud-storage-1לאזור העריכה.
- לוחצים על Cloud Run (Service) כדי להוסיף רכיב
ב-canvas, גוררים מהרכיב cloud-run-1 לרכיב cloud-storage-1 כדי ליצור חיבור.
כשמחברים את הרכיבים, חשבון השירות של Cloud Run מועבר לקישור ה-IAM של קטגוריה של Cloud Storage עם התפקיד
roles/storage.objectAdmin.לוחצים על הרכיב cloud-run-1 כדי לפתוח את החלונית Configuration:
- באזור Containers (מאגרי תגים), מרחיבים את Container 1 (מאגר תגים 1).
- בשדה Container Image, מזינים את קובץ האימג' של קונטיינר הציבורי לדוגמה
us-docker.pkg.dev/cloudrun/container/hello:latest. - לוחצים על Save.
לוחצים על המשך > פריסה בקנה מידה נרחב באמצעות App Lifecycle Manager.
הכלי App Lifecycle Manager נפתח במסוף Google Cloud .
בקטע Connected application template, לוחצים על Update template revision.
בדף Update template revision, בוחרים באפשרות
r-2ברשימה Revision ולוחצים על Update.בקטע Connected application template מוצג הכיתוב Importing Application Template. בסיום הייבוא, סוג היחידה
u-native-componentsשנוצר מופיע בכרטיסייה Unit kinds.
הקצאת האפליקציה באמצעות App Lifecycle Manager
בדף SaaS offering details של
run-storage-quickstart-offering, לוחצים על Provision.הדף הקצאה ידנית נפתח.
בדף Provision, בוחרים את
us-central1ברשימה Region ולוחצים על Add.בחלונית הוספת יחידה להקצאה, מגדירים את היחידה:
- בשדה Unit name, מזינים
run-storage-quickstart-unit-1. - ברשימה Unit kind, בוחרים את סוג היחידה
u-native-components. - ברשימה Release, בוחרים את הגרסה שנוצרה לגרסת התבנית.
- ברשימה Service account, בוחרים את חשבון השירות לסימולציה שיצרתם בקטע לפני שמתחילים.
- בשדה Unit name, מזינים
לוחצים על Add tenant project variables ובוחרים את הפרויקט שישמש להקצאת המשאבים.
באזור 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
- Name:
לוחצים על הוספה. היחידה
run-storage-quickstart-unit-1מופיעה בטבלה יחידות להקצאה.לוחצים על הקצאה כדי לפרוס את
run-storage-quickstart-unit-1.ההקצאה של שירות Cloud Run ו-Cloud Storage מסתיימת אחרי כמה דקות.
כדי להקצות יחידות נוספות באזורים אחרים, בוחרים את האזור מהרשימה Region ולוחצים על Add.
הצגת היחידה שנפרסה
מוודאים ש-App Lifecycle Manager הקצה את היחידה והמשאבים שלה.
במסוף Google Cloud , נכנסים לדף App Lifecycle Manager > Units.
לוחצים על
run-storage-quickstart-unit-1כדי לפתוח את הדף Unit details.בדף Unit details, בודקים את השדה State:
- Ready: השירות של Cloud Run והקטגוריה של Cloud Storage הוקצו.
- הקצאה: פעולת הפריסה עדיין מתבצעת.
הסרת המשאבים
כדי לא לצבור חיובים בחשבון Google Cloud על המשאבים שבהם השתמשתם בדף הזה, מבצעים את הפעולות הבאות.
מחיקת הפרויקט
אם פרסתם את משאבי האפליקציה בפרויקט חדש ב- Google Cloud ואתם לא צריכים יותר את הפרויקט, אתם יכולים למחוק אותו:
- במסוף Google Cloud , נכנסים לדף Manage resources.
- ברשימת הפרויקטים, בוחרים את הפרויקט שרוצים למחוק ולוחצים על Delete.
- בהודעה שמופיעה, מקלידים את מזהה הפרויקט ולוחצים על Shut down.
המאמרים הבאים
- במדריך תכנון ופריסה של מוצרי SaaS מוסבר איך לייבא ולפרוס רכיבי Terraform בהתאמה אישית.
- סקירה כללית על App Lifecycle Manager
- כדי להתחיל להשתמש ב-App Lifecycle Manager, קודם צריך ליצור מוצר SaaS.
- במאמר חשבונות שירות של App Lifecycle Manager מוסבר איך משתמשים בחשבונות שירות ואיך נותנים את ההרשאות הנדרשות לחשבונות האלה.
- במאמר עדכון מוצר SaaS מוסבר איך לעדכן את הגרסה.