Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Staging and Production on Kubernetes

I'm sharing the same cluster for 2 namespaces: staging and production. The only differences among the two namespaces are:

  1. Volumes mounted to certain pods (separate persistence between staging and production, obviously!)
  2. A couple of web-URLs for relative addressing
  3. A couple of IPs to databases used for sophisticated persistence

I have managed to address (2) and (3) as follows, so as to maintain a single YAML file for all ReplicationControllers:

  • Use ConfigMaps local to a namespace to define any configuration that is passed via environment variables into the pods
  • Use Services with Endpoints to handle a DNS entry pointing to different internal IPs

However, I'm unable to find a satisfactory way to have a reference for a gcePersistentDisk's pdName - I can't seem to use a ConfigMap, hence a little stumped. What would be the appropriate way to go about this? The best alternative seems to be to maintain 2 separate YAML files with different strings, but this has a code-smell as it is violating DRY.

Also, any constructive commentary on the rest of my setup as mentioned above is highly appreciated :-)

like image 876
Angad Avatar asked May 18 '16 11:05

Angad


Video Answer


1 Answers

You could probably create one PersistentVolumeClaim in each namespace. Take a look at Can a PVC be bound to a specific PV? on how to "pre-bind" PersistentVolumes to PersistentVolumeClaims.

Might not be an ideal solution but it probably works 'till PVCs support label selectors.

like image 128
jayme Avatar answered Oct 26 '22 19:10

jayme