אימות האפליקציה אחרי הפריסה

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

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

  1. יוצרים אשכול GKE אחד או שירות Cloud Run אחד.

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

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

    צינור ההפצה כולל שלב אחד בלבד ומשתמש רק ביעד אחד. מגדירים את התצורה של אימות הפריסה בקטע stage.

  3. יוצרים הגדרת Skaffold שנדרשת לגרסה, ומניפסט של Kubernetes או הגדרת שירות של Cloud Run.

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

    אחרי פריסת האפליקציה, האימות מופעל כשלב בתהליך ההשקה.

  5. אפשר לראות את תוצאות האימות ביומני Cloud Build, באמצעות הדף Rollout details של Cloud Deploy במסוף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. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Cloud Deploy, Cloud Build, GKE, 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

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

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

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

    gcloud init
  8. 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

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

  10. Enable the Cloud Deploy, Cloud Build, GKE, 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

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

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

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

    gcloud init
  14. אם ה-CLI כבר מותקן, צריך לוודא שאתם מריצים את הגרסה העדכנית:

    gcloud components update
    

  15. מוודאים שלחשבון השירות שמשמש כברירת מחדל ב-Compute Engine יש הרשאות מספיקות.

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

    1. קודם מוסיפים את התפקיד clouddeploy.jobRunner:

      gcloud projects add-iam-policy-binding PROJECT_ID \
          --member=serviceAccount:$(gcloud projects describe PROJECT_ID \
          --format="value(projectNumber)")-compute@developer.gserviceaccount.com \
          --role="roles/clouddeploy.jobRunner"
      

    2. מוסיפים את תפקיד המפתח לזמן הריצה הספציפי.
      • ב-GKE:

        gcloud projects add-iam-policy-binding PROJECT_ID \
            --member=serviceAccount:$(gcloud projects describe PROJECT_ID \
            --format="value(projectNumber)")-compute@developer.gserviceaccount.com \
            --role="roles/container.developer"
        

      • ל-Cloud Run:

        gcloud projects add-iam-policy-binding PROJECT_ID \
            --member=serviceAccount:$(gcloud projects describe PROJECT_ID \
            --format="value(projectNumber)")-compute@developer.gserviceaccount.com \
            --role="roles/run.developer"
        

    3. מוסיפים את התפקיד iam.serviceAccountUser, שכולל את ההרשאה actAs לפריסה בסביבת זמן הריצה: