פריסת מכונה של MySQL באמצעות App Lifecycle Manager

איך פורסים מופע של Cloud SQL באמצעות App Lifecycle Manager

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

  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 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. נותנים לחשבון השירות App Lifecycle Manager את ההרשאות הנדרשות:
    1. עוברים אל App Lifecycle Manager > Overview Get started.

      איך מתחילים להשתמש ב-App Lifecycle Manager

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

יצירת מודל של מוצר Cloud SQL באמצעות תבנית מורכבת

בקטע הזה תשתמשו ב-App Lifecycle Manager כדי ליצור מודל של תבנית מורכבת (sql-quickstart-template) שמורכבת ממכונה של Cloud SQL באמצעות Application Design Center.

  1. במסוף Google Cloud , עוברים אל App Lifecycle Manager > הצעת האפליקציה.

    מעבר אל "מוצר האפליקציה"

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

  3. בשדה שם האפליקציה, מקלידים: my-sql-quickstart-saas-offering.

  4. בתפריט הנפתח Region, בוחרים את האזורים:

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

    לוחצים על אישור.

  5. לוחצים על יצירה. יכול להיות שיחלפו כמה דקות עד שmy-sql-quickstart-saas-offering ייווצר.

    נפתח הדף פרטי המוצר של האפליקציה.

  6. בדף פרטי האפליקציה, לוחצים על יצירת תבנית חדשה.

  7. בדף Create a new composite template (יצירת תבנית מורכבת חדשה):

    1. בתיבה Template ID (מזהה התבנית), מזינים sql-quickstart-template.
    2. לוחצים על יצירת תבנית. יחלפו כמה דקות עד שכלי App Lifecycle Manager ייצור את התבנית המורכבת.

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

  8. בקטע Connected application template (תבנית של אפליקציה מקושרת), עוברים אל Manage template (ניהול התבנית) > Configure in canvas (הגדרה באזור העריכה).

    מרכז עיצוב האפליקציות ייפתח בחלון המסוף Google Cloud .

  9. באזור רכיבים, מוצאים את התבנית Cloud SQL (My SQL) ולוחצים עליה.

    רכיב Cloud SQL (My SQL) נוסף לאזור העריכה.

  10. לוחצים על המשך > פריסה בהיקף נרחב באמצעות App Lifecycle Manager.

    App Lifecycle Manager נפתח בחלון המסוף של Google Cloud .

  11. בקטע Connected application template (תבנית של אפליקציה מקושרת), לוחצים על Update template revision (עדכון של גרסת התבנית).

  12. בדף Update template revision, בוחרים באפשרות r-2 בתפריט הנפתח Revision.

  13. לוחצים על עדכון. בקטע Connected application template מופיע הכיתוב Importing Application Template.

    יכול להיות שיעברו כמה דקות עד ש-App Lifecycle Manager ייבא את גרסת התבנית. כשהייבוא של הגרסה יסתיים, רשימת סוגי היחידות תופיע בכרטיסייה Unit kinds.

הקצאת מכונה של Cloud SQL באמצעות App Lifecycle Manager

בקטע הזה, יוצרים יחידה (my-sql-quickstart-unit) ומקצים לה מכונת Cloud SQL באזור us-central1.

  1. בדף פרטי האפליקציה של my-sql-quickstart-saas-offering, לוחצים על הקצאה.

    הדף Provision נפתח.

  2. בדף Provision, בוחרים באפשרות us-central1 בתפריט הנפתח Region.

    לוחצים על הוספה כדי להוסיף יחידה לאפליקציה.

  3. בחלונית הוספת יחידה להקצאה:

    1. בתיבה Unit name, מקלידים my-sql-quickstart-unit-1.
    2. בתפריט הנפתח Unit kind, בוחרים את סוג היחידה sql-quickstart-template.
    3. בתפריט הנפתח גרסה, בוחרים באפשרות (r-3).
    4. בתפריט הנפתח Service account, בוחרים את חשבון השירות שיצרתם בקטע לפני שמתחילים.
  4. לוחצים על הוספת משתנים של פרויקט דייר.

    1. בוחרים את הפרויקט כדי להקצות את המשאבים.
  5. בקטע Other input variables (משתני קלט אחרים) בחלונית Add unit to provision (הוספת יחידה להקצאה):

    1. לוחצים על התפריט הנפתח sql-my-sql-1_database_version.

      • בתיבה ערך המשתנה, מקלידים MYSQL_8_0.

      לוחצים על סיום.

    2. לוחצים על התפריט הנפתח sql-my-sql-1_name.

      • בתיבה ערך המשתנה, מקלידים my-sql-db-1.

      לוחצים על סיום.

    3. לוחצים על התפריט הנפתח sql-my-sql-1_project_id.

      • בתיבה Variable value, מקלידים את מזהה הפרויקט.

      לוחצים על סיום.

    4. לוחצים על התפריט הנפתח sql-my-sql-1_region.

      • בתיבה Variable value, מקלידים us-central1.

      לוחצים על סיום.

    לוחצים על הוספה. הערך my-sql-quickstart-unit-1 יופיע בטבלה Units to be provisioned.

  6. לוחצים על Provision כדי להקצות את my-sql-quickstart-unit-1, שיצור מכונה פעילה של Cloud SQL בחבילת האפליקציות שלכם.

    יכול להיות שיחלפו כמה דקות עד ש-App Lifecycle Manager יקצה את my-sql-quickstart-unit-1.

צפייה במכונה של Cloud SQL שנפרסה

עכשיו השתמשתם ב-App Lifecycle Manager כדי לפרוס מכונה של Cloud SQL.

כדי לראות את המכונה של Cloud SQL שפרסתם במדריך למתחילים הזה:

  1. במסוף Google Cloud , עוברים אל App Lifecycle Manager > Units > Unit details.

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

  2. לוחצים על השם של היחידה: my-sql-quickstart-unit-1.

  3. בדף פרטי היחידה:

    1. מוודאים שהערך של State הוא:

      • Ready אם המכונה של Cloud SQL הוקצתה.
      • הקצאת הרשאות אם הפעולה עדיין מתבצעת.

הסרת המשאבים

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

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

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

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

    כניסה לדף Manage resources

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

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