diff --git a/charts/opencost/Chart.yaml b/charts/opencost/Chart.yaml index 8cb9a80..dc5c630 100755 --- a/charts/opencost/Chart.yaml +++ b/charts/opencost/Chart.yaml @@ -9,7 +9,7 @@ keywords: - kubecost - opencost - monitoring -version: 1.18.1 +version: 1.19.0 maintainers: - name: mattray url: https://mattray.dev diff --git a/charts/opencost/templates/_helpers.tpl b/charts/opencost/templates/_helpers.tpl index ee1f012..0be4623 100644 --- a/charts/opencost/templates/_helpers.tpl +++ b/charts/opencost/templates/_helpers.tpl @@ -92,6 +92,17 @@ Create the name of the controller service account to use {{- end -}} +{{- define "opencost.thanosServerEndpoint" -}} + {{- if .Values.opencost.prometheus.thanos.external.enabled -}} + {{ .Values.opencost.prometheus.thanos.external.url }} + {{- else -}} + {{- $host := .Values.opencost.prometheus.thanos.internal.serviceName }} + {{- $ns := .Values.opencost.prometheus.thanos.internal.namespaceName }} + {{- $port := .Values.opencost.prometheus.thanos.internal.port | int }} + {{- printf "http://%s.%s.svc:%d" $host $ns $port -}} + {{- end -}} +{{- end -}} + {{/* Check that either prometheus external or internal is defined */}} @@ -99,4 +110,9 @@ Check that either prometheus external or internal is defined {{- if and .Values.opencost.prometheus.external.enabled .Values.opencost.prometheus.internal.enabled -}} {{- fail "Only use one of the prometheus setups, internal or external" -}} {{- end -}} + {{- if .Values.opencost.prometheus.thanos.enabled -}} + {{- if and .Values.opencost.prometheus.thanos.external.enabled .Values.opencost.prometheus.thanos.internal.enabled -}} + {{- fail "Only use one of the thanos setups, internal or external" -}} + {{- end -}} + {{- end -}} {{- end -}} diff --git a/charts/opencost/templates/deployment.yaml b/charts/opencost/templates/deployment.yaml index aefb812..2fa0137 100644 --- a/charts/opencost/templates/deployment.yaml +++ b/charts/opencost/templates/deployment.yaml @@ -125,7 +125,21 @@ spec: {{- if and .Values.opencost.exporter.persistence.enabled .Values.opencost.exporter.csv_path }} - name: EXPORT_CSV_FILE value: {{ .Values.opencost.exporter.csv_path | quote }} - {{- end}} + {{- end }} + {{- if .Values.opencost.prometheus.thanos.enabled }} + - name: THANOS_ENABLED + value: 'true' + - name: THANOS_QUERY_URL + value: {{ include "opencost.thanosServerEndpoint" . | quote }} + {{- end }} + {{- if .Values.opencost.prometheus.thanos.queryOffset }} + - name: THANOS_QUERY_OFFSET + value: {{ .Values.opencost.prometheus.thanos.queryOffset | quote }} + {{- end }} + {{- if .Values.opencost.prometheus.thanos.maxSourceResolution }} + - name: THANOS_MAX_SOURCE_RESOLUTION + value: {{ .Values.opencost.prometheus.thanos.maxSourceResolution | quote }} + {{- end }} {{- with .Values.opencost.exporter.env }} {{- toYaml . | nindent 12 }} {{- end }} diff --git a/charts/opencost/values.yaml b/charts/opencost/values.yaml index 5b573f6..496d19e 100644 --- a/charts/opencost/values.yaml +++ b/charts/opencost/values.yaml @@ -170,6 +170,18 @@ opencost: namespaceName: opencost # -- Service port of in-cluster Prometheus port: 9090 + thanos: + enabled: false + queryOffset: '' + maxSourceResolution: '' + internal: + enabled: true + serviceName: my-thanos-query + namespaceName: opencost + port: 10901 + external: + enabled: false + url: 'https://thanos-query.example.com/thanos' ui: # -- Enable OpenCost UI