Skip to content

Commit 18936a6

Browse files
feat(helm): Sidecar and Service Account Update (#509)
* updated templates for service account and deployment for workload identity and / or extra containers
1 parent 296a854 commit 18936a6

File tree

6 files changed

+56
-17
lines changed

6 files changed

+56
-17
lines changed

helm/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: sql-exporter
33
description: Database-agnostic SQL exporter for Prometheus
44
type: application
5-
version: 0.4.5
5+
version: 0.4.6
66
appVersion: 0.14.2
77
keywords:
88
- exporter

helm/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ helm install sql_exporter/sql-exporter
3939
| service.port | int | `80` | Service port |
4040
| service.labels | object | `{}` | Service labels |
4141
| service.annotations | object | `{}` | Service annotations |
42+
| extraContainers | object | `{}` | |
43+
| serviceAccount.create | bool | `false` | |
44+
| serviceAccount.annotations | object | `{}` | |
45+
| serviceAccount.name | string | `""` | |
46+
| serviceAccount.automountServiceAccountToken | bool | `false` | |
4247
| resources | object | `{}` | Resource limits and requests for the application controller pods |
4348
| podLabels | object | `{}` | Pod labels |
4449
| podAnnotations | object | `{}` | Pod annotations |

helm/templates/_helpers.tpl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,23 @@ app.kubernetes.io/name: {{ include "sql-exporter.name" . }}
5050
app.kubernetes.io/instance: {{ .Release.Name }}
5151
{{- end }}
5252

53+
{{/*
54+
Determine if service account needs to be created
55+
*/}}
56+
{{- define "sql-exporter.createServiceAccount" -}}
57+
{{- with .Values.serviceAccount }}
58+
{{- default "false" .create }}
59+
{{- end }}
60+
{{- end }}
61+
5362
{{/*
5463
Create the name of the service account to use
5564
*/}}
5665
{{- define "sql-exporter.serviceAccountName" -}}
57-
{{- if .Values.serviceAccount.create }}
66+
{{- if (include "sql-exporter.createServiceAccount" . ) }}
5867
{{- default (include "sql-exporter.fullname" .) .Values.serviceAccount.name }}
5968
{{- else }}
60-
{{- default "default" .Values.serviceAccount.name }}
69+
{{- "default" }}
6170
{{- end }}
6271
{{- end }}
6372

helm/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ spec:
2929
{{- end }}
3030
securityContext:
3131
{{- toYaml .Values.podSecurityContext | nindent 8 }}
32+
serviceAccount: {{ include "sql-exporter.serviceAccountName" . }}
3233
{{- if eq (include "sql-exporter.volumes" .) "\"true\"" }}
3334
volumes:
3435
{{- if .Values.createConfig }}
@@ -108,6 +109,9 @@ spec:
108109
protocol: TCP
109110
resources:
110111
{{- toYaml .Values.resources | nindent 12 }}
112+
{{- with .Values.extraContainers }}
113+
{{- toYaml . | nindent 8 }}
114+
{{- end }}
111115
{{- with .Values.nodeSelector }}
112116
nodeSelector:
113117
{{- toYaml . | nindent 8 }}

helm/templates/serviceaccount.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if (include "sql-exporter.createServiceAccount" . ) }}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "sql-exporter.serviceAccountName" . }}
6+
{{- with .Values.serviceAccount.annotations}}
7+
annotations:
8+
{{- toYaml . | nindent 4 }}
9+
{{- end }}
10+
labels:
11+
{{- with .Values.serviceAccount.labels }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
{{- include "sql-exporter.labels" . | nindent 4 }}
15+
automountServiceAccountToken: {{ default "false" .Values.serviceAccount.automountServiceAccountToken }}
16+
{{- end }}

helm/values.yaml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
nameOverride: ""
33
# -- String to fully override "sql-exporter.fullname"
44
fullnameOverride: ""
5-
65
image:
76
# -- Image repository
87
repository: burningalchemist/sql_exporter
@@ -11,10 +10,8 @@ image:
1110
# -- Image tag
1211
# @default -- `appVersion` value from `Chart.yaml`
1312
tag: ""
14-
1513
# -- Secrets with credentials to pull images from a private registry
1614
imagePullSecrets: []
17-
1815
service:
1916
# -- Service type
2017
type: ClusterIP
@@ -23,30 +20,40 @@ service:
2320
# -- Service labels
2421
labels: {}
2522
# -- Service annotations
26-
annotations:
27-
{}
23+
annotations: {}
2824
# example of prometheus usage
2925
# prometheus.io/scrape: "true"
3026
# prometheus.io/path: "/metrics"
31-
27+
extraContainers: {}
28+
# - name: your_sidecar
29+
# image: gcr.io/your_image:your_tag
30+
# args:
31+
# resources:
32+
# requests:{}
33+
serviceAccount:
34+
# Specifies whether a service account should be created
35+
create: false
36+
# Annotations to add to the service account
37+
annotations: {}
38+
## example annotations ##
39+
# annotations:
40+
# iam.gke.io/gcp-service-account: my-service-account@gke.url
41+
name: ""
42+
automountServiceAccountToken: false
3243
# -- Resource limits and requests for the application controller pods
33-
resources:
34-
{}
44+
resources: {}
3545
# limits:
3646
# cpu: 100m
3747
# memory: 128Mi
3848
# requests:
3949
# cpu: 100m
4050
# memory: 128Mi
41-
4251
# -- Pod labels
4352
podLabels: {}
4453
# -- Pod annotations
4554
podAnnotations: {}
46-
4755
# -- Pod security context
48-
podSecurityContext:
49-
{}
56+
podSecurityContext: {}
5057
# capabilities:
5158
# drop:
5259
# - ALL
@@ -55,7 +62,6 @@ podSecurityContext:
5562
# runAsUser: 1000
5663
# @ignored
5764
securityContext: {}
58-
5965
# Prometheus Operator values
6066
serviceMonitor:
6167
# -- Enable ServiceMonitor
@@ -68,7 +74,6 @@ serviceMonitor:
6874
# scrapeTimeout: 10s
6975
# -- ServiceMonitor metric relabelings
7076
metricRelabelings: {}
71-
7277
# Additional env variables
7378
# - kind should be either Secret or ConfigMap
7479
# - name is the name of the Secret or ConfigMap that should be used

0 commit comments

Comments
 (0)