יצירת אילוצים מותאמים אישית

Google Cloud מדיניות הארגון מאפשרת לכם שליטה מרוכזת ופרוגרמטית על המשאבים של הארגון. אדמינים של מדיניות הארגון יכולים להגדיר מדיניות ארגונית, שהיא קבוצה של הגבלות שנקראות אילוצים, שחלות על משאביGoogle Cloud ועל משאבים שנגזרים מהם בGoogle Cloud היררכיית המשאבים. אפשר לאכוף את מדיניות הארגון ברמת הארגון, התיקייה או הפרויקט.

השירות Organization Policy מספק מגבלות מוגדרות מראש לשירותים שונים שלGoogle Cloud . עם זאת, אם אתם רוצים שליטה מדויקת יותר בשדות הספציפיים שמוגבלים במדיניות הארגון, אתם יכולים גם ליצור אילוצים בהתאמה אישית ולהשתמש בהם במדיניות הארגון.

יתרונות

אתם יכולים להשתמש במדיניות ארגונית בהתאמה אישית כדי לאפשר או לדחות פעולות ספציפיות באצוות, בסשנים ובתבניות של סשנים ב-Managed Service for Apache Spark. לדוגמה, אם בקשה ליצירת עומס עבודה של אצווה לא עומדת בדרישות של אימות אילוצים מותאמים אישית שהוגדרו במדיניות הארגון, הבקשה תיכשל ותוחזר שגיאה למבצע הקריאה.

העברה בירושה של מדיניות

כברירת מחדל, מדיניות הארגון עוברת בירושה לצאצאים של המשאבים שבהם אתם אוכפים את המדיניות. לדוגמה, אם אוכפים מדיניות בתיקייה, Google Cloud המדיניות נאכפת בכל הפרויקטים בתיקייה. מידע נוסף על ההתנהגות הזו ועל שינוי שלה זמין במאמר בנושא כללי הערכה היררכיים.

תמחור

שירות מדיניות הארגון, כולל אילוצים מוגדרים מראש ומותאמים אישית, מוצע ללא תשלום.

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

  1. הגדרת הפרויקט
    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 Managed Service for Apache Spark API.

      Roles required to enable APIs

      To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

      Enable the API

    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 Managed Service for Apache Spark API.

      Roles required to enable APIs

      To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

      Enable the API

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

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

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

      gcloud init
    14. חשוב לוודא שאתם יודעים מהו מספר הארגון שלכם.

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

כדי לקבל את ההרשאות שדרושות לניהול מדיניות הארגון, אתם צריכים לבקש מהאדמין להקצות לכם את תפקיד ה-IAM‏ Organization policy administrator (אדמין של מדיניות הארגון) ‏(roles/orgpolicy.policyAdmin) במשאב הארגון. כדי לקרוא הסבר על מתן תפקידים, ראו איך מנהלים את הגישה ברמת הפרויקט, התיקייה והארגון.

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

ההרשאות הנדרשות

כדי לנהל את מדיניות הארגון, נדרשות ההרשאות הבאות:

  • orgpolicy.constraints.list
  • orgpolicy.policies.create
  • orgpolicy.policies.delete
  • orgpolicy.policies.list
  • orgpolicy.policies.update
  • orgpolicy.policy.get
  • orgpolicy.policy.set

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

יצירת אילוץ בהתאמה אישית

אילוץ בהתאמה אישית מוגדר בקובץ YAML לפי המשאבים, השיטות, התנאים והפעולות שהוא חל עליהם. ‫Managed Service for Apache Spark תומך באילוצים מותאמים אישית שמוחלים על ה-method ‏CREATE של משאבי ה-batch והסשן.

מידע נוסף על יצירת אילוץ בהתאמה אישית זמין במאמר יצירה וניהול של מדיניות ארגונית בהתאמה אישית.

יצירת אילוץ בהתאמה אישית למשאב של קבוצת בקשות

כדי ליצור קובץ YAML לאילוץ מותאם אישית של Managed Service for Apache Spark למשאב של אצווה, משתמשים בפורמט הבא:

name: organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME
resourceTypes:
- dataproc.googleapis.com/Batch
methodTypes: 
- CREATE
condition: CONDITION
actionType: ACTION
displayName: DISPLAY_NAME
description: DESCRIPTION

מחליפים את מה שכתוב בשדות הבאים:

  • ORGANIZATION_ID: מזהה הארגון, למשל 123456789.

  • CONSTRAINT_NAME: השם שרוצים לתת לאילוץ החדש בהתאמה אישית. אילוץ מותאם אישית חייב להתחיל ב-custom., ויכול לכלול רק אותיות רישיות, אותיות קטנות או מספרים, לדוגמה, custom.batchMustHaveSpecifiedCategoryLabel. האורך המקסימלי של השדה הזה הוא 70 תווים, לא כולל הקידומת, לדוגמה, organizations/123456789/customConstraints/custom..

  • CONDITION: תנאי CEL שנכתב על סמך ייצוג של משאב שירות נתמך. האורך המקסימלי של השדה הוא 1,000 תווים. למידע נוסף על המשאבים שאפשר לכתוב תנאים לגביהם, אפשר לעיין במאמר הגבלות על משאבים ופעולות ב-Dataproc Serverless. תנאי לדוגמה: ("category" in resource.labels) && (resource.labels['category'] in ['retail', 'ads', 'service']).

  • ACTION: הפעולה שתתבצע אם התנאי יתקיים. הערך יכול להיות ALLOW או DENY.

  • DISPLAY_NAME: שם קריא לאנשים של האילוץ. שם תצוגה לדוגמה: "החלת דרישה לתווית 'קטגוריה' על קבוצת פריטים". האורך המקסימלי של השדה הוא 200 תווים.

  • DESCRIPTION: תיאור ידידותי למשתמש של האילוץ, שיוצג כהודעת שגיאה אם תהיה הפרה של המדיניות. האורך המקסימלי של השדה הוא 2,000 תווים. תיאור לדוגמה: "אפשר ליצור אצווה של Dataproc רק אם יש לה תווית 'category' עם הערך 'retail',‏ 'ads' או 'service'".

יצירת אילוץ בהתאמה אישית למשאב של סשן

כדי ליצור קובץ YAML לאילוץ בהתאמה אישית של Managed Service for Apache Spark עבור משאב מסוג session, משתמשים בפורמט הבא:

name: organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME
resourceTypes:
- dataproc.googleapis.com/Session
methodTypes: 
- CREATE
condition: CONDITION
actionType: ACTION
displayName: DISPLAY_NAME
description: DESCRIPTION

מחליפים את מה שכתוב בשדות הבאים:

  • ORGANIZATION_ID: מזהה הארגון, למשל 123456789.

  • CONSTRAINT_NAME: השם שרוצים לתת לאילוץ החדש בהתאמה אישית. אילוץ מותאם אישית חייב להתחיל ב-custom., ויכול לכלול רק אותיות רישיות, אותיות קטנות או מספרים, לדוגמה, custom.SessionNameMustStartWithTeamName. האורך המקסימלי של השדה הזה הוא 70 תווים, לא כולל הקידומת, לדוגמה, organizations/123456789/customConstraints/custom..

  • CONDITION: תנאי CEL שנכתב על סמך ייצוג של משאב שירות נתמך. האורך המקסימלי של השדה הוא 1,000 תווים. מידע נוסף על המשאבים שזמינים לכתיבת תנאים מופיע במאמר מגבלות של משאבים ופעולות ב-Dataproc Serverless. תנאי לדוגמה: (resource.name.startsWith("dataproc").

  • ACTION: הפעולה שתתבצע אם התנאי יתקיים. הערך יכול להיות ALLOW או DENY.

  • DISPLAY_NAME: שם קריא לאנשים של האילוץ. שם לדוגמה: "Enforce session to have a ttl < 2 hours". האורך המקסימלי של השדה הוא 200 תווים.

  • DESCRIPTION: תיאור ידידותי למשתמש של האילוץ, שיוצג כהודעת שגיאה אם תהיה הפרה של המדיניות. האורך המקסימלי של השדה הוא 2,000 תווים. תיאור לדוגמה: "רק אם מוגדר TTL מותר, אפשר ליצור סשן".

יצירת אילוץ בהתאמה אישית למשאב של תבנית סשן

כדי ליצור קובץ YAML לאילוץ בהתאמה אישית של Managed Service for Apache Spark עבור משאב של תבנית סשן, משתמשים בפורמט הבא:

name: organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME
resourceTypes:
- dataproc.googleapis.com/SessionTemplate
methodTypes: 
- CREATE
- UPDATE
condition: CONDITION
actionType: ACTION
displayName: DISPLAY_NAME
description: DESCRIPTION

מחליפים את מה שכתוב בשדות הבאים:

  • ORGANIZATION_ID: מזהה הארגון, למשל 123456789.

  • CONSTRAINT_NAME: השם שרוצים לתת לאילוץ החדש בהתאמה אישית. אילוץ מותאם אישית חייב להתחיל ב-custom., ויכול לכלול רק אותיות רישיות, אותיות קטנות או מספרים, לדוגמה, custom.SessionTemplateNameMustStartWithTeamName. האורך המקסימלי של השדה הזה הוא 70 תווים, לא כולל הקידומת, לדוגמה, organizations/123456789/customConstraints/custom..

  • CONDITION: תנאי CEL שנכתב על סמך ייצוג של משאב שירות נתמך. האורך המקסימלי של השדה הוא 1,000 תווים. מידע נוסף על המשאבים שזמינים לכתיבת תנאים מופיע במאמר מגבלות על משאבים ופעולות. תנאי לדוגמה: (resource.name.startsWith("dataproc").

  • ACTION: הפעולה שתתבצע אם התנאי יתקיים. הערך יכול להיות ALLOW או DENY.

  • DISPLAY_NAME: שם קריא לאנשים של האילוץ. דוגמה לשם לתצוגה: "Enforce session template to have a ttl < 2 hours". האורך המקסימלי של השדה הוא 200 תווים.

  • DESCRIPTION: תיאור ידידותי למשתמש של האילוץ, שיוצג כהודעת שגיאה אם תהיה הפרה של המדיניות. האורך המקסימלי של השדה הוא 2,000 תווים. תיאור לדוגמה: "רק אם מוגדר TTL מותר, אפשר ליצור תבנית סשן".

הגדרת אילוץ בהתאמה אישית

המסוף

כדי ליצור אילוץ בהתאמה אישית:

  1. במסוף Google Cloud , נכנסים לדף מדיניות הארגון.

    מעבר למדיניות הארגון

  2. בכלי לבחירת פרויקטים, בוחרים את הפרויקט שרוצים להגדיר לו את מדיניות הארגון.
  3. לוחצים על Custom constraint (הגבלה מותאמת אישית).
  4. בתיבה שם לתצוגה, מזינים שם שאנשים יכולים לקרוא למגבלה. השם הזה משמש בהודעות שגיאה, ואפשר להשתמש בו לצורך זיהוי וניפוי באגים. אל תשתמשו בפרטים אישיים מזהים (PII) או במידע אישי רגיש בשמות לתצוגה, כי השם הזה עלול להיחשף בהודעות שגיאה. השדה הזה יכול להכיל עד 200 תווים.
  5. בתיבה Constraint ID (מזהה ההגבלה), מזינים את המזהה שרוצים להגדיר להגבלה החדשה בהתאמה אישית. אילוץ מותאם אישית יכול להכיל רק אותיות (כולל אותיות גדולות וקטנות) או מספרים, למשל custom.batchMustHaveSpecifiedCategoryLabel. השדה הזה יכול להכיל עד 70 תווים, לא כולל הקידומת (custom.), לדוגמה, organizations/123456789/customConstraints/custom. אל תכללו פרטים אישיים מזהים (PII) או נתונים רגישים במזהה האילוץ, כי הם עלולים להיחשף בהודעות שגיאה.
  6. בתיבה Description, מזינים תיאור של האילוץ שכתוב בצורה שקריאה לאנשים. התיאור הזה משמש כהודעת שגיאה כשמתבצעת הפרה של המדיניות. לכלול פרטים על הסיבה להפרת המדיניות ואיך לפתור אותה. אל תכללו בתיאור פרטים אישיים מזהים (PII) או מידע אישי רגיש, כי הם עלולים להיחשף בהודעות שגיאה. השדה הזה יכול להכיל עד 2,000 תווים.
  7. בתיבה Resource type, בוחרים את השם של משאב REST‏ Google Cloud שמכיל את האובייקט והשדה שרוצים להגביל – לדוגמה, container.googleapis.com/NodePool. רוב סוגי המשאבים תומכים בעד 20 אילוצים מותאמים אישית. אם תנסו ליצור עוד אילוצים בהתאמה אישית, הפעולה תיכשל.
  8. אפשר לאכוף את ההגבלה הזו רק בשיטת REST‏ CREATE.
  9. כדי לראות את השיטות הנתמכות לכל שירות, מחפשים את השירות בקטע שירותים שתומכים באילוצים בהתאמה אישית.

  10. כדי להגדיר תנאי, לוחצים על Edit condition.
    1. בחלונית Add condition, יוצרים תנאי CEL שמתייחס למשאב שירות נתמך, לדוגמה, resource.management.autoUpgrade == false. השדה הזה יכול להכיל עד 1,000 תווים. פרטים על השימוש ב-CEL זמינים במאמר בנושא Common Expression Language. מידע נוסף על משאבי השירות שאפשר להשתמש בהם באילוצים בהתאמה אישית זמין במאמר שירותים שתומכים באילוצים בהתאמה אישית.
    2. לוחצים על Save.
  11. בקטע פעולה, בוחרים אם לאשר או לדחות את השיטה שנבדקה אם התנאי מתקיים.
  12. הפעולה deny (דחייה) פירושה שהפעולה ליצירה או לעדכון של המשאב נחסמת אם התנאי מוערך כ-True.

    הפעולה allow (אישור) אומרת שהפעולה ליצירה או לעדכון של המשאב מותרת רק אם התנאי מחזיר את הערך true. כל מקרה אחר, מלבד אלה שמפורטים במפורש בתנאי, נחסם.

  13. לוחצים על יצירת אילוץ.
  14. אחרי שמזינים ערך בכל שדה, מופיעה משמאל הגדרת ה-YAML המקבילה לאילוץ המותאם אישית הזה.

gcloud

  1. כדי ליצור אילוץ בהתאמה אישית, יוצרים קובץ YAML בפורמט הבא:
  2. name: organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME
    resourceTypes: RESOURCE_NAME
    methodTypes:
      - CREATE
    condition: "CONDITION"
    actionType: ACTION
    displayName: DISPLAY_NAME
    description: DESCRIPTION

    מחליפים את מה שכתוב בשדות הבאים:

    • ORGANIZATION_ID: מזהה הארגון, למשל 123456789.
    • CONSTRAINT_NAME: השם שרוצים לתת לאילוץ המותאם אישית החדש. אילוץ מותאם אישית יכול להכיל רק אותיות (כולל אותיות רישיות וקטנות) או מספרים, למשל, custom.batchMustHaveSpecifiedCategoryLabel. השדה הזה יכול להכיל עד 70 תווים, לא כולל הקידומת (custom.) – לדוגמה, organizations/123456789/customConstraints/custom. אל תכללו פרטים אישיים מזהים (PII) או נתונים רגישים במזהה האילוץ, כי הם עלולים להיחשף בהודעות שגיאה.
    • RESOURCE_NAME: השם מוגדר במלואו של המשאב Google Cloudשמכיל את האובייקט והשדה שרוצים להגביל. לדוגמה: dataproc.googleapis.com/batch. רוב סוגי המשאבים תומכים בעד 20 אילוצים מותאמים אישית. אם תנסו ליצור עוד אילוצים בהתאמה אישית, הפעולה תיכשל.
    • methodTypes: שיטות ה-REST שבהן האילוץ נאכף. הערך יכול להיות רק CREATE.
    • כדי לראות את השיטות הנתמכות לכל שירות, מחפשים את השירות ב שירותים שתומכים באילוצים בהתאמה אישית.

    • CONDITION: תנאי CEL שנכתב על סמך ייצוג של משאב שירות נתמך. השדה הזה יכול להכיל עד 1,000 תווים. לדוגמה: ("category" in resource.labels) && (resource.labels['category'] in ['retail', 'ads', 'service']).
    • מידע נוסף על המשאבים שאפשר לכתוב תנאים לגביהם זמין במאמר משאבים נתמכים.

    • ACTION: הפעולה שתתבצע אם התנאי condition יתקיים. הערך יכול להיות רק ALLOW.
    • הפעולה allow (אישור) אומרת שאם התנאי מקבל את הערך True, הפעולה ליצירה או לעדכון של המשאב מותרת. המשמעות היא שכל מקרה אחר, חוץ מהמקרה שמופיע במפורש בתנאי, ייחסם.

    • DISPLAY_NAME: שם קריא לאנשים של האילוץ. השם הזה מופיע בהודעות שגיאה ויכול לשמש לזיהוי ולניפוי באגים. אל תשתמשו בפרטים אישיים מזהים (PII) או במידע אישי רגיש בשמות המוצגים, כי השם הזה עלול להיחשף בהודעות שגיאה. השדה הזה יכול להכיל עד 200 תווים.
    • DESCRIPTION: תיאור ידידותי למשתמש של האילוץ שיוצג כהודעת שגיאה אם המדיניות תופר. השדה הזה יכול להכיל עד 2,000 תווים.
  3. אחרי שיוצרים קובץ YAML לאילוץ חדש בהתאמה אישית, צריך להגדיר אותו כדי שיהיה זמין למדיניות הארגון בארגון. כדי להגדיר אילוץ בהתאמה אישית, משתמשים בפקודה gcloud org-policies set-custom-constraint:
  4. gcloud org-policies set-custom-constraint CONSTRAINT_PATH

    מחליפים את CONSTRAINT_PATH בנתיב המלא לקובץ האילוצים המותאמים אישית. לדוגמה, /home/user/customconstraint.yaml.

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

  5. כדי לוודא שהאילוץ המותאם אישית קיים, משתמשים בפקודה gcloud org-policies list-custom-constraints:
  6. gcloud org-policies list-custom-constraints --organization=ORGANIZATION_ID

    מחליפים את ORGANIZATION_ID במזהה של משאב הארגון.

    מידע נוסף זמין במאמר בנושא צפייה במדיניות הארגון.

החלת אילוץ מותאם אישית

כדי לאכוף אילוץ, יוצרים מדיניות ארגון שמפנה אליו, ואז מחילים את מדיניות הארגון הזו על משאב Google Cloud .

המסוף

  1. במסוף Google Cloud , נכנסים לדף מדיניות הארגון.

    מעבר למדיניות הארגון

  2. מכלי לבחירת פרויקטים, בוחרים את הפרויקט שרוצים להגדיר לו את מדיניות הארגון.
  3. מהרשימה בדף מדיניות הארגון, בוחרים את האילוץ כדי לראות את הדף פרטי המדיניות של האילוץ הזה.
  4. כדי להגדיר את מדיניות הארגון עבור המשאב הזה, לוחצים על ניהול מדיניות.
  5. בדף עריכת מדיניות, בוחרים באפשרות במקום המדיניות של המשאב הראשי.
  6. לוחצים על Add a rule.
  7. בקטע Enforcement (אכיפה), בוחרים אם מדיניות הארגון הזו נאכפת או לא.
  8. אופציונלי: כדי להגדיר את מדיניות הארגון כתלויה בתג, לוחצים על הוספת תנאי. הערה: אם מוסיפים כלל מותנה למדיניות ארגון, צריך להוסיף לפחות כלל לא מותנה אחד, אחרת אי אפשר לשמור את המדיניות. מידע נוסף על מדיניות ארגונית עם תגים
  9. לוחצים על בדיקת שינויים כדי לדמות את ההשפעה של מדיניות הארגון. מידע נוסף זמין במאמר בדיקת שינויים במדיניות הארגון באמצעות סימולטור המדיניות.
  10. כדי לאכוף את המדיניות של הארגון במצב פרימטר לבדיקות, לוחצים על הגדרת המדיניות להרצת בדיקה. מידע נוסף זמין במאמר בנושא בדיקת מדיניות הארגון.
  11. אחרי שמוודאים שמדיניות הארגון במצב הרצה יבשה פועלת כמו שרוצים, לוחצים על הגדרת מדיניות כדי להגדיר את המדיניות הפעילה.

gcloud

  1. כדי ליצור מדיניות ארגונית עם כללים בוליאניים, יוצרים קובץ YAML של מדיניות שמפנה לאילוץ:
  2. name: projects/PROJECT_ID/policies/CONSTRAINT_NAME
    spec:
      rules:
      - enforce: true
    
    dryRunSpec:
      rules:
      - enforce: true

    מחליפים את מה שכתוב בשדות הבאים:

    • PROJECT_ID: הפרויקט שבו רוצים לאכוף את האילוץ.
    • CONSTRAINT_NAME: השם שהגדרתם לאילוץ המותאם אישית. לדוגמה, custom.batchMustHaveSpecifiedCategoryLabel.
  3. כדי לאכוף את מדיניות הארגון במצב הרצה יבשה, מריצים את הפקודה הבאה עם הדגל dryRunSpec:
  4. gcloud org-policies set-policy POLICY_PATH --update-mask=dryRunSpec

    מחליפים את POLICY_PATH בנתיב המלא לקובץ ה-YAML של מדיניות הארגון. יחלפו עד 15 דקות לפני שהמדיניות תיכנס לתוקף.

  5. אחרי שמוודאים שמדיניות הארגון במצב הרצה יבשה פועלת כמו שרוצים, מגדירים את המדיניות הפעילה באמצעות הפקודה org-policies set-policy והדגל spec:
  6. gcloud org-policies set-policy POLICY_PATH --update-mask=spec

    מחליפים את POLICY_PATH בנתיב המלא לקובץ ה-YAML של מדיניות הארגון. יחלפו עד 15 דקות לפני שהמדיניות תיכנס לתוקף.

בדיקת האילוץ המותאם אישית

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

בדיקת אילוץ מותאם אישית למשאב של קבוצה

בדוגמה הבאה ליצירת קבוצה, מניחים שנוצר אילוץ מותאם אישית והוא נאכף על יצירת הקבוצה, כך שהקבוצה צריכה לכלול תווית category עם הערך retail,‏ ads או service:("category" in resource.labels) && (resource.labels['category'] in ['retail', 'ads', 'service']).

gcloud dataproc batches submit spark \
  --region us-west1
  --jars file:///usr/lib/spark/examples/jars/spark-examples.jar \
  --class org.apache.spark.examples.SparkPi  \
  --network default \
  --labels category=foo \
  --100

פלט לדוגמה:

Operation denied by custom org policies: ["customConstraints/custom.batchMustHaveSpecifiedCategoryLabel": ""Only allow Dataproc batch creation if it has a 'category' label with
  a 'retail', 'ads', or 'service' value""]

בדיקת אילוץ מותאם אישית למשאב של סשן

בדוגמה הבאה ליצירת סשן מניחים שנוצר אילוץ מותאם אישית והוא נאכף על יצירת הסשן, כך שנדרש שהסשן יכלול name שמתחיל ב-orgName.

gcloud beta dataproc sessions create spark test-session
  --location us-central1

פלט לדוגמה:

Operation denied by custom org policy:
["customConstraints/custom.denySessionNameNotStartingWithOrgName": "Deny session
creation if its name does not start with 'orgName'"]

בדיקת אילוץ מותאם אישית למשאב של תבנית סשן

בדוגמה הבאה ליצירת תבנית סשן מניחים שיצרתם אילוץ מותאם אישית ואכפתם אותו על יצירה ועדכון של תבנית סשן, כדי לדרוש שלתבנית הסשן יהיה name שמתחיל ב-orgName.

gcloud beta dataproc session-templates import test-session-template
--source=saved-template.yaml

פלט לדוגמה:

Operation denied by custom org policy:
["customConstraints/custom.denySessionTemplateNameNotStartingWithOrgName":
"Deny session template creation or update if its name does not start with
'orgName'"]

הגבלות על משאבים ופעולות

בקטע הזה מפורטות האילוצים המותאמים אישית שזמינים ב-Managed Service for Apache Spark למשאבי אצווה ומשאבי סשן.

אילוצים נתמכים של קבוצות

אפשר להשתמש באילוצים המותאמים אישית הבאים של Managed Service for Apache Spark כשיוצרים (שולחים) עומס עבודה של עיבוד ברצף:

כללי

  • resource.labels

PySparkBatch

  • resource.pysparkBatch.mainPythonFileUri
  • resource.pysparkBatch.args
  • resource.pysparkBatch.pythonFileUris
  • resource.pysparkBatch.jarFileUris
  • resource.pysparkBatch.fileUris
  • resource.pysparkBatch.archiveUris

SparkBatch

  • resource.sparkBatch.mainJarFileUri
  • resource.sparkBatch.mainClass
  • resource.sparkBatch.args
  • resource.sparkBatch.jarFileUris
  • resource.sparkBatch.fileUris
  • resource.sparkBatch.archiveUris

SparRBatch

  • resource.sparkRBatch.mainRFileUri
  • resource.sparkRBatch.args
  • resource.sparkRBatch.fileUris
  • resource.sparkRBatch.archiveUris

SparkSqlBatch

  • resource.sparkSqlBatch.queryFileUri
  • resource.sparkSqlBatch.queryVariables
  • resource.sparkSqlBatch.jarFileUris

RuntimeConfig

  • resource.runtimeConfig.version
  • resource.runtimeConfig.containerImage
  • resource.runtimeConfig.properties
  • resource.runtimeConfig.repositoryConfig.pypiRepositoryConfig.pypiRepository
  • resource.runtimeConfig.autotuningConfig.scenarios
  • resource.runtimeConfig.cohort

ExecutionConfig

  • resource.environmentConfig.executionConfig.serviceAccount
  • resource.environmentConfig.executionConfig.networkUri
  • resource.environmentConfig.executionConfig.subnetworkUri
  • resource.environmentConfig.executionConfig.networkTags
  • resource.environmentConfig.executionConfig.kmsKey
  • resource.environmentConfig.executionConfig.idleTtl
  • resource.environmentConfig.executionConfig.ttl
  • resource.environmentConfig.executionConfig.stagingBucket
  • resource.environmentConfig.executionConfig.authenticationConfig.userWorkloadAuthenticationType

PeripheralsConfig

  • resource.environmentConfig.peripheralsConfig.metastoreService
  • resource.environmentConfig.peripheralsConfig.sparkHistoryServerConfig.dataprocCluster

אילוצים נתמכים של סשנים

אפשר להשתמש במאפייני הסשן הבאים כשיוצרים אילוצים מותאמים אישית בסשנים ללא שרת:

כללי

  • resource.name
  • resource.sparkConnectSession
  • resource.user
  • resource.sessionTemplate

JupyterSession

  • resource.jupyterSession.kernel
  • resource.jupyterSession.displayName

RuntimeConfig

  • resource.runtimeConfig.version
  • resource.runtimeConfig.containerImage
  • resource.runtimeConfig.properties
  • resource.runtimeConfig.repositoryConfig.pypiRepositoryConfig.pypiRepository
  • resource.runtimeConfig.autotuningConfig.scenarios
  • resource.runtimeConfig.cohort

ExecutionConfig

  • resource.environmentConfig.executionConfig.serviceAccount
  • resource.environmentConfig.executionConfig.networkUri
  • resource.environmentConfig.executionConfig.subnetworkUri
  • resource.environmentConfig.executionConfig.networkTags
  • resource.environmentConfig.executionConfig.kmsKey
  • resource.environmentConfig.executionConfig.idleTtl
  • resource.environmentConfig.executionConfig.ttl
  • resource.environmentConfig.executionConfig.stagingBucket
  • resource.environmentConfig.executionConfig.authenticationConfig.userWorkloadAuthenticationType

PeripheralsConfig

  • resource.environmentConfig.peripheralsConfig.metastoreService
  • resource.environmentConfig.peripheralsConfig.sparkHistoryServerConfig.dataprocCluster

אילוצים נתמכים בתבניות של סשנים

אפשר להשתמש במאפיינים הבאים של תבניות סשנים כשיוצרים אילוצים בהתאמה אישית בתבניות סשנים ללא שרת:

כללי

  • resource.name
  • resource.description
  • resource.sparkConnectSession

JupyterSession

  • resource.jupyterSession.kernel
  • resource.jupyterSession.displayName

RuntimeConfig

  • resource.runtimeConfig.version
  • resource.runtimeConfig.containerImage
  • resource.runtimeConfig.properties
  • resource.runtimeConfig.repositoryConfig.pypiRepositoryConfig.pypiRepository
  • resource.runtimeConfig.autotuningConfig.scenarios
  • resource.runtimeConfig.cohort

ExecutionConfig

  • resource.environmentConfig.executionConfig.serviceAccount
  • resource.environmentConfig.executionConfig.networkUri
  • resource.environmentConfig.executionConfig.subnetworkUri
  • resource.environmentConfig.executionConfig.networkTags
  • resource.environmentConfig.executionConfig.kmsKey
  • resource.environmentConfig.executionConfig.idleTtl
  • resource.environmentConfig.executionConfig.ttl
  • resource.environmentConfig.executionConfig.stagingBucket
  • resource.environmentConfig.executionConfig.authenticationConfig.userWorkloadAuthenticationType

PeripheralsConfig

  • resource.environmentConfig.peripheralsConfig.metastoreService
  • resource.environmentConfig.peripheralsConfig.sparkHistoryServerConfig.dataprocCluster

דוגמאות למגבלות מותאמות אישית לתרחישי שימוש נפוצים

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

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

בטבלה הבאה מפורטות דוגמאות למגבלות מותאמות אישית של עיבוד ברצף (batch processing) ב-Managed Service for Apache Spark:

תיאור תחביר של אילוצים
צריך לצרף לכל קובץ באצ' תווית 'קטגוריה' עם ערכים מותרים.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.batchMustHaveSpecifiedCategoryLabel
    resourceTypes:
    - dataproc.googleapis.com/Batch
    methodTypes:
    - CREATE
    condition: ("category" in resource.labels) && (resource.labels['category'] in ['retail', 'ads', 'service'])
    actionType: ALLOW
    displayName: Enforce batch "category" label requirement.
    description: Only allow batch creation if it attaches a "category" label with an allowable value.
צריך להגדיר ב-Batch גרסת זמן ריצה מותרת.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.batchMustUseAllowedVersion
    resourceTypes:
    - dataproc.googleapis.com/Batch
    methodTypes:
    - CREATE
    condition:  (has(resource.runtimeConfig.version)) && (resource.runtimeConfig.version in ["2.0.45", "2.0.48"])
    actionType: ALLOW
    displayName: Enforce batch runtime version.
    description: Only allow batch creation if it sets an allowable runtime version.
חובה להשתמש ב-SparkSQL.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.batchMustUseSparkSQL
    resourceTypes:
    - dataproc.googleapis.com/Batch
    methodTypes:
    - CREATE
    condition: (has(resource.sparkSqlBatch))
    actionType: ALLOW
    displayName: Enforce batch only use SparkSQL Batch.
    description: Only allow creation of SparkSQL Batch.
ב-Batch, צריך להגדיר TTL של פחות משעתיים.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.batchMustSetLessThan2hTtl
    resourceTypes:
    - dataproc.googleapis.com/Batch
    methodTypes:
    - CREATE
    condition:  (has(resource.environmentConfig.executionConfig.ttl)) && (resource.environmentConfig.executionConfig.ttl <= duration('2h'))
    actionType: ALLOW
    displayName: Enforce batch TTL.
    description: Only allow batch creation if it sets an allowable TTL.
אי אפשר להגדיר יותר מ-20 תהליכי Spark ראשוניים בטוקנים מרובים.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.batchInitialExecutorMax20
    resourceTypes:
    - dataproc.googleapis.com/Batch
    methodTypes:
    - CREATE
    condition: (has(resource.runtimeConfig.properties)) && ('spark.executor.instances' in resource.runtimeConfig.properties)
     && (int(resource.runtimeConfig.properties['spark.executor.instances'])>20)
    actionType: DENY
    displayName: Enforce maximum number of batch Spark executor instances.
    description: Deny batch creation if it specifies more than 20 Spark executor instances.
אי אפשר להגדיר יותר מ-20 תהליכי הפעלה ראשוניים של הקצאה דינמית של Spark באצווה.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.batchDynamicAllocationInitialExecutorMax20
    resourceTypes:
    - dataproc.googleapis.com/Batch
    methodTypes:
    - CREATE
    condition: (has(resource.runtimeConfig.properties)) && ('spark.dynamicAllocation.initialExecutors' in resource.runtimeConfig.properties)
     && (int(resource.runtimeConfig.properties['spark.dynamicAllocation.initialExecutors'])>20)
    actionType: DENY
    displayName: Enforce maximum number of batch dynamic allocation initial executors.
    description: Deny batch creation if it specifies more than 20 Spark dynamic allocation initial executors.
האצווה לא יכולה להכיל יותר מ-20 תהליכי הפעלה של הקצאה דינמית.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.batchDynamicAllocationMaxExecutorMax20
    resourceTypes:
    - dataproc.googleapis.com/Batch
    methodTypes:
    - CREATE
    condition: (resource.runtimeConfig.properties['spark.dynamicAllocation.enabled']=='false') || (('spark.dynamicAllocation.maxExecutors' in resource.runtimeConfig.properties) && (int(resource.runtimeConfig.properties['spark.dynamicAllocation.maxExecutors'])<=20))
    actionType: ALLOW
    displayName: Enforce batch maximum number of dynamic allocation executors.
    description:  Only allow batch creation if dynamic allocation is disabled or
    the maximum number of dynamic allocation executors is set to less than or equal to 20.
מערכת Batch צריכה להגדיר את מפתח ה-KMS לתבנית מותרת.
    name: organizations/ORGANIZATION_ID/custom.batchKmsPattern
    resourceTypes:
    - dataproc.googleapis.com/Batch
    methodTypes:
    - CREATE
    condition:  matches(resource.environmentConfig.executionConfig.kmsKey, '^keypattern[a-z]$')
    actionType: ALLOW
    displayName: Enforce batch KMS Key pattern.
    description: Only allow batch creation if it sets the KMS key to an allowable pattern.
ב-Batch צריך להגדיר את הקידומת של קטגוריית האחסון הזמני לערך מותר.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.batchStagingBucketPrefix
    resourceTypes:
    - dataproc.googleapis.com/Batch
    methodTypes:
    - CREATE
    condition:  resource.environmentConfig.executionConfig.stagingBucket.startsWith(ALLOWED_PREFIX)
    actionType: ALLOW
    displayName: Enforce batch staging bucket prefix.
    description: Only allow batch creation if it sets the staging bucket prefix to ALLOWED_PREFIX.
ההגדרה של הזיכרון להרצת קבוצות של פעולות חייבת להסתיים בסיומת m ולהיות קטנה מ-20,000 m.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.batchExecutorMemoryMax
    resourceTypes:
    - dataproc.googleapis.com/Batch
    methodTypes:
    - CREATE
    condition:  ('spark.executor.memory' in resource.runtimeConfig.properties) && (resource.runtimeConfig.properties['spark.executor.memory'].endsWith('m')) && (int(resource.runtimeConfig.properties['spark.executor.memory'].split('m')[0])<20000)
    actionType: ALLOW
    displayName: Enforce batch executor maximum memory.
    description: Only allow batch creation if the executor memory setting ends with a suffix 'm' and is less than 20000 m.

דוגמה למגבלות מותאמות אישית למשאב של סשן

בטבלה הבאה מפורטות דוגמאות למגבלות מותאמות אישית של סשנים ב-Managed Service for Apache Spark:

תיאור תחביר של אילוצים
הסשן צריך להגדיר את sessionTemplate כמחרוזת ריקה.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionTemplateMustBeEmpty
    resourceTypes:
    - dataproc.googleapis.com/Session
    methodTypes:
    - CREATE
    condition: resource.sessionTemplate == ""
    actionType: ALLOW
    displayName: Enforce empty session templates.
    description: Only allow session creation if session template is empty string.
הערך של sessionTemplate צריך להיות שווה למזהי התבניות שאושרו.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionTemplateIdMustBeApproved
    resourceTypes:
    - dataproc.googleapis.com/Session
    methodTypes:
    - CREATE
    condition:
    resource.sessionTemplate.startsWith("https://www.googleapis.com/compute/v1/projects/")
      &&
      resource.sessionTemplate.contains("/locations/") &&
      resource.sessionTemplate.contains("/sessionTemplates/") &&
       (
         resource.sessionTemplate.endsWith("/1") ||
         resource.sessionTemplate.endsWith("/2") ||
         resource.sessionTemplate.endsWith("/13")
       )
    actionType: ALLOW
    displayName: Enforce templateId must be 1, 2, or 13.
    description: Only allow session creation if session template ID is in the
    approved list, that is, 1, 2 and 13.
הסשן צריך להשתמש בפרטי הכניסה של משתמש הקצה כדי לאמת את עומס העבודה.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.AllowEUCSessions
    resourceTypes:
    - dataproc.googleapis.com/Session
    methodTypes:
    - CREATE
    condition:
    resource.environmentConfig.executionConfig.authenticationConfig.userWorkloadAuthenticationType=="END_USER_CREDENTIALS"
    actionType: ALLOW
    displayName: Require end user credential authenticated sessions.
    description: Allow session creation only if the workload is authenticated
    using end-user credentials.
בסשן צריך להגדיר גרסה מותרת של זמן ריצה.
    name: organizations/ORGANIZATION_ID/custom.sessionMustUseAllowedVersion
    resourceTypes:
    - dataproc.googleapis.com/Session
    methodTypes:
    - CREATE
    condition: (has(resource.runtimeConfig.version)) &&
    (resource.runtimeConfig.version in ["2.0.45", "2.0.48"])
    actionType: ALLOW
    displayName: Enforce session runtime version.
    description: Only allow session creation if it sets an allowable runtime
    version.
בסשן צריך להגדיר TTL של פחות משעתיים.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionMustSetLessThan2hTtl
    resourceTypes:
    - dataproc.googleapis.com/Session
    methodTypes:
    - CREATE
    condition: (has(resource.environmentConfig.executionConfig.ttl)) &&
    (resource.environmentConfig.executionConfig.ttl <= duration('2h'))
    actionType: ALLOW
    displayName: Enforce session TTL.
    description: Only allow session creation if it sets an allowable TTL.
בסשן אי אפשר להגדיר יותר מ-20 מנהלי ביצוע ראשוניים של Spark.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionInitialExecutorMax20
    resourceTypes:
    - dataproc.googleapis.com/Session
    methodTypes:
    - CREATE
    condition: (has(resource.runtimeConfig.properties)) &&
    ('spark.executor.instances' in resource.runtimeConfig.properties) &&
    (int(resource.runtimeConfig.properties['spark.executor.instances'])>20)
    actionType: DENY
    displayName: Enforce maximum number of session Spark executor instances.
    description: Deny session creation if it specifies more than 20 Spark executor
    instances.
בסשן אי אפשר להגדיר יותר מ-20 תהליכי הפעלה ראשוניים של הקצאה דינמית של Spark.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionDynamicAllocationInitialExecutorMax20
    resourceTypes:
    - dataproc.googleapis.com/Session
    methodTypes:
    - CREATE
    condition: (has(resource.runtimeConfig.properties)) &&
    ('spark.dynamicAllocation.initialExecutors' in resource.runtimeConfig.properties)
    && (int(resource.runtimeConfig.properties['spark.dynamicAllocation.initialExecutors'])>20)
    actionType: DENY
    displayName: Enforce maximum number of session dynamic allocation initial executors.
    description: Deny session creation if it specifies more than 20 Spark dynamic
    allocation initial executors.
בסשן צריך להגדיר את מפתח ה-KMS לתבנית מותרת.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionKmsPattern
    resourceTypes:
    - dataproc.googleapis.com/Session
    methodTypes:
    - CREATE
    condition: matches(resource.environmentConfig.executionConfig.kmsKey, '^keypattern[a-z]$')
    actionType: ALLOW
    displayName: Enforce session KMS Key pattern.
    description: Only allow session creation if it sets the KMS key to an
    allowable pattern.
בסשן צריך להגדיר את הקידומת של קטגוריית הביניים לערך מותר.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionStagingBucketPrefix
    resourceTypes:
    - dataproc.googleapis.com/Session
    methodTypes:
    - CREATE
    condition: resource.environmentConfig.executionConfig.stagingBucket.startsWith(ALLOWED_PREFIX)
    actionType: ALLOW
    displayName: Enforce session staging bucket prefix.
    description: Only allow session creation if it sets the staging bucket prefix
    to ALLOWED_PREFIX.
ההגדרה של הזיכרון להרצת סשן חייבת להסתיים בסיומת m ולכלול ערך שקטן מ-20,000 m.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionExecutorMemoryMax
    resourceTypes:
    - dataproc.googleapis.com/Session
    methodTypes:
    - CREATE
    condition: ('spark.executor.memory' in resource.runtimeConfig.properties) &&
    (resource.runtimeConfig.properties['spark.executor.memory'].endsWith('m')) &&
    (int(resource.runtimeConfig.properties['spark.executor.memory'].split('m')[0])<20000)
    actionType: ALLOW
    displayName: Enforce session executor maximum memory.
    description: Only allow session creation if the executor memory setting ends
    with a suffix 'm' and is less than 20000 m.

דוגמה למגבלות מותאמות אישית למשאב של תבנית לפגישה

בטבלה הבאה מופיעות דוגמאות למגבלות מותאמות אישית של תבנית סשן ב-Managed Service for Apache Spark:

תיאור תחביר של אילוצים
שם תבנית הסשן חייב להסתיים ב-org-name.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.denySessionTemplateNameNotEndingWithOrgName
    resourceTypes:
    - dataproc.googleapis.com/SessionTemplate
    methodTypes:
    - CREATE
    - UPDATE
    condition: '!resource.name.endsWith(''org-name'')'
    actionType: DENY
    displayName: DenySessionTemplateNameNotEndingWithOrgName
    description: Deny session template creation/update if its name does not end with 'org-name'
בתבנית הסשן צריך להגדיר גרסת זמן ריצה מותרת.
    name: organizations/ORGANIZATION_ID/custom.sessionTemplateMustUseAllowedVersion
    resourceTypes:
    - dataproc.googleapis.com/SessionTemplate
    methodTypes:
    - CREATE
    - UPDATE
    condition: (has(resource.runtimeConfig.version)) &&
    (resource.runtimeConfig.version in ["2.0.45", "2.0.48"])
    actionType: ALLOW
    displayName: Enforce session template runtime version.
    description: Only allow session template creation or update if it sets an
    allowable runtime version.
בתבנית של הסשן צריך להגדיר TTL של פחות משעתיים.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionTemplateMustSetLessThan2hTtl
    resourceTypes:
    - dataproc.googleapis.com/SessionTemplate
    methodTypes:
    - CREATE
    - UPDATE
    condition: (has(resource.environmentConfig.executionConfig.ttl)) &&
    (resource.environmentConfig.executionConfig.ttl <= duration('2h'))
    actionType: ALLOW
    displayName: Enforce session template TTL.
    description: Only allow session template creation or update if it sets an
    allowable TTL.
בתבנית של סשן אי אפשר להגדיר יותר מ-20 מנהלי הפעלה ראשוניים של Spark.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionTemplateInitialExecutorMax20
    resourceTypes:
    - dataproc.googleapis.com/SessionTemplate
    methodTypes:
    - CREATE
    - UPDATE
    condition: (has(resource.runtimeConfig.properties)) &&
    ('spark.executor.instances' in resource.runtimeConfig.properties) &&
    (int(resource.runtimeConfig.properties['spark.executor.instances'])>20)
    actionType: DENY
    displayName: Enforce maximum number of session Spark executor instances.
    description: Deny session template creation or update if it specifies more
    than 20 Spark executor instances.
בתבנית סשן אי אפשר להגדיר יותר מ-20 תהליכי Spark דינמיים להקצאה ראשונית.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionTemplateDynamicAllocationInitialExecutorMax20
    resourceTypes:
    - dataproc.googleapis.com/SessionTemplate
    methodTypes:
    - CREATE
    - UPDATE
    condition: (has(resource.runtimeConfig.properties)) &&
    ('spark.dynamicAllocation.initialExecutors' in resource.runtimeConfig.properties)
    && (int(resource.runtimeConfig.properties['spark.dynamicAllocation.initialExecutors'])>20)
    actionType: DENY
    displayName: Enforce maximum number of session dynamic allocation initial executors.
    description: Deny session template creation or update if it specifies more than 20
    Spark dynamic allocation initial executors.
בתבנית הסשן צריך להגדיר את מפתח ה-KMS לתבנית מותרת.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionTemplateKmsPattern
    resourceTypes:
    - dataproc.googleapis.com/SessionTemplate
    methodTypes:
    - CREATE
    - UPDATE
    condition: matches(resource.environmentConfig.executionConfig.kmsKey, '^keypattern[a-z]$')
    actionType: ALLOW
    displayName: Enforce session KMS Key pattern.
    description: Only allow session template creation or update if it sets the KMS key to an
    allowable pattern.
בתבנית הסשן צריך להגדיר את הקידומת של מאגר האחסון הזמני לערך מותר.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionTemplateStagingBucketPrefix
    resourceTypes:
    - dataproc.googleapis.com/SessionTemplate
    methodTypes:
    - CREATE
    - UPDATE
    condition: resource.environmentConfig.executionConfig.stagingBucket.startsWith(ALLOWED_PREFIX)
    actionType: ALLOW
    displayName: Enforce session staging bucket prefix.
    description: Only allow session template creation or update if it sets the staging
    bucket prefix to ALLOWED_PREFIX.
הגדרת הזיכרון של מפעיל תבניות הסשן חייבת להסתיים בסיומת m ולהיות קטנה מ-20,000 m.
    name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionTemplateExecutorMemoryMax
    resourceTypes:
    - dataproc.googleapis.com/SessionTemplate
    methodTypes:
    - CREATE
    - UPDATE
    condition: ('spark.executor.memory' in resource.runtimeConfig.properties) &&
    (resource.runtimeConfig.properties['spark.executor.memory'].endsWith('m')) &&
    (int(resource.runtimeConfig.properties['spark.executor.memory'].split('m')[0])<20000)
    actionType: ALLOW
    displayName: Enforce session executor maximum memory.
    description: Only allow session template creation or update if the executor memory setting ends
    with a suffix 'm' and is less than 20000 m.

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