本文档是 GCP Service Broker 的 GitHub 代码库上显示的文档修订版。
前提条件
- 安装了 Kf 的集群。
gcloud
:按照这些说明安装 gcloud CLI。kubectl
:安装gcloud
后,运行gcloud components install kubectl
。helm
:按照这些说明安装helm
CLI。git
:需要 Git 才能克隆代码库。
配置
选择项目
选择要用于本教程其余部分的 Google Cloud 项目。它应该是您的 Kf 集群所用的项目。
您必须是所选项目的所有者。(可选)更改以下值以反映您的环境,然后在终端中设置以下环境变量:
export PROJECT_ID=$(gcloud config get-value project)
export SERVICE_ACCOUNT_NAME=kf-gcp-broker
为 Broker 创建服务账号
创建服务账号:
gcloud iam service-accounts create $SERVICE_ACCOUNT_NAME
创建新凭据以允许 Broker 进行身份验证,并将凭据下载到
key.json
:gcloud iam service-accounts keys create key.json --iam-account $SERVICE_ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com
向 Broker 授予项目所有者权限:
gcloud projects add-iam-policy-binding $PROJECT_ID --member serviceAccount:$SERVICE_ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com --role "roles/owner"
启用必需的 API
现在,您需要启用 API 以使 Broker 预配资源。
Broker 具有运行它所需的一些 API,还有一些 API 是可选的,但必须启用才能预配特定类型的资源。
需要 Cloud Resource Manager 和 Identity and Access Management API 才能运行代理。如需启用它们,请输入以下命令:
gcloud services enable cloudresourcemanager.googleapis.com iam.googleapis.com --project $PROJECT_ID
启用 API
为了在项目上预配 Cloud 服务,Kf 建议至少启用以下 API:
GCP Service Broker 还支持多种其他服务,您可以通过启用此处列出的 API 来添加对这些服务的支持。
安装 Service Broker
将 GCP Service Broker 克隆到本地工作站,并使用
cd
切换到该工作站:git clone --depth=1 "https://github.com/GoogleCloudPlatform/gcp-service-broker"
cd gcp-service-broker/deployments/helm/gcp-service-broker
更新 Helm 图表的依赖项:
helm dependency update
修改文件
values.yaml
并将broker.service_account_json
的值设置为包含key.json
的全部内容的字符串。可选:通读其余属性并更改任何适合您的环境所需的内容。
# ... broker: # ... service_account_json: "contents of key.json go here" # ...
如果在生产环境中运行,请将
mysql.embedded
设置为 false,并为具有自动备份和故障切换的外部 MySQL 数据库提供凭据。为 GCP Service Broker 创建 Kubernetes 命名空间:
kubectl create namespace gcp-service-broker
安装代理:
helm install gcp-service-broker --set svccat.register=false --namespace gcp-service-broker .
向 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"
确认安装 Broker
运行 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 部署的应用。