0
votes

Kubernetes provides easy tools for rolling out and rolling back changes to Deployments and Daemonsets. However, deployments are often tightly associated with other kubernetes primitives like Secrets or Services, and I'd like to know how to do the same for those as they directly affect the running state of the app/cluster as well.

For example, if I change some ports in my service or change a Secrets-based environment variable (then restart my pods), I may break something and want to rollback the configuration to the previous version.

How can I do this most easily?

1

1 Answers

2
votes

The features you described are not covered by the Kubernetes API.

I would suggest that you look into Helm which is the Kubernetes Application manager. Helm would allow you to upgrade or rollback all resources associated with your application.

You can find an example Helm package here.
To install this package and all it's Kubernetes Resources you can use helm install nginx --name my-nginx.
This allows you to upgrade your package helm upgrade my-nginx nginx and rollback to the previous version with is there the 0 version: helm rollback my-nginx 0.

Performing a rolling upgrade of your pods when you change your secret or configmap can be done by adding an annotation to your pods that is based on the state of your configmap.
Example:

kind: Deployment
spec:
  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}