Helm Chart Templates to Rescue

Here I will demonstrate how we can use Helm charts to achieve multi version support for a service in declarative fashion.

Helm template engine supports flow control. We can use range structure to which provides a “for-each” style loop. Following is the example values.yaml file:

Note that versions is an array, each item in the array contains the variables specific to a service version. In above example I have a stable version and other next-gen version.

Following snippet shows corresponding deployment spec:

This deployment template file iterates over all versions defined in the Values.yaml and creates corresponding Deployment and RouteRule specification. I am leveraging Istio for doing Header based routing. The rule specifies that if request contains a version header, route it to the corresponding service version.

Note that one version can be as similar or different from the other version as needed. No assumptions are made in this regard. Each service version can be updated by just updating corresponding config in values.yaml 's versions array.

Using this trick — multi-version services can be supported in a declarative configuration-as-code fashion. Hope you find it useful.

Happy Helming!!!