Shared environment variables versus DNS records for discovery
Kubernetes provides several mechanisms for global discovery across the cluster. If your storage cluster is not managed by Kubernetes, you still need to tell Kubernetes pods how to find it and access it. There are two main methods:
- DNS
- Environment variables
In some cases, you may want to use both where environment variables can override DNS.
Accessing external data stores via DNS
The DNS approach is simple and straightforward. Assuming your external storage cluster is load balanced and can provide a stable endpoint, then pods can just hit that endpoint directly and connect to the external cluster.
Accessing external data stores via environment variables
Another simple approach is to use environment variables to pass connection information to an external storage cluster. Kubernetes offers the ConfigMap
resource as a way to keep configuration separate from the container image. The configuration is a set of key-value pairs. The configuration...