Connecting Google Cloud SQL Credentials to Kubernetes Secret

12/8/2018

I am new to Kubernetes and I was playing with it on Google Cloud. I was going through the google-github-repo and stcox-gke-wordpress I am very confused as to what to provide for the secret cloudsql-instance-credentials. After going through some more documentation, I ended up creating a service account and downloaded the JSON Key and tried to provide that as cloudsql-instance-credentials.

dbCred: {
  type: '',
  project_id: '',
  private_key_id: '',
  private_key: '',
  client_email: '',
  client_id: '',
  auth_uri: '',
  token_uri: '',
  auth_provider_x509_cert_url: '',
  client_x509_cert_url: '',
}


apiVersion: v1
kind: Secret
metadata:
  name: cloudsql-instance-credentials
  namespace: wp-{{ .Values.name }}
  labels:
    app: wp-{{ .Values.name }}
type: Opaque
data:
  credentials.json: {{ .Values.dbCred | b64enc }}

But I ended up getting this error: error converting YAML to JSON: did not find expected key

I am pretty sure I am providing wrong dbCred. Any help will be appreciated :)

-- Kamil Kamili
gcloud
google-cloud-platform
google-cloud-sql
kubernetes

2 Answers

12/10/2018

cloudsql-instance-credentials is/are stored as a Kubernetes secret.

You skipped setting up this up. Go back to this tutorial:

-- John Hanley
Source: StackOverflow

12/9/2018

Since your Values.dbCred spans multiple lines, you need to tell yaml that, by using the pipe character |. Check this out.https://yaml-multiline.info

-- Bal Chua
Source: StackOverflow