If I have a ConfigMap like so:
apiVersion: v1
kind: ConfigMap
metadata:
name: id-config
data:
uuid: "{{ randAlphaNum 32 }}"
and a StatefulSet specification like so (taken and slightly modified from kubernetes' StatefulSet Basics page):
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
ports:
- port: 80
name: web
clusterIP: None
selector:
app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: "nginx"
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: registry.k8s.io/nginx-slim:0.8
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
env:
- name: UUID
valueFrom:
configMapKeyRef:
name: id-config
key: uuid
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
Will randAlphaNum
only be called once, when the initial deployment occurs, and then the value returned by randAlphaNum
is stored in the uuid
key and used if a pod restarts? Or will randAlphaNum
be called every time a pod is created or restarted, with a different uuid being returned every time? Thanks in advance.
When you deploy something with Helm you need to differentiate between two distinct things that are happening:
helm
CLI.Entries in the manifest files such as {{ randAlphaNum 32 }}
are rendered in step 1 and the pre-rendered results are sent to the Kubernetes API. It will only change if you ask Helm to render and deploy again.