I am checking how to use statefullset on kubernet to deploy my service. In stateFullSet, I able to know the pods names because it would be always the stateFullSet name + a sequence number like:
app-0
app-1
app-2
so I would like to have a specific configuration in configMap for each pod and the pod would reading the config map based on the pod hostname.
It would be something like:
spec:
containers:
- name: cgwcontainer
image: helioay/nginx
volumeMounts:
- name: config-volume
mountPath: /opt/app/config
volumes:
- name: config-volume
configMap:
# Provide the name of the ConfigMap containing the files you want
# to add to the container
name: "pod_host_name"
I have seen that I can get the pod hostname based on the POD information "metadata.name" , but I am not sure if I am able to use this information as configMap name value. I know it is possible to set environment variables like:
env:
- name: NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
Is it possible to use similar solution but for the configMap name?
Thanks.