Today I hade the problem that i wanted to install a configmap only once but keep it after each upgrade, which wasnt as easy i thought before. Since it took my quite some time to figure this one out, here a short how to:
Only run once
At first I fell for the mistake of installing the Ressource only once and the leaving it at that like this:
1
2
3
4
5
6
7
kind: ConfigMap
apiVersion: v1
metadata:
---
kind: ConfigMap
apiVersion: v1
metadata:
Unfortunately Helm isnt working like this. Instead helm validates my expression as true and doesnt deploy the configmap. But then, since the configmap is no longer deployed its deleted by helm afterwards since its orphaned.
This lead me to the second approach of keeping the data.
Keep the data
As far as I found out there are 2 ways to keep the data in helm:
lookup
This is the solution i settled with, i havent tested it yet with huge configmaps but I´m confident it will work as well =).
1
2
3
4
5
6
7
8
9
kind: ConfigMap
apiVersion: v1
metadata:
name: example-conf
namespace:
data:
app.yml: |
use-default: true
annotation
The disadvantage of this solution is: The configmap is kept even after a helm uinstall and will no longer be managed by helm. Of course it would be deleted after the namespace is removed.
1
2
3
4
5
6
7
8
9
10
kind: ConfigMap
apiVersion: v1
metadata:
name: example-conf
namespace:
annotations:
"helm.sh/resource-policy": keep
data:
app.yml: |
use-default: true
Comments
Comment on Github