Skip to content

Commit

Permalink
[prometheus-sql-exporter] Fix labels/matchLabels (#4947)
Browse files Browse the repository at this point in the history
* [prometheus-sql-exporter] Fix labels/matchLabels by using include instead of duplicating declaration in each file

Signed-off-by: Wilfried Roset <[email protected]>

* [prometheus-sql-exporter] Raises the minor version as the old-style labels are replaced

Signed-off-by: Wilfried Roset <[email protected]>

* [prometheus-sql-exporter] Adjust NOTES.txt to take into account correct label name

Signed-off-by: Wilfried Roset <[email protected]>

---------

Signed-off-by: Wilfried Roset <[email protected]>
  • Loading branch information
wilfriedroset authored Oct 30, 2024
1 parent ba798b5 commit ca268b4
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 44 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus-sql-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: Prometheus SQL Exporter
name: prometheus-sql-exporter
version: 0.1.2
version: 0.2.0
appVersion: v0.5.8
home: https://github.com/justwatchcom/sql_exporter
sources:
Expand Down
2 changes: 1 addition & 1 deletion charts/prometheus-sql-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "prometheus-sql-exporter.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "prometheus-sql-exporter.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ template "prometheus-sql-exporter.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:9187
{{- end }}
15 changes: 5 additions & 10 deletions charts/prometheus-sql-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,19 @@ kind: Deployment
metadata:
name: {{ template "prometheus-sql-exporter.fullname" . }}
labels:
app: {{ template "prometheus-sql-exporter.name" . }}
chart: {{ template "prometheus-sql-exporter.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- include "prometheus-sql-exporter.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "prometheus-sql-exporter.name" . }}
release: {{ .Release.Name }}
{{- include "prometheus-sql-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app: {{ template "prometheus-sql-exporter.name" . }}
release: {{ .Release.Name }}
{{- if .Values.podLabels }}
{{- include "prometheus-sql-exporter.selectorLabels" . | nindent 8 }}
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | trim | indent 8 }}
{{- end }}
{{- end }}
annotations:
kubectl.kubernetes.io/default-container: {{ .Chart.Name }}
{{- if .Values.annotations }}
Expand Down
3 changes: 1 addition & 2 deletions charts/prometheus-sql-exporter/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ metadata:
spec:
podSelector:
matchLabels:
app: {{ template "prometheus-sql-exporter.name" . }}
release: {{ .Release.Name }}
{{- include "prometheus-sql-exporter.selectorLabels" . | nindent 8 }}
policyTypes:
- Ingress
ingress:
Expand Down
8 changes: 2 additions & 6 deletions charts/prometheus-sql-exporter/templates/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ kind: PodDisruptionBudget
metadata:
name: {{ template "prometheus-sql-exporter.fullname" . }}
labels:
app: {{ template "prometheus-sql-exporter.name" . }}
chart: {{ template "prometheus-sql-exporter.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "prometheus-sql-exporter.selectorLabels" . | nindent 8 }}
spec:
maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
selector:
matchLabels:
app: {{ template "prometheus-sql-exporter.name" . }}
release: {{ .Release.Name }}
{{- include "prometheus-sql-exporter.selectorLabels" . | nindent 8 }}
{{- end }}
5 changes: 1 addition & 4 deletions charts/prometheus-sql-exporter/templates/prometheusrule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ metadata:
namespace: {{ . }}
{{- end }}
labels:
app: {{ template "prometheus-sql-exporter.name" . }}
chart: {{ template "prometheus-sql-exporter.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
{{- include "prometheus-sql-exporter.labels" . | nindent 4 }}
{{- with .Values.prometheusRule.additionalLabels }}
{{ toYaml . | indent 4 }}
{{- end }}
Expand Down
5 changes: 1 addition & 4 deletions charts/prometheus-sql-exporter/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: Role
metadata:
name: {{ template "prometheus-sql-exporter.fullname" . }}
labels:
app: {{ template "prometheus-sql-exporter.name" . }}
chart: {{ template "prometheus-sql-exporter.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- include "prometheus-sql-exporter.labels" . | nindent 4 }}
{{- if .Values.rbac.pspEnabled }}
rules:
- apiGroups: ['extensions']
Expand Down
5 changes: 1 addition & 4 deletions charts/prometheus-sql-exporter/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: RoleBinding
metadata:
name: {{ template "prometheus-sql-exporter.fullname" . }}
labels:
app: {{ template "prometheus-sql-exporter.name" . }}
chart: {{ template "prometheus-sql-exporter.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- include "prometheus-sql-exporter.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
8 changes: 2 additions & 6 deletions charts/prometheus-sql-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ metadata:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
labels:
app: {{ template "prometheus-sql-exporter.name" . }}
chart: {{ template "prometheus-sql-exporter.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- include "prometheus-sql-exporter.labels" . | nindent 4 }}
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | trim | indent 4 }}
{{- end }}
Expand All @@ -22,5 +19,4 @@ spec:
protocol: TCP
name: {{ .Values.service.name }}
selector:
app: {{ template "prometheus-sql-exporter.name" . }}
release: {{ .Release.Name }}
{{- include "prometheus-sql-exporter.selectorLabels" . | nindent 8 }}
5 changes: 1 addition & 4 deletions charts/prometheus-sql-exporter/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: ServiceAccount
metadata:
name: {{ template "prometheus-sql-exporter.serviceAccountName" . }}
labels:
app: {{ template "prometheus-sql-exporter.name" . }}
chart: {{ template "prometheus-sql-exporter.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "prometheus-sql-exporter.labels" . | nindent 4 }}
{{- if .Values.serviceAccount.annotations }}
annotations:
{{ toYaml .Values.serviceAccount.annotations }}
Expand Down
3 changes: 1 addition & 2 deletions charts/prometheus-sql-exporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ spec:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: {{ template "prometheus-sql-exporter.name" . }}
release: {{ .Release.Name }}
{{- include "prometheus-sql-exporter.selectorLabels" . | nindent 8 }}
{{- if .Values.serviceMonitor.targetLabels }}
targetLabels:
{{- range .Values.serviceMonitor.targetLabels }}
Expand Down

0 comments on commit ca268b4

Please sign in to comment.