From d917455a480558ef92529c4e121ee0fdfce00965 Mon Sep 17 00:00:00 2001 From: Matt Conway Date: Mon, 23 Aug 2021 12:18:54 -0400 Subject: [PATCH] document restarts on configmap/secret changes --- README.md | 5 ++++- examples/deployment/values-modular.yaml | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b53382..5fb89f7 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,10 @@ To use them as files on disk in a pod: Note that config map updates don't get seen by a running pod. You can use something like [Reloader](https://github.com/stakater/Reloader) to automate restarting the pod on a ConfigMap change, or read config from mounted volumes -for configmaps/secrets, which do get updated automatically in a running pod. +for configmaps/secrets, which do get updated automatically in a running pod. If +you are also [using kubetruth to deploy](examples/deployment), then you can make +your deployment manifest include a version string generated from a hash of the +parameters, thereby forcing a re-deploy when your config changes. ## Additional configuration diff --git a/examples/deployment/values-modular.yaml b/examples/deployment/values-modular.yaml index 029cadc..d619b87 100644 --- a/examples/deployment/values-modular.yaml +++ b/examples/deployment/values-modular.yaml @@ -19,7 +19,9 @@ projectMappings: # Define an override project mapping to enable processing of a single project # for this example. This will also gain the default `resource_templates` for # generating configmap and secret resource, but if not desired, those can be - # skipped by setting them to an empty string. + # skipped by setting them to an empty string. In a real world scenario you + # would want to add the deployment templates in an override that matches + # multiple projects in order to share its behavior across those projects deploytest: scope: "override" skip: false @@ -53,6 +55,13 @@ projectMappings: metadata: labels: app: "{{ parameters.app_name }}" + # Adding version labels here to demonstrate restart on a + # configmap change. An alternate method would be to make the + # configmap name based on the hash thereby forcing the restart + # whilst preserving the old configmap + # + parameters_version: "{{ parameters | sort | to_json | sha256 | slice: 0, 7 }}" + secrets_version: "{{ secrets | sort | to_json | sha256 | slice: 0, 7 }}" spec: containers: - name: "{{ parameters.image_name }}"