GoogleCloudPlatform / k8s-config-connector

GCP Config Connector, a Kubernetes add-on for managing GCP resources
https://cloud.google.com/config-connector/docs/overview
Apache License 2.0
890 stars 218 forks source link

how to ref the IP of cloudsql once its done in deployment #166

Closed thecloudgeek closed 4 years ago

thecloudgeek commented 4 years ago

Hello,

We're trying to create a deployment that also uses CNRM to provision a cloudsql instance in the same spec file. But what we can't seem to figure out is how can one reference the IP of the cloudsql instance once it comes up in the deployment ref.

So if we had a structure like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-nomad
  namespace: demo
spec:
  ...
apiVersion: sql.cnrm.cloud.google.com/v1beta1
kind: SQLInstance
metadata:
  annotations:
    cnrm.cloud.google.com/project-id: OVERLAY
  name: grafana-db-03
  namespace: monitoring
spec:
  databaseVersion: POSTGRES_11
  region: OVERLAY
  settings:
    availabilityType: REGIONAL
    backupConfiguration:
      enabled: true
    ipConfiguration:
      ...
---
apiVersion: sql.cnrm.cloud.google.com/v1beta1
kind: SQLUser
metadata:
  annotations:
    cnrm.cloud.google.com/project-id: OVERLAY
  name: grafana
  namespace: monitoring
spec:
  instanceRef:
    name: grafana-db-03
  host: "%"
  password:
    valueFrom:
      secretKeyRef:
        name: grafana-db-creds
        key: GF_DATABASE_PASSWORD
---
apiVersion: sql.cnrm.cloud.google.com/v1beta1
kind: SQLDatabase
metadata:
  name: grafana
  namespace: monitoring
spec:
  charset: UTF8
  collation: en_US.UTF8
  instanceRef:
    name: grafana-db-03

Once k8s creates the cloudsql instance, how can I reference its IP in the kind: Deployment for example...

kibbles-n-bytes commented 4 years ago

Hey @thecloudgeek , we recommend that you use the Cloud SQL proxy in order to connect to your SQL instance. The instance connection name in practice can be determined ahead of time and baked into your configuration.

jjhuff commented 4 years ago

@kibbles-n-bytes That works ok for SQL (although it is a bit of a pain and I have performance concerns). However, the same issue applies for Redis/Memcache

AlexBulankou commented 4 years ago

In this case, this is dupe of https://github.com/GoogleCloudPlatform/k8s-config-connector/issues/88. @jjhuff , thanks for raising it. We are tracking the work to enable exposing the IP address of to-be-created services to other workloads, and Redis is the primary scenario for this. We'll update the linked issue once (https://github.com/GoogleCloudPlatform/k8s-config-connector/issues/88) once we have an update. Also if you are working with Google support or a technical account manager, we are happy to share more information - please ask them to to contact Config Connector team.

Closing as dupe of https://github.com/GoogleCloudPlatform/k8s-config-connector/issues/88.