carbonql / carbon-ts

(PRE-RELEASE ALPHA)
Apache License 2.0
4 stars 2 forks source link

Deployment dependencies (via. services and DNS) #3

Open grampelberg opened 6 years ago

grampelberg commented 6 years ago

Let's say, for discussion's sake, that I am creating a rails app in GKE. To access the database, I will need to run a cloud sql proxy (https://github.com/GoogleCloudPlatform/cloudsql-proxy/blob/master/Kubernetes.md). Now, I could either run this as a sidecar or as a deployment. For this instance, let's see how to do a deployment instead of a sidecar. Note, the proxy could either already be running (and something common in the namespace) or started on demand by this.

const sqlProxy = CloudSQLProxy("my-project", "database1", "/tmp/credentials.json")

const railsApp = Deployment()

# Env configuration.
railsApp.env("MYSQL_HOST", sqlProxy.clusterDNS())

# Config file
const cfg = fromJson("/tmp/config.json")
cfg.mysqlHost = sqlProxy.clusterDNS()

raisApp.file("config.json", cfg.toJson())