חיבור מ-Google Kubernetes Engine

בדף הזה מוסבר איך להגדיר חיבור מאפליקציה שפועלת ב-Google Kubernetes Engine ‏ (GKE) למכונה של Cloud SQL.

להוראות מפורטות להפעלת אפליקציית אינטרנט לדוגמה של Google Kubernetes Engine שמחוברת ל-Cloud SQL, קראו את המדריך למתחילים בנושא התחברות מ-Google Kubernetes Engine.

‫Cloud SQL הוא שירות מנוהל של מסד נתונים, שבעזרתו אפשר ליצור, לתחזק ולנהל מסדי נתונים רלציוניים בענן.

‫Google Kubernetes Engine היא דרך פשוטה לפרוס, לנהל ולהתאים לעומס את Kubernetes באופן אוטומטי.

מידע על חיבור Google Kubernetes Engine ל-Cloud SQL

כדי לגשת למכונה של Cloud SQL מאפליקציה שפועלת ב-Google Kubernetes Engine, אתם יכולים להשתמש ב-Cloud SQL Auth Proxy (עם כתובת IP ציבורית או פרטית), או להתחבר ישירות באמצעות כתובת IP פרטית.

השימוש ב-Cloud SQL Auth Proxy הוא הדרך המומלצת להתחבר ל-Cloud SQL, גם כשמשתמשים בכתובת IP פרטית. הסיבה לכך היא ש-Cloud SQL Auth Proxy מספק הצפנה ואימות חזקים באמצעות IAM, שיכולים לעזור לשמור על אבטחת מסד הנתונים.

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

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

כדי להתחבר ל-Cloud SQL, צריך:

  • אשכול GKE, עם כלי שורת הפקודה kubectl שמותקן ומוגדר לתקשר עם האשכול.

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

    כדי להתחבר באמצעות כתובת IP פרטית, אשכול GKE חייב להיות מבוסס-VPC ומקושר לאותה רשת VPC כמו מכונת Cloud SQL.

  • נוצר מופע.

    למידע נוסף על יצירת מכונה של Cloud SQL, קראו את המאמר יצירת מכונות.

  • חשבון משתמש של SQL Server שמוגדר במכונה.

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

מידע על סודות ב-Kubernetes

ב-Kubernetes, סודות הם דרך מאובטחת להעביר פרטי הגדרה לאפליקציה. אתם יכולים ליצור Secret עם פרטים כמו שם מסד הנתונים, המשתמש והסיסמה, ולהוסיף אותו לאפליקציה כמשתני סביבה.

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

  • סוד של פרטי כניסה למסד נתונים כולל את שם המשתמש במסד הנתונים שאליו אתם מתחברים, ואת הסיסמה של המשתמש למסד הנתונים.
  • אם מתחברים באמצעות Cloud SQL Auth Proxy, אפשר להשתמש ב-Secret כדי לשמור את קובץ פרטי הכניסה של חשבון השירות.
  • אם מתחברים באמצעות כתובת IP פרטית, אפשר להשתמש ב-Secret כדי לציין את כתובת ה-IP הפרטית של המכונה ב-Cloud SQL.

דוגמאות פתורות מלאות לשימוש ב-Secrets מופיעות במאגרי GitHub שמוזכרים בהמשך הדף.

יצירת אובייקט Secret

  1. כדי ליצור את אובייקטי הסוד, משתמשים בפקודה kubectl create secret.

    כדי ליצור סוד לפרטי הכניסה למסד הנתונים:

    kubectl create secret generic <YOUR-DB-SECRET> \
      --from-literal=username=<YOUR-DATABASE-USER> \
      --from-literal=password=<YOUR-DATABASE-PASSWORD> \
      --from-literal=database=<YOUR-DATABASE-NAME>
    
  2. אחרי שיוצרים את האובייקטים, אפשר לראות אותם בקטע Configuration בדף Google Kubernetes Engine במסוףGoogle Cloud .

התחברות ל-Cloud SQL באמצעות Cloud SQL Auth Proxy

כשמתחברים באמצעות Cloud SQL Auth Proxy, הוא מתווסף ל-pod באמצעות תבנית מאגר sidecar. מאחר שהקונטיינר של Cloud SQL Auth Proxy נמצא באותו pod של האפליקציה, האפליקציה יכולה להתחבר ל-Cloud SQL Auth Proxy באמצעות localhost, מה שמשפר את האבטחה והביצועים.

מידע נוסף על Cloud SQL Auth Proxy זמין במאמר מידע על Cloud SQL Auth Proxy. למידע נוסף על עבודה עם Pods, קראו את הסקירה הכללית על Pod במסמכי התיעוד של Kubernetes.

כדי להתחבר באמצעות Cloud SQL Auth Proxy, צריך:

  1. שם החיבור של המכונה ב-Cloud SQL.

    שם החיבור למכונה זמין בדף Cloud SQL Instance details במסוף Google Cloud או באמצעות הפקודה gcloud sql instances describe INSTANCE_ID.

  2. המיקום של קובץ המפתח שמשויך לחשבון שירות עם ההרשאות המתאימות למכונה שלכם ב-Cloud SQL.

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

  3. ‫Cloud SQL Admin API מופעל.

    התפקידים שנדרשים כדי להפעיל ממשקי API

    כדי להפעיל ממשקי API, צריך את ההרשאה serviceusage.services.enable. אם יצרתם את הפרויקט, סביר להניח שכבר יש לכם את ההרשאה הזו דרך התפקיד "בעלים" (roles/owner). אחרת, תוכלו לקבל את ההרשאה הזו דרך התפקיד "אדמין בממשק 'שימוש בשירות'" (roles/serviceusage.serviceUsageAdmin). איך מקצים תפקידים

    להפעלת ה-API

הגדרת חשבון השירות ב-Cloud SQL Auth Proxy

השלב הראשון בהפעלת Cloud SQL Auth Proxy ב-Google Kubernetes Engine הוא ליצור חשבון שירות של Google‏ (GSA) שייצג את האפליקציה. מומלץ ליצור חשבון שירות ייחודי לכל אפליקציה, במקום להשתמש באותו חשבון שירות בכל מקום. המודל הזה מאובטח יותר כי הוא מאפשר להגביל את ההרשאות לכל אפליקציה בנפרד.

חשבון השירות של האפליקציה צריך לעמוד בקריטריונים הבאים:

  • להיות חלק מפרויקט שבו מופעל Cloud SQL Admin API
  • קיבל את תפקיד ה-IAM של לקוח Cloud SQL (או תפקיד מקביל) בפרויקט שמכיל את המכונה שאליה רוצים להתחבר.
  • אם מתחברים באמצעות כתובת IP פרטית, צריך להשתמש באשכול GKE שמותאם ל-VPC, באותו VPC של מכונת Cloud SQL.

צריך להגדיר את GKE כך שיספק את חשבון השירות ל-Cloud SQL Auth Proxy. יש שתי דרכים מומלצות לעשות את זה: Workload Identity או קובץ מפתח של חשבון שירות.

Workload Identity

אם אתם משתמשים ב-Google Kubernetes Engine, השיטה המועדפת היא להשתמש בתכונה Workload Identity של GKE. בשיטה הזו אפשר לקשר חשבון שירות של Kubernetes‏ (KSA) לחשבון שירות של Google‏ (GSA). לאחר מכן, אפליקציות שמשתמשות ב-KSA התואם יוכלו לגשת ל-GSA.

חשבון שירות של Google ‏ (GSA) הוא זהות ב-IAM שמייצגת את האפליקציה שלכם ב-Google Cloud. באופן דומה, חשבון שירות של Kubernetes‏ (KSA) הוא זהות שמייצגת את האפליקציה שלכם באשכול של Google Kubernetes Engine.

‫Workload Identity מקשר בין KSA ל-GSA, כך שכל פריסה עם ה-KSA הזה תאומת כ-GSA באינטראקציות שלה עם Google Cloud.

  1. הפעלת Workload Identity באשכול
  2. בדרך כלל, לכל אפליקציה יש זהות משלה, שמיוצגת על ידי זוג KSA ו-GSA. מריצים את הפקודה kubectl apply -f service-account.yaml כדי ליצור KSA לאפליקציה:

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: <YOUR-KSA-NAME> # TODO(developer): replace these values
  3. מפעילים את הקישור של IAM בין YOUR-GSA-NAME לבין YOUR-KSA-NAME:

    gcloud iam service-accounts add-iam-policy-binding \
    --role="roles/iam.workloadIdentityUser" \
    --member="serviceAccount:YOUR-GOOGLE-CLOUD-PROJECT.svc.id.goog[YOUR-K8S-NAMESPACE/YOUR-KSA-NAME]" \
    YOUR-GSA-NAME@YOUR-GOOGLE-CLOUD-PROJECT.iam.gserviceaccount.com
  4. מוסיפים הערה ל-YOUR-KSA-NAME כדי להשלים את הקישור:

    kubectl annotate serviceaccount \
    YOUR-KSA-NAME \
    iam.gke.io/gcp-service-account=YOUR-GSA-NAME@YOUR-GOOGLE-CLOUD-PROJECT.iam.gserviceaccount.com
  5. לסיום, חשוב לציין את חשבון השירות של אובייקט k8s.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: <YOUR-DEPLOYMENT-NAME>
    spec:
      selector:
        matchLabels:
          app: <YOUR-APPLICATION-NAME>
      template:
        metadata:
          labels:
            app: <YOUR-APPLICATION-NAME>
        spec:
          serviceAccountName: <YOUR-KSA-NAME>

קובץ מפתח של חשבון שירות

לחלופין, אם אתם לא יכולים להשתמש ב-Workload Identity, מומלץ לטעון קובץ מפתח של חשבון שירות ל-pod של Cloud SQL Auth Proxy ולהשתמש בדגל --credentials-file.

  1. יוצרים קובץ פרטי כניסה למפתח של חשבון השירות:

    gcloud iam service-accounts keys create ~/key.json \
    --iam-account=YOUR-SA-NAME@project-id.iam.gserviceaccount.com
  2. הופכים את המפתח של חשבון השירות ל-Secret של k8s:

    kubectl create secret generic YOUR-SA-SECRET \
    --from-file=service_account.json=~/key.json
  3. מגדירים את הסוד כנפח אחסון ב-spec: של אובייקט ה-k8s:

    volumes:
      - name: <YOUR-SA-SECRET-VOLUME>
        secret:
          secretName: <YOUR-SA-SECRET>
  4. כדי לגשת לנפח מה-pod של Cloud SQL Auth Proxy, פועלים לפי ההוראות בקטע הבא.

הפעלת Cloud SQL Auth Proxy בתבנית sidecar

מומלץ להריץ את Cloud SQL Auth Proxy בתבנית sidecar (כקונטיינר נוסף שמשתף pod עם האפליקציה). אנחנו ממליצים על האפשרות הזו ולא על הפעלה כשירות נפרד, מכמה סיבות:

  • מונע חשיפה של תעבורת הנתונים ב-SQL באופן מקומי. Cloud SQL Auth Proxy מספק הצפנה בחיבורים יוצאים, אבל צריך להגביל את החשיפה של חיבורים נכנסים.
  • מונעת נקודת כשל בודדת. הגישה של כל אפליקציה למסד הנתונים לא תלויה באפליקציות האחרות, ולכן היא עמידה יותר.
  • מגבילה את הגישה ל-Cloud SQL Auth Proxy, ומאפשרת להשתמש בהרשאות IAM לכל אפליקציה במקום לחשוף את מסד הנתונים לכל האשכול.
  • מאפשר להגדיר את היקף הבקשות למשאבים בצורה מדויקת יותר. מכיוון ש-Cloud SQL Auth Proxy צורך משאבים באופן ליניארי לשימוש, התבנית הזו מאפשרת להגדיר את ההיקף ולבקש משאבים שיתאימו לאפליקציות שלכם ככל שהאפליקציה גדלה.

  • מוסיפים את Cloud SQL Auth Proxy להגדרת ה-pod בקטע initContainers, אלא אם משתמשים ב-Cloud Service Mesh או ב-Istio.

    אם אתם משתמשים ב-Cloud Service Mesh או ב-Istio, הוסיפו את Cloud SQL Auth Proxy בקטע containers.

    initContainers

    initContainers:
      - name: cloud-sql-proxy
        restartPolicy: Always
        # It is recommended to use the latest version of the Cloud SQL Auth Proxy
        # Make sure to update on a regular schedule!
        image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.14.1
        args:
          # If connecting from a VPC-native GKE cluster, you can use the
          # following flag to have the proxy connect over private IP
          # - "--private-ip"
    
          # If you are not connecting with Automatic IAM, you can delete
          # the following flag.
          - "--auto-iam-authn"
    
          # Enable structured logging with LogEntry format:
          - "--structured-logs"
    
          # Replace DB_PORT with the port the proxy should listen on
          - "--port=<DB_PORT>"
          - "<INSTANCE_CONNECTION_NAME>"
    
        securityContext:
          # The default Cloud SQL Auth Proxy image runs as the
          # "nonroot" user and group (uid: 65532) by default.
          runAsNonRoot: true
        # You should use resource requests/limits as a best practice to prevent
        # pods from consuming too many resources and affecting the execution of
        # other pods. You should adjust the following values based on what your
        # application needs. For details, see
        # https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
        resources:
          requests:
            # The proxy's memory use scales linearly with the number of active
            # connections. Fewer open connections will use less memory. Adjust
            # this value based on your application's requirements.
            memory: "2Gi"
            # The proxy's CPU use scales linearly with the amount of IO between
            # the database and the application. Adjust this value based on your
            # application's requirements.
            cpu: "1"

    containers

    - name: cloud-sql-proxy
      # It is recommended to use the latest version of the Cloud SQL Auth Proxy
      # Make sure to update on a regular schedule!
      image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.14.1
      args:
        # If connecting from a VPC-native GKE cluster, you can use the
        # following flag to have the proxy connect over private IP
        # - "--private-ip"
    
        # If you are not connecting with Automatic IAM, you can delete
        # the following flag.
        - "--auto-iam-authn"
    
        # Enable structured logging with LogEntry format:
        - "--structured-logs"
    
        # Replace DB_PORT with the port the proxy should listen on
        - "--port=<DB_PORT>"
        - "<INSTANCE_CONNECTION_NAME>"
    
      securityContext:
        # The default Cloud SQL Auth Proxy image runs as the
        # "nonroot" user and group (uid: 65532) by default.
        runAsNonRoot: true
      # You should use resource requests/limits as a best practice to prevent
      # pods from consuming too many resources and affecting the execution of
      # other pods. You should adjust the following values based on what your
      # application needs. For details, see
      # https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
      resources:
        requests:
          # The proxy's memory use scales linearly with the number of active
          # connections. Fewer open connections will use less memory. Adjust
          # this value based on your application's requirements.
          memory: "2Gi"
          # The proxy's CPU use scales linearly with the amount of IO between
          # the database and the application. Adjust this value based on your
          # application's requirements.
          cpu: "1"
  • אם אתם משתמשים במפתח של חשבון שירות, ציינו את נפח הסוד והוסיפו את הדגל --credentials-file לפקודה:

      # This flag specifies where the service account key can be found
      - "--credentials-file=/secrets/service_account.json"
    securityContext:
      # The default Cloud SQL Auth Proxy image runs as the
      # "nonroot" user and group (uid: 65532) by default.
      runAsNonRoot: true
    volumeMounts:
      - name: <YOUR-SA-SECRET-VOLUME>
        mountPath: /secrets/
        readOnly: true
  • בסיום, מגדירים את האפליקציה להתחבר באמצעות 127.0.0.1 בכל DB_PORT שציינתם בקטע של הפקודה.

קובצי תצורה לדוגמה:

Workload Identity

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: <YOUR-DEPLOYMENT-NAME>
spec:
  selector:
    matchLabels:
      app: <YOUR-APPLICATION-NAME>
  template:
    metadata:
      labels:
        app: <YOUR-APPLICATION-NAME>
    spec:
      serviceAccountName: <YOUR-KSA-NAME>
      containers:
        - name: <YOUR-APPLICATION-NAME>
          # ... other container configuration
          env:
            - name: DB_USER
              valueFrom:
                secretKeyRef:
                  name: <YOUR-DB-SECRET>
                  key: username
            - name: DB_PASS
              valueFrom:
                secretKeyRef:
                  name: <YOUR-DB-SECRET>
                  key: password
            - name: DB_NAME
              valueFrom:
                secretKeyRef:
                  name: <YOUR-DB-SECRET>
                  key: database
      initContainers:
        - name: cloud-sql-proxy
          restartPolicy: Always
          # It is recommended to use the latest version of the Cloud SQL Auth Proxy
          # Make sure to update on a regular schedule!
          image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.14.1
          args:
            # If connecting from a VPC-native GKE cluster, you can use the
            # following flag to have the proxy connect over private IP
            # - "--private-ip"

            # If you are not connecting with Automatic IAM, you can delete
            # the following flag.
            - "--auto-iam-authn"

            # Enable structured logging with LogEntry format:
            - "--structured-logs"

            # Replace DB_PORT with the port the proxy should listen on
            - "--port=<DB_PORT>"
            - "<INSTANCE_CONNECTION_NAME>"

          securityContext:
            # The default Cloud SQL Auth Proxy image runs as the
            # "nonroot" user and group (uid: 65532) by default.
            runAsNonRoot: true
          # You should use resource requests/limits as a best practice to prevent
          # pods from consuming too many resources and affecting the execution of
          # other pods. You should adjust the following values based on what your
          # application needs. For details, see
          # https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
          resources:
            requests:
              # The proxy's memory use scales linearly with the number of active
              # connections. Fewer open connections will use less memory. Adjust
              # this value based on your application's requirements.
              memory: "2Gi"
              # The proxy's CPU use scales linearly with the amount of IO between
              # the database and the application. Adjust this value based on your
              # application's requirements.
              cpu: "1"

מפתח לחשבון השירות

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: <YOUR-DEPLOYMENT-NAME>
spec:
  selector:
    matchLabels:
      app: <YOUR-APPLICATION-NAME>
  template:
    metadata:
      labels:
        app: <YOUR-APPLICATION-NAME>
    spec:
      containers:
        - name: <YOUR-APPLICATION-NAME>
          # ... other container configuration
          env:
            - name: DB_USER
              valueFrom:
                secretKeyRef:
                  name: <YOUR-DB-SECRET>
                  key: username
            - name: DB_PASS
              valueFrom:
                secretKeyRef:
                  name: <YOUR-DB-SECRET>
                  key: password
            - name: DB_NAME
              valueFrom:
                secretKeyRef:
                  name: <YOUR-DB-SECRET>
                  key: database
      initContainers:
        - name: cloud-sql-proxy
          restartPolicy: Always
          # It is recommended to use the latest version of the Cloud SQL Auth Proxy
          # Make sure to update on a regular schedule!
          image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.14.1
          args:
            # If connecting from a VPC-native GKE cluster, you can use the
            # following flag to have the proxy connect over private IP
            # - "--private-ip"

            # If you are not connecting with Automatic IAM AuthN, you can delete
            # the following flag.
            - "--auto-iam-authn"

            # Enable structured logging with LogEntry format:
            - "--structured-logs"

            # Replace DB_PORT with the port the proxy should listen on
            - "--port=<DB_PORT>"
            - "<INSTANCE_CONNECTION_NAME>"

            # This flag specifies where the service account key can be found
            - "--credentials-file=/secrets/service_account.json"
          securityContext:
            # The default Cloud SQL Auth Proxy image runs as the
            # "nonroot" user and group (uid: 65532) by default.
            runAsNonRoot: true
          volumeMounts:
            - name: <YOUR-SA-SECRET-VOLUME>
              mountPath: /secrets/
              readOnly: true
          # Resource configuration depends on an application's requirements. You
          # should adjust the following values based on what your application
          # needs. For details, see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
          resources:
            requests:
              # The proxy's memory use scales linearly with the number of active
              # connections. Fewer open connections will use less memory. Adjust
              # this value based on your application's requirements.
              memory: "2Gi"
              # The proxy's CPU use scales linearly with the amount of IO between
              # the database and the application. Adjust this value based on your
              # application's requirements.
              cpu: "1"
      volumes:
        - name: <YOUR-SA-SECRET-VOLUME>
          secret:
            secretName: <YOUR-SA-SECRET>

התחברות ל-Cloud SQL בלי Cloud SQL Auth Proxy

אפשר להתחבר מאשכול GKE מותאם ל-VPC למכונה של Cloud SQL באותו VPC באמצעות כתובת IP פרטית בלי Cloud SQL Auth Proxy, אבל זה פחות מאובטח.

  1. יוצרים סוד עם כתובת ה-IP הפרטית של המכונה:

    kubectl create secret generic <YOUR-PRIVATE-IP-SECRET> \
        --from-literal=db_host=<YOUR-PRIVATE-IP-ADDRESS>
    
  2. בשלב הבא, מוסיפים את הסוד למאגר של האפליקציה:

    - name: DB_HOST
      valueFrom:
        secretKeyRef:
          name: <YOUR-PRIVATE-IP-SECRET>
          key: db_host
  3. לבסוף, מגדירים את האפליקציה כך שתתחבר באמצעות כתובת ה-IP ממשתנה הסביבה DB_HOST. צריך להשתמש ביציאה הנכונה ל-SQL Server: ‏1433

קובץ תצורה לדוגמה:

כתובת IP פרטית

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: <YOUR-DEPLOYMENT-NAME>
spec:
  selector:
    matchLabels:
      app: <YOUR-APPLICATION-NAME>
  template:
    metadata:
      labels:
        app: <YOUR-APPLICATION-NAME>
    spec:
      containers:
      - name: <YOUR-APPLICATION-NAME>
        # ... other container configuration
        env:
        - name: DB_USER
          valueFrom:
            secretKeyRef:
              name: <YOUR-DB-SECRET>
              key: username
        - name: DB_PASS
          valueFrom:
            secretKeyRef:
              name: <YOUR-DB-SECRET>
              key: password
        - name: DB_NAME
          valueFrom:
            secretKeyRef:
              name: <YOUR-DB-SECRET>
              key: database
        - name: DB_HOST
          valueFrom:
            secretKeyRef:
              name: <YOUR-PRIVATE-IP-SECRET>
              key: db_host

פתרון בעיות

דרושה לך עזרה? לקבלת עזרה בפתרון בעיות בשרת ה-proxy, קראו את המאמר פתרון בעיות בחיבורים של Cloud SQL Auth Proxy או עיינו בדף התמיכה של Cloud SQL.

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