The volumeMount defines the mountPath (which becomes a directory inside the pod) as /etc/kubernetes/azure.json and mounts the ConfigMap as azure.json within it, causing it's real location to be /etc/kubernetes/azure.json/azure.json.
Hence, the error about /etc/kubernetes/azure.json being a directory is true.
When userDefinedMSI is enabled, the correct mountPath should be /etc/kubernetes/, so that the ConfigMap is mounted to /etc/kubernetes/azure.json as intended.
Introducing an if-else-block in the volumeMount section of the deployments
If the ConfigMap is mounted (userDefinedMSI.enabled == true), use Helm's dir function in order to get the directory path of .Values.cloudConfig (e.g., /etc/kubernetes/)
Using Helm's base function to set the path of the configMap's azure.json key to the filename set in .Values.cloudConfig (e.g., azure.json)
These changes fix the mentioned issue while still mounting the ConfigMap to whatever path is defined in .Values.cloudConfig.
Problem Statement
I encountered the following error when setting
global.userDefinedMSI.enabled
to true, causing the controller and env-injector pods to crash:A short excerpt from the rendered
controller-deployment.yaml
explains the issue:The volumeMount defines the mountPath (which becomes a directory inside the pod) as
/etc/kubernetes/azure.json
and mounts the ConfigMap asazure.json
within it, causing it's real location to be/etc/kubernetes/azure.json/azure.json
.Hence, the error about
/etc/kubernetes/azure.json
being a directory is true.When userDefinedMSI is enabled, the correct mountPath should be
/etc/kubernetes/
, so that the ConfigMap is mounted to/etc/kubernetes/azure.json
as intended.Steps to Reproduce
Chart.yaml:
values.yaml:
Commands:
Resolution
This PR resolves the issue by:
.Values.cloudConfig
(e.g.,/etc/kubernetes/
).Values.cloudConfig
(e.g.,azure.json
)These changes fix the mentioned issue while still mounting the ConfigMap to whatever path is defined in
.Values.cloudConfig
..