When trying to evaluate how to connect to a Cloud SQL database from a Google Kubernetes Engine pod, there are a couple of ways to do this. One is to use a sidecar cloud proxy agent. Another is using a private IP and using a SSL connection between the two. Is there a clear case for either? Or do they both serve the same functionality? Is there one that is considered "best practice"?
Cloud SQL Proxy sidecar
The cloud sql proxy sidecar establishes a TCP connection into a proxy service that is hosted on Google's infrastructure. This then connects you to your cloud SQL instance on the Google network.
Pros
- Establishes a secure connection without you having to manage the crypto material in your application
- Connects to the instance and you don't have to manage DNS records or IP addresses
Cons
- You have to create a secret that stores a service account key.
- You have to manage a sidecar instance along side your pod, which if that fails, you no longer can connect to your database
- Latency added due to the number of layers you have to the proxy layers
Private IP + SSL
Using a private IP and connecting the instance to your VPC allows you to use an internal IP address, that is not publicly routed, and keeps traffic in your VPC instance. On top of that, setting up SSL only connections to your database to make sure traffic is secure from point to point.
Pros
- Low latency connection to the database because its a point to point connection
- You manage the keys between the services
- No outside dependencies or systems needed to connect between the two
Cons
- You have to manage the SSL certificate inside of the connection
- You have to verify that the IP and DNS records setup in your cluster are correct
Am I missing something? Do these two indeed provide the same thing? Is there not an absolutely clear winner between the two and you can pick whichever one you see that best fits your style?