From c46b5662ad922b23fc9e4b1090fcc135cca55fb9 Mon Sep 17 00:00:00 2001 From: Valdis Rigdon Date: Thu, 9 May 2024 23:52:42 -0400 Subject: [PATCH] Fix support for disabledMetrics configmap (#204) CONFIG_PATH is a single directory where both the custom pricing (aws.json) and metrics.json need to exist. The only way to map multiple ConfigMaps into a single folder is to use subPath. --- charts/opencost/Chart.yaml | 2 +- .../templates/configmap-metrics-config.yaml | 2 +- charts/opencost/templates/deployment.yaml | 14 +++++++++++++- charts/opencost/values.yaml | 2 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/charts/opencost/Chart.yaml b/charts/opencost/Chart.yaml index 0c9d3ce..0bd5147 100755 --- a/charts/opencost/Chart.yaml +++ b/charts/opencost/Chart.yaml @@ -9,7 +9,7 @@ keywords: - finops - monitoring - opencost -version: 1.35.0 +version: 1.36.0 maintainers: - name: mattray url: https://mattray.dev diff --git a/charts/opencost/templates/configmap-metrics-config.yaml b/charts/opencost/templates/configmap-metrics-config.yaml index e1db889..f4be7a2 100644 --- a/charts/opencost/templates/configmap-metrics-config.yaml +++ b/charts/opencost/templates/configmap-metrics-config.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ .Release.Name }}-metrics-config + name: {{ .Values.opencost.metrics.config.configmapName }} namespace: {{ include "opencost.namespace" . }} labels: {{- include "opencost.labels" . | nindent 4 }} data: diff --git a/charts/opencost/templates/deployment.yaml b/charts/opencost/templates/deployment.yaml index 0347af8..e3dea28 100644 --- a/charts/opencost/templates/deployment.yaml +++ b/charts/opencost/templates/deployment.yaml @@ -115,7 +115,7 @@ spec: value: {{ include "opencost.namespace" . }} {{- if .Values.opencost.metrics.config.enabled }} - name: METRICS_CONFIGMAP_NAME - value: {{ .Release.Name }}-metrics-config + value: {{ .Values.opencost.metrics.config.configmapName }} {{- end }} {{- if .Values.opencost.exporter.apiPort }} - name: API_PORT @@ -245,6 +245,13 @@ spec: {{- if .Values.opencost.customPricing.enabled }} - mountPath: {{ .Values.opencost.customPricing.configPath }} name: custom-configs + subPath: {{ include "opencost.configFileName" . }}.json + readOnly: true + {{- end }} + {{- if .Values.opencost.metrics.config.enabled }} + - mountPath: {{ .Values.opencost.customPricing.configPath }} + name: custom-metrics + subPath: metrics.json readOnly: true {{- end }} {{- if .Values.opencost.cloudIntegrationSecret }} @@ -363,6 +370,11 @@ spec: configMap: name: {{ .Values.opencost.customPricing.configmapName }} {{- end }} + {{- if .Values.opencost.metrics.config.enabled }} + - name: custom-metrics + configMap: + name: {{ .Values.opencost.config.metrics.configmapName }} + {{- end }} {{- if .Values.opencost.exporter.persistence.enabled }} - name: opencost-export persistentVolumeClaim: diff --git a/charts/opencost/values.yaml b/charts/opencost/values.yaml index 0cf7599..315c406 100644 --- a/charts/opencost/values.yaml +++ b/charts/opencost/values.yaml @@ -301,6 +301,8 @@ opencost: config: # -- Enables creating the metrics.json configuration as a ConfigMap enabled: false + # -- Customize the configmap name used for metrics + configmapName: custom-metrics # -- List of metrics to be disabled disabledMetrics: [] # -