התקנה של GCP Service Broker

המסמך הזה הוא גרסה שעברה שינוי של התיעוד שמופיע במאגר GitHub של GCP Service Broker.

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

  1. קלאסטר עם Kf מותקן.
  2. gcloud: פועלים לפי ההוראות האלה כדי להתקין את ה-CLI של gcloud.
  3. kubectl: אחרי שמתקינים את gcloud, מריצים את gcloud components install kubectl.
  4. helm: פועלים לפי ההוראות האלה כדי להתקין את helmה-CLI.
  5. git: נדרש Git כדי לשכפל מאגר.

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

בחירת פרויקט

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

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

export PROJECT_ID=$(gcloud config get-value project)
export SERVICE_ACCOUNT_NAME=kf-gcp-broker

יצירת חשבון שירות עבור הברוקר

  1. יוצרים את חשבון השירות:

    gcloud iam service-accounts create $SERVICE_ACCOUNT_NAME
  2. יוצרים פרטי כניסה חדשים כדי לאפשר לתווך לבצע אימות, ומורידים את פרטי הכניסה אל key.json:

    gcloud iam service-accounts keys create key.json --iam-account $SERVICE_ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com
  3. מעניקים לברוקר הרשאות של בעלי פרויקט:

    gcloud projects add-iam-policy-binding $PROJECT_ID --member serviceAccount:$SERVICE_ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com --role "roles/owner"

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

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

לסוכן יש כמה ממשקי API שנדרשים להרצת הסוכן, וכמה ממשקי API אופציונליים שצריך להפעיל כדי להקצות משאבים מסוג מסוים.

כדי שהברוקר יפעל, צריך להשתמש בממשקי Cloud Resource Manager API ובממשקי Identity and Access Management API. כדי להפעיל אותן:

gcloud services enable cloudresourcemanager.googleapis.com iam.googleapis.com --project $PROJECT_ID

הפעלת ממשקי ה-API

כדי להקצות שירותי ענן בפרויקט, מומלץ להפעיל לפחות את ממשקי ה-API הבאים:

  1. CloudSQL API
  2. CloudSQL Admin API
  3. Pub/Sub API
  4. Redis API
  5. Storage API

‫GCP Service Broker תומך גם במגוון שירותים אחרים שאפשר להוסיף להם תמיכה על ידי הפעלת ממשקי ה-API שמפורטים כאן.

התקנת מתווך השירותים

  1. משכפלים את GCP Service Broker אל תחנת העבודה המקומית ומעבירים את cd אליו:

    git clone --depth=1 "https://github.com/GoogleCloudPlatform/gcp-service-broker"
    cd gcp-service-broker/deployments/helm/gcp-service-broker
  2. מעדכנים את התלויות של תרשים Helm:

    helm dependency update
  3. עורכים את הקובץ values.yaml ומגדירים את הערך של broker.service_account_json כמחרוזת שמכילה את כל התוכן של key.json.

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

    # ...
    broker:
      # ...
      service_account_json: "contents of key.json go here"
    # ...
  4. אם מריצים בסביבת ייצור, צריך להגדיר את mysql.embedded כ-false ולספק פרטי כניסה למסד נתונים חיצוני של MySQL עם גיבויים אוטומטיים ויתירות כשל.

  5. יוצרים מרחב שמות של Kubernetes בשביל GCP Service Broker:

    kubectl create namespace gcp-service-broker
  6. מתקינים את הברוקר:

    helm install gcp-service-broker --set svccat.register=false --namespace gcp-service-broker .
  7. רושמים את הברוקר ב-Kf:

    kf create-service-broker gcp-service-broker \
      "$(kubectl get secret gcp-service-broker-auth -n gcp-service-broker -o jsonpath='{.data.username}' | base64 --decode)" \
      "$(kubectl get secret gcp-service-broker-auth -n gcp-service-broker -o jsonpath='{.data.password}' | base64 --decode)" \
      "http://gcp-service-broker.gcp-service-broker.svc.cluster.local"

אישור ההתקנה של הברוקר

מריצים את kf marketplace. הפלט אמור להיראות כך:

Broker              Name                          Space       Status  Description
gcp-service-broker  google-stackdriver-profiler               Active  Continuous CPU and heap profiling to improve performance and reduce costs.
gcp-service-broker  google-stackdriver-monitoring             Active  Stackdriver Monitoring provides visibility into the performance, uptime, and overall health of cloud
gcp-service-broker  google-dataflow                           Active  A managed service for executing a wide variety of data processing patterns built on Apache Beam.
gcp-service-broker  google-cloudsql-mysql                     Active  Google CloudSQL for MySQL is a fully-managed MySQL database service.
gcp-service-broker  google-spanner                            Active  The first horizontally scalable, globally consistent, relational database service.
gcp-service-broker  google-ml-apis                            Active  Machine Learning APIs including Vision, Translate, Speech, and Natural Language.
gcp-service-broker  google-pubsub                             Active  A global service for real-time and reliable messaging and streaming data.
gcp-service-broker  google-datastore                          Active  Google Cloud Datastore is a NoSQL document database service.
gcp-service-broker  google-stackdriver-debugger               Active  Stackdriver Debugger is a feature of the Google Cloud Platform that lets you inspect the state of an
gcp-service-broker  google-firestore                          Active  Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL document database that simp
gcp-service-broker  google-bigtable                           Active  A high performance NoSQL database service for large analytical and operational workloads.
gcp-service-broker  google-storage                            Active  Unified object storage for developers and enterprises. Cloud Storage allows world-wide storage and r
gcp-service-broker  google-stackdriver-trace                  Active  Stackdriver Trace is a distributed tracing system that collects latency data from your applications
gcp-service-broker  google-cloudsql-postgres                  Active  Google CloudSQL for PostgreSQL is a fully-managed PostgreSQL database service.
gcp-service-broker  google-dialogflow                         Active  Dialogflow is an end-to-end, build-once deploy-everywhere development suite for creating conversatio
gcp-service-broker  google-bigquery                           Active  A fast, economical and fully managed data warehouse for large-scale data analytics.

ה-GCP Service Broker מותקן ואפשר להשתמש בו כדי ליצור שירותים ולקשר אותם לאפליקציות שפורסים באמצעות Kf.