Skip to content

Commit

Permalink
[prometheus-mysql-exporter] Add support for templating .Release.Names…
Browse files Browse the repository at this point in the history
…pace with its override (prometheus-community#3882)

* [prometheus-mysql-exporter] Add support for overriding release namespace

Signed-off-by: Kawon1 <[email protected]>

* [prometheus-mysql-exporter] Bump chart

Signed-off-by: Kawon1 <[email protected]>

---------

Signed-off-by: Kawon1 <[email protected]>
Co-authored-by: André Bauer <[email protected]>
  • Loading branch information
2 people authored and Matiasmct committed Mar 20, 2024
1 parent afdf523 commit a6d5801
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus-mysql-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
description: A Helm chart for prometheus mysql exporter with cloudsqlproxy
name: prometheus-mysql-exporter
version: 2.0.0
version: 2.1.0
home: https://github.com/prometheus/mysqld_exporter
appVersion: v0.15.0
sources:
Expand Down
11 changes: 11 additions & 0 deletions charts/prometheus-mysql-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ Secret key for config
{{- end -}}
*/}}

{{/*
Define overriding namespace
*/}}
{{- define "prometheus-mysql-exporter.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}

{{/*
CloudSqlProxy Workload Identity Service Account Annotation
*/}}
Expand Down
1 change: 1 addition & 0 deletions charts/prometheus-mysql-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "prometheus-mysql-exporter.fullname" . }}
namespace: {{ include "prometheus-mysql-exporter.namespace" . }}
labels:
{{- include "prometheus-mysql-exporter.labels" . | nindent 4 }}
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "prometheus-mysql-exporter.secretName" . }}
namespace: {{ include "prometheus-mysql-exporter.namespace" . }}
labels:
{{- include "prometheus-mysql-exporter.labels" . | nindent 4 }}
type: Opaque
Expand Down
1 change: 1 addition & 0 deletions charts/prometheus-mysql-exporter/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "prometheus-mysql-exporter.cloudsqlsecret" . }}
namespace: {{ include "prometheus-mysql-exporter.namespace" . }}
labels:
{{- include "prometheus-mysql-exporter.labels" . | nindent 4 }}
type: Opaque
Expand Down
1 change: 1 addition & 0 deletions charts/prometheus-mysql-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ template "prometheus-mysql-exporter.fullname" . }}
namespace: {{ include "prometheus-mysql-exporter.namespace" . }}
labels:
{{- include "prometheus-mysql-exporter.labels" . | nindent 4 }}
{{- if .Values.service.labels }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "prometheus-mysql-exporter.serviceAccountName" . }}
namespace: {{ include "prometheus-mysql-exporter.namespace" . }}
labels:
app: {{ template "prometheus-mysql-exporter.name" . }}
chart: {{ template "prometheus-mysql-exporter.chart" . }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ metadata:
spec:
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
- {{ include "prometheus-mysql-exporter.namespace" . }}
selector:
matchLabels:
{{- include "prometheus-mysql-exporter.selectorLabels" . | nindent 6 }}
Expand Down
3 changes: 3 additions & 0 deletions charts/prometheus-mysql-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
## This is a YAML-formatted file.
## Declare variables to be passed into your templates.

## namespaceOverride overrides the namespace which the resources will be deployed in
namespaceOverride: ""

## override release name
fullnameOverride: ""

Expand Down

0 comments on commit a6d5801

Please sign in to comment.