פריסת אפליקציה ב-Cloud Run באמצעות Cloud Deploy

בדף הזה מוסבר איך להשתמש ב-Cloud Deploy כדי להעביר תמונה של אפליקציה לדוגמה בשם hello לרצף של שני שירותי Cloud Run, שתי משימות Cloud Run או שני מאגרי עובדים של Cloud Run.

במדריך למתחילים הזה תבצעו את הפעולות הבאות:

  1. יצירת הגדרה של Skaffold

  2. יוצרים קובצי הגדרות לשני שירותים של Cloud Run, לשתי משימות או לשני מאגרי עובדים.

    הקבצים האלה מגדירים את השירותים או המשימות, ומציינים את תמונות המאגר (שנוצרו מראש) לפריסה.

  3. מגדירים את צינור העברת הנתונים ואת יעדי הפריסה של Cloud Deploy, שמפנים לשני השירותים, לשתי המשימות או לשני מאגרי העובדים.

  4. יוצרים מהדורת הפצה כדי ליצור מופע של צינור ההפצה. המהדורה הזו נפרסת אוטומטית ליעד הראשון.

  5. מקדמים את הגרסה ליעד השני.

  6. אפשר לראות את שתי ההשקות במסוף Google Cloud .

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

  1. נכנסים לחשבון Google Cloud . אם אתם משתמשים חדשים ב- Google Cloud, צרו חשבון כדי שתוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 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. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

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

  5. Enable the Cloud Deploy, Cloud Build, Cloud Run, and Cloud Storage APIs.

    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

  6. התקינו את ה-CLI של Google Cloud.

  7. אם אתם משתמשים בספק זהויות חיצוני (IdP), קודם אתם צריכים להיכנס ל-CLI של gcloud באמצעות המאגר המאוחד לניהול זהויות.

  8. כדי לאתחל את ה-CLI של gcloud, הריצו את הפקודה הבאה:

    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. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

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

  12. Enable the Cloud Deploy, Cloud Build, Cloud Run, and Cloud Storage APIs.

    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

  13. התקינו את ה-CLI של Google Cloud.

  14. אם אתם משתמשים בספק זהויות חיצוני (IdP), קודם אתם צריכים להיכנס ל-CLI של gcloud באמצעות המאגר המאוחד לניהול זהויות.

  15. כדי לאתחל את ה-CLI של gcloud, הריצו את הפקודה הבאה:

    gcloud init

התפקידים הנדרשים

כדי לוודא שלחשבון השירות של Cloud Deploy יש את ההרשאות הנדרשות להפעלת פעולות של Cloud Deploy ולפריסה ב-Cloud Run, צריך לבקש מהאדמין להקצות לחשבון השירות של Cloud Deploy את תפקידי ה-IAM הבאים בפרויקט:

להסבר על מתן תפקידים, ראו איך מנהלים את הגישה ברמת הפרויקט, התיקייה והארגון.

יכול להיות שהאדמין גם יוכל לתת לחשבון השירות של Cloud Deploy את ההרשאות שנדרשות באמצעות תפקידים בהתאמה אישית או תפקידים מוגדרים מראש אחרים.

הכנת הגדרות Skaffold

‫Cloud Deploy משתמש ב-Skaffold כדי לספק את הפרטים לגבי מה לפרוס ואיך לפרוס אותו בצורה נכונה עבור יעדים נפרדים.

במדריך למתחילים הזה יוצרים קובץ skaffold.yaml שמזהה את שירות Cloud Run או את הגדרת המשימה שבהם יש להשתמש כדי לפרוס את האפליקציה לדוגמה.

  1. פותחים חלון טרמינל.