I’m trying to make a k8s charm and the pod uses a configmap to configure itself. I don’t see a way to create one though. How should I go about building this for my charm?
Juju charms don’t create config maps directly - they specify file sets which are mounted at specified locations in the docker images.
Internally, Juju creates a config map volume source to do that. The config map is called:
So if the
myapp charm produced a pod spec yaml like this:
files: - name: foocfg mountPath: /var/lib/foo files: file1: | [config] foo: bar
There would be a config map called
myapp-foocfg-config created to back the volume mounted into the pod.
I’m seeing things take the configmap on the command line for the docker image. Metallb does this as does the nginx ingress controller. This means the docker image itself is talking to the api server and reading the config map. This makes the image tied to Kubernetes, but these things seem pretty Kubernetes-specific. I think Juju will need a way to handle this and I wouldn’t want to rely on magically knowing that a configmap will be made with a specific name. I would prefer to see the name exposed or another mechanism to specify this.