Skip to content

Commit 881da5b

Browse files
fix!(helm): adjust the logic for serviceAccount creation (#513)
* fix!: adjust the logic for serviceAccount creation * fix!(helm): set create to true by default
1 parent 84ee75c commit 881da5b

File tree

7 files changed

+22
-31
lines changed

7 files changed

+22
-31
lines changed

helm/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: v2
22
name: sql-exporter
33
description: Database-agnostic SQL exporter for Prometheus
44
type: application
5-
version: 0.4.6
6-
appVersion: 0.14.2
5+
version: 0.5.0
6+
appVersion: 0.14.3
77
keywords:
88
- exporter
99
- servicemonitor

helm/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# sql-exporter
22

3-
![Version: 0.4.5](https://img.shields.io/badge/Version-0.4.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.14.2](https://img.shields.io/badge/AppVersion-0.14.2-informational?style=flat-square)
3+
![Version: 0.5.0](https://img.shields.io/badge/Version-0.5.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.14.3](https://img.shields.io/badge/AppVersion-0.14.3-informational?style=flat-square)
44

55
Database-agnostic SQL exporter for Prometheus
66

@@ -39,11 +39,9 @@ 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` | |
42+
| extraContainers | object | `{}` | Arbitrary sidecar containers list |
43+
| serviceAccount.create | bool | `true` | Specifies whether a Service Account should be created, defaults to "sql-exporter" unless overriden. Check values.yaml for all the available parameters |
44+
| serviceAccount.annotations | object | `{}` | Annotations to add to the Service Account |
4745
| resources | object | `{}` | Resource limits and requests for the application controller pods |
4846
| podLabels | object | `{}` | Pod labels |
4947
| podAnnotations | object | `{}` | Pod annotations |

helm/README.md.gotmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ helm install sql_exporter/sql-exporter
3333
{{- end }}
3434
{{- end }}
3535

36+
3637
### Prometheus ServiceMonitor
3738

3839
| Key | Type | Default | Description |

helm/templates/_helpers.tpl

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,11 @@ 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-
6253
{{/*
6354
Create the name of the service account to use
6455
*/}}
6556
{{- define "sql-exporter.serviceAccountName" -}}
66-
{{- if (include "sql-exporter.createServiceAccount" . ) }}
67-
{{- default (include "sql-exporter.fullname" .) .Values.serviceAccount.name }}
68-
{{- else }}
69-
{{- "default" }}
70-
{{- end }}
57+
{{- default "default" .Values.serviceAccount.name }}
7158
{{- end }}
7259

7360
{{- define "sql-exporter.volumes" -}}

helm/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ spec:
2929
{{- end }}
3030
securityContext:
3131
{{- toYaml .Values.podSecurityContext | nindent 8 }}
32-
serviceAccount: {{ include "sql-exporter.serviceAccountName" . }}
32+
serviceAccountName: {{ if .Values.serviceAccount.create }}{{ template "sql-exporter.fullname" . }}{{ else }}{{ include "sql-exporter.serviceAccountName" . }}{{end}}
3333
{{- if eq (include "sql-exporter.volumes" .) "\"true\"" }}
3434
volumes:
3535
{{- if .Values.createConfig }}

helm/templates/serviceaccount.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
{{- if (include "sql-exporter.createServiceAccount" . ) }}
1+
{{- if .Values.serviceAccount.create }}
22
apiVersion: v1
33
kind: ServiceAccount
44
metadata:
5-
name: {{ include "sql-exporter.serviceAccountName" . }}
5+
name: {{ template "sql-exporter.fullname" . }}
66
{{- with .Values.serviceAccount.annotations}}
77
annotations:
88
{{- toYaml . | nindent 4 }}
@@ -13,4 +13,4 @@ metadata:
1313
{{- end }}
1414
{{- include "sql-exporter.labels" . | nindent 4 }}
1515
automountServiceAccountToken: {{ default "false" .Values.serviceAccount.automountServiceAccountToken }}
16-
{{- end }}
16+
{{- end }}

helm/values.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,27 @@ service:
2424
# example of prometheus usage
2525
# prometheus.io/scrape: "true"
2626
# prometheus.io/path: "/metrics"
27+
# -- Arbitrary sidecar containers list
2728
extraContainers: {}
2829
# - name: your_sidecar
2930
# image: gcr.io/your_image:your_tag
3031
# args:
3132
# resources:
3233
# requests:{}
3334
serviceAccount:
34-
# Specifies whether a service account should be created
35-
create: false
36-
# Annotations to add to the service account
35+
# -- Specifies whether a Service Account should be created, creates "sql-exporter" service account if true, unless
36+
# overriden. Otherwise, set to `default` if false, and custom service account name is not provided. Check all the
37+
# available parameters.
38+
create: true
39+
# -- References a custom Service Account if it already exists
40+
# name: "sql-exporter-custom-sa"
41+
# -- Annotations to add to the Service Account
3742
annotations: {}
3843
## example annotations ##
3944
# annotations:
4045
# iam.gke.io/gcp-service-account: [email protected]
41-
name: ""
42-
automountServiceAccountToken: false
46+
# -- Defines if token is automatically mounted to the pod after it has been created
47+
# automountServiceAccountToken: false
4348
# -- Resource limits and requests for the application controller pods
4449
resources: {}
4550
# limits:

0 commit comments

Comments
 (0)