מעבר מ-ConfigManagement API אל PolicyController API

בדף הזה מוסבר איך להעביר את הניהול של Policy Controller מ-ConfigManagement API ל-PolicyController API. ממשק PolicyController API מציע את אותן יכולות להתקנה ולניהול של Policy Controller.

החל מאפריל 2025, גרסה 1.21 ואילך של configManagement API לא תומכות יותר בהתקנה או בעדכונים של Policy Controller. ניסיון לשדרג או להתקין את Policy Controller באמצעות השיטה הזו ייכשל עם שגיאה. כדי להמשיך להשתמש ב-Policy Controller, צריך לפעול לפי ההוראות שבדף הזה כדי לבצע את המעבר.

השלבים להעברה מלאה משתנים בהתאם לשיטת ההתקנה שבה השתמשתם כדי להתקין את Policy Controller.

אם אתם משתמשים בפקודות ה-CLI של gcloud PolicyController שמתחילות ב-gcloud container fleet policycontroller, אתם כבר משתמשים ב-API של PolicyController. לא נדרשת כל פעולה מצידך. אחרת, כדאי לעיין בהוראות של השיטה שבה השתמשתם כדי להתקין את Policy Controller:

config management

אם אתם משתמשים בפקודות של gcloud CLI שמתחילות ב-gcloud alpha container fleet config-management, עליכם לעבור לשימוש בפקודות של Policy Controller ב-CLI של gcloud שמתחילות ב-gcloud container fleet policycontroller. במסמכי העזר של ה-CLI של gcloud יש רשימה של פקודות. לא נדרשת כל פעולה נוספת.

אם קובץ apply spec של Google Cloud CLI כולל את הבלוק policyController, צריך להסיר אותו כדי להבטיח תאימות ל-סנכרון תצורות.

Terraform

אם אתם משתמשים במשאב Terraform שמגדיר את Policy Controller עם שם התכונה "configmanagement", אתם צריכים לעבור למשאב Terraform עם שם התכונה "policycontroller". כדי לעשות את זה, מבצעים את השלבים הבאים:

  1. מעתיקים את קובץ Terraform הקיים לקובץ חדש, או מעדכנים את קובץ Terraform ומוסיפים את השורות הבאות:

    resource "google_gke_hub_feature" "feature" {
      name = "policycontroller"
      location = "global"
    }
    
    resource "google_gke_hub_feature_membership" "feature_member" {
      feature = google_gke_hub_feature.feature.name # "policycontroller"
      location = "global"
      membership = MEMBERSHIP_NAME
      project = PROJECT_ID
       policycontroller {
          policy_controller_hub_config {
            install_spec = "INSTALL_SPEC_ENABLED"
        }
      }
    }
    

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

    • MEMBERSHIP: שם החברות של האשכול הרשום שמותקן בו Policy Controller.
    • PROJECT_ID: מזהה הפרויקט.
  2. מסירים את הבלוק "policy_controller" מהמשאב הקיים של Terraform. אפשר למצוא את הבלוק מתחת לבלוק "configmanagement". אם אתם משתמשים במשאב כדי לנהל רק את Policy Controller, אתם יכולים להסיר את כל הבלוק configmanagement. אם אתם משתמשים במשאב כדי לנהל את סנכרון תצורות, הקפידו להסיר רק את הבלוק Policy Controller. לדוגמה, הבלוק configmanagement יכול להיראות כך:

    resource "google_gke_hub_feature_membership" "feature_member" {
       provider   = google-beta
       location   = "global"
       feature    = "configmanagement"
       membership = google_gke_hub_membership.membership.membership_id
       configmanagement {
          version = "1.8.0"
          config_sync {
             source_format = "unstructured"
             git {
             }
          }
          # if you're still using the config_sync block, delete only the policy_controller block
          policy_controller {
             enabled                    = true
             template_library_installed = true
             referential_rules_enabled  = true
          }
       }
    }
    
  3. מייבאים את ההגדרות של תכונת החברות ב-Policy Controller באחת מהדרכים הבאות:

    1. מריצים את הפקודה הבאה:

      terraform import "google_gke_hub_feature.feature" "projects/PROJECT_ID/locations/global/features/policycontroller"
      terraform import "google_gke_hub_feature_membership.feature_member" "projects/PROJECT_ID/locations/global/features/policycontroller/membershipId/MEMBERSHIP_NAME"
      
    2. מוסיפים בלוק ייבוא למשאב Terraform:

      import {
         to = google_gke_hub_feature_membership.feature_member
         id = "projects/PROJECT_ID/locations/global/features/policycontroller/membershipId/MEMBERSHIP_NAME"
      }
      import {
         to = google_gke_hub_feature.feature
         id = "projects/PROJECT_ID/locations/global/features/policycontroller"
      }
      
  4. מחילים את ההגדרות של Policy Controller:

    terraform apply
    
  5. אופציונלי: אחרי שהייבוא מסתיים, אפשר להסיר את בלוק הייבוא ממשאב Terraform. לחלופין, אפשר להשאיר את בלוק הייבוא בהגדרה כתיעוד של המקור של המשאב.

Config Connector

כדי להפסיק להשתמש במפרט configmanagement.policyController, מבצעים את השלבים הבאים:

  1. יוצרים GKEHubFeatureMembership מפרט חדש עם שדות החובה policycontroller. חשוב לוודא שהגדרתם את השדה resourceID לערך policyController.

  2. אם יש לכם GKEHubFeatureMembership קיים שמשתמש בשדה spec.configmanagement.policyController, צריך להסיר את כל השדות policycontroller מהמפרט של configmanagement.

kubectl

אם אתם משתמשים בפקודות kubectl כדי לנהל את Policy Controller עם אובייקט ConfigManagement, אתם צריכים לעבור לשימוש בפקודות Policy Controller של ה-CLI של gcloud שמתחילות ב-gcloud container fleet policycontroller. לא נדרשת כל פעולה נוספת.

אם אובייקט ConfigManagement כולל את הבלוק policyController, צריך להסיר אותו כדי לשמור על תאימות ל-סנכרון תצורות.

כדי לקבל מידע נוסף על Policy Controller API, מומלץ לעיין במקורות המידע הבאים: