Kubernetes version: v1.31.0
Host OS: Ubuntu
i have different pvc in different node
node1:
mypvc-node1
node2:
mypvc-node2 …
when install Daemonset dynamic get node in env and append in pvc claim name
I am try to volumes in PersistentVolumeClaim(PVC) dynamic append node name like below from environment variable but not working
containers:
- name: node-pvc-container
image: busybox
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName # Get node name dynamically
volumeMounts:
- name: storage
mountPath: /mydaemon
volumes:
- name: storage
persistentVolumeClaim:
claimName: mypvc-$(NODE_NAME) # Trying to append node name to PVC name
Problem:
The PVC name in volumes.persistentVolumeClaim.claimName does not resolve $(NODE_NAME), so it remains as mypvc-$(NODE_NAME) instead of dynamically appending the actual node name.
I need a way to ensure that each node gets a unique PVC, ideally named mypvc-{node-name}