Skip to content

Commit

Permalink
Fix support for disabledMetrics configmap (#204)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
valdisrigdon authored May 10, 2024
1 parent c27a920 commit c46b566
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/opencost/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keywords:
- finops
- monitoring
- opencost
version: 1.35.0
version: 1.36.0
maintainers:
- name: mattray
url: https://mattray.dev
Expand Down
2 changes: 1 addition & 1 deletion charts/opencost/templates/configmap-metrics-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 13 additions & 1 deletion charts/opencost/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions charts/opencost/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
# - <metric-to-be-disabled>
Expand Down

0 comments on commit c46b566

Please sign in to comment.