连接MySQL
gcloud方式
1 | gcloud sql connect cloud-sql-name -u root |
1 | ./cloud_sql_proxy -instances=project-ID:zone:name=tcp:9000 -credential_file=key.json |
cloud sql proxy
启用 Cloud SQL API
Create a Service Account -> Role:Cloud SQL Client
Create a Secrets,主要用于gce-proxy Docker
1 | kubectl create secret generic cloudsql-credentials --from-file=credentials.json=[PROXY_KEY_FILE_PATH] |
- Create a User/Password
1 | kubectl create secret generic cloudsql-custom-credentials --from-literal=username=proxyuser --from-literal=password=[PASSWORD] |
docker proxy
创建用户
1 | gcloud sql users create [USER_NAME] [HOST] --instance=[INSTANCE_NAME] --password=[PASSWORD] |