Grant the dcgm-exporter DRA role read access to ConfigMaps - #2724
Grant the dcgm-exporter DRA role read access to ConfigMaps#2724rajathagasthya wants to merge 1 commit into
Conversation
Setting DCGM_EXPORTER_CONFIGMAP_DATA through dcgmExporter.env points the exporter at a ConfigMap of custom metrics that it reads from the Kubernetes API. On the GPUCluster path neither the namespaced Role nor the ClusterRole granted configmaps, so the read failed with a forbidden error and the exporter fell back to its built-in metrics without crashing. The ClusterPolicy path has granted this since before the feature existed. Add configmaps get/list to the namespaced Role. The Role is bound in the operator namespace only, so a namespace:name value pointing elsewhere is still denied. Signed-off-by: Rajath Agasthya <ragasthya@nvidia.com>
| resources: | ||
| - configmaps | ||
| verbs: | ||
| - get |
There was a problem hiding this comment.
The role in the upstream helm chart is only requesting a get privilege and it is scoped to a particular resource name
- apiGroups: [""]
resources: ["configmaps"]
resourceNames: ["exporter-metrics-config-map"]
verbs: ["get"]
There was a problem hiding this comment.
I'm not sure why the upstream chart is scoping this to a particular resource name. The ConfigMap name is user supplied, so it doesn't make sense to restrict the name.
As for having both get and list permissions, this PR matches what is granted to the ClusterPolicy-based DCGM Exporter role:
gpu-operator/assets/state-dcgm-exporter/0200_role.yaml
Lines 17 to 24 in cfabcc9
We could scope this to only get and only create the role when a ConfigMap is provided, but that would be a deviation from a known ClusterPolicy configuration and would require thorough testing.
There was a problem hiding this comment.
The upstream role is referring to this ConfigMap containing all custom metrics, and is gated behind .Values.customMetrics: https://github.com/NVIDIA/dcgm-exporter/blob/main/deployment/templates/metrics-configmap.yaml. It looks like an example to me.
We also let users create a ConfigMap from the chart, but we don't restrict the name and hence don't scope the role to one resource name.
Description
DCGM_EXPORTER_CONFIGMAP_DATAset throughdcgmExporter.envpoints theexporter at a ConfigMap of custom metrics that it reads from the Kubernetes
API. On the GPUCluster path neither the namespaced Role nor the ClusterRole
granted
configmaps, so the read failed with a forbidden error and theexporter fell back to its built-in metrics without crashing. The ClusterPolicy
path has granted this since before the feature existed.
Add
configmapsget/list to the namespaced Role. The Role is bound in theoperator namespace only, so a
namespace:namevalue pointing elsewhere isstill denied.
Verified on a DRA cluster: the ServiceAccount can read ConfigMaps and the
custom metric set is served. Golden fixtures updated to match.
Follow-up to #2721, which fixes the equivalent problem on the ClusterPolicy
path.
Checklist
make lint)make validate-generated-assets)make validate-modules)