הכנות להגדרת Gateway API ל-Cloud Service Mesh

בדף הזה מוסבר איך להתקין באשכול את ההגדרות הנדרשות של משאבים מותאמים אישית עבור השער.

מגבלות

  • אין תמיכה בשילוב של אשכולות gateway config-api ו-istio config-api באותו צי.
  • אין תמיכה בגילוי שירותים ובאיזון עומסים בין אשכולות ב-gateway config-api clusters.
  • אם מצטרפים לאשכול באמצעות הדגל --management automatic הקיים, האשכול מתחיל להשתמש ב-API של התצורה istio ולא ניתן לשנות אותו ל-API ‏gateway.
  • יש תמיכה רק בשמות דומיין מלאים (FQDN). אין תמיכה בשמות מקוצרים.

דרישות מוקדמות

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

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

  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 Kubernetes Engine, GKE Hub, and Cloud Service Mesh 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. 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

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

  7. Enable the Kubernetes Engine, GKE Hub, and Cloud Service Mesh 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

  1. יוצרים רשומה ב-kubeconfig עבור האשכול:
  2. gcloud container clusters get-credentials CLUSTER_NAME --location LOCATION --project PROJECT_ID
    

where:

  • CLUSTER_NAME הוא שם האשכול
  • LOCATION הוא המיקום של האשכול
  • PROJECT_ID הוא מזהה הפרויקט של האשכול

יצירה ורישום של אשכול GKE

  1. יוצרים אשכול GKE:

    gcloud container clusters create CLUSTER_NAME \
    --location=LOCATION \
    --enable-ip-alias \
    --scopes=https://www.googleapis.com/auth/cloud-platform \
    --release-channel=regular \
    --project=PROJECT_ID \
    --gateway-api=standard
    

    where:

    • CLUSTER_NAME הוא שם האשכול
    • LOCATION הוא המיקום של האשכול
    • PROJECT_ID הוא מזהה הפרויקט של האשכול
  2. הפעלת איחוד שירותי אימות הזהות של עומסי העבודה ב-GKE:

    gcloud container clusters update CLUSTER_NAME \
    --location LOCATION \
    --workload-pool=PROJECT_ID.svc.id.goog
    
  3. מריצים את שרת המטא-נתונים של GKE בצומת:

    gcloud container node-pools update default-pool \
    --cluster=CLUSTER_NAME \
    --location=LOCATION \
    --workload-metadata=GKE_METADATA
    
  4. רישום האשכול לFleet:

    gcloud container hub memberships register CLUSTER_NAME \
    --gke-cluster LOCATION/CLUSTER_NAME \
    --project=PROJECT_ID
    
  5. מוודאים שהאשכול רשום ב-Fleet:

    gcloud container hub memberships list --project=PROJECT_ID
    

    הפלט אמור להיראות כך:

    NAME            EXTERNAL_ID                             LOCATION
    my-cluster      91980bb9-593c-4b36-9170-96445c9edd39    us-west1
    

הגדרת ההרשאות

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

  1. הקצאת התפקיד trafficdirector.client:

    gcloud projects add-iam-policy-binding PROJECT_ID \
        --member "group:PROJECT_ID.svc.id.goog:/allAuthenticatedUsers/" \
        --role "roles/trafficdirector.client"
    
  2. הקצאת התפקיד container.developer:

    gcloud projects add-iam-policy-binding PROJECT_ID \
    --member "serviceAccount:service-PROJECT_NUMBER@container-engine-robot.iam.gserviceaccount.com" \
    --role "roles/container.developer"
    

    כאשר PROJECT_NUMBER הוא מספר הפרויקט.

  3. הקצאת התפקיד compute.networkAdmin:

    gcloud projects add-iam-policy-binding PROJECT_ID \
    --member "serviceAccount:service-PROJECT_NUMBER@container-engine-robot.iam.gserviceaccount.com" \
    --role "roles/compute.networkAdmin"
    

    כאשר PROJECT_NUMBER הוא מספר הפרויקט.

הפעלת Cloud Service Mesh

  1. כדי להפעיל את התכונה 'רשת':

    gcloud container hub mesh enable --project PROJECT_ID
    
  2. מעדכנים את הרשת לשימוש ב-Gateway API:

    gcloud alpha container fleet mesh update \
    --config-api gateway \
    --memberships CLUSTER_NAME \
    --project PROJECT_ID
    
  3. כדי לוודא שהעדכון בוצע, מתארים את הסטטוס של משאב Cloud Service Mesh:

    gcloud alpha container fleet mesh describe
    

התקנה של הגדרות מותאמות אישית של משאבים

מתקינים את ההגדרה של המשאב המותאם אישית (CRD) של GRPCRoute:

curl https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v1.1.0/config/crd/standard/gateway.networking.k8s.io_grpcroutes.yaml \
| kubectl apply -f -

הפלט אמור להיראות כך:

customresourcedefinition.apiextensions.k8s.io/grpcroutes.gateway.networking.k8s.io created

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