Skip to content

Commit

Permalink
fix!(helm): adjust the logic for serviceAccount creation (burningalch…
Browse files Browse the repository at this point in the history
…emist#513)

* fix!: adjust the logic for serviceAccount creation
* fix!(helm): set create to true by default
  • Loading branch information
burningalchemist authored May 11, 2024
1 parent 84ee75c commit 881da5b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 31 deletions.
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: sql-exporter
description: Database-agnostic SQL exporter for Prometheus
type: application
version: 0.4.6
appVersion: 0.14.2
version: 0.5.0
appVersion: 0.14.3
keywords:
- exporter
- servicemonitor
Expand Down
10 changes: 4 additions & 6 deletions helm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# sql-exporter

![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)
![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)

Database-agnostic SQL exporter for Prometheus

Expand Down Expand Up @@ -39,11 +39,9 @@ helm install sql_exporter/sql-exporter
| service.port | int | `80` | Service port |
| service.labels | object | `{}` | Service labels |
| service.annotations | object | `{}` | Service annotations |
| extraContainers | object | `{}` | |
| serviceAccount.create | bool | `false` | |
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.name | string | `""` | |
| serviceAccount.automountServiceAccountToken | bool | `false` | |
| extraContainers | object | `{}` | Arbitrary sidecar containers list |
| 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 |
| serviceAccount.annotations | object | `{}` | Annotations to add to the Service Account |
| resources | object | `{}` | Resource limits and requests for the application controller pods |
| podLabels | object | `{}` | Pod labels |
| podAnnotations | object | `{}` | Pod annotations |
Expand Down
1 change: 1 addition & 0 deletions helm/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ helm install sql_exporter/sql-exporter
{{- end }}
{{- end }}


### Prometheus ServiceMonitor

| Key | Type | Default | Description |
Expand Down
15 changes: 1 addition & 14 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,11 @@ app.kubernetes.io/name: {{ include "sql-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Determine if service account needs to be created
*/}}
{{- define "sql-exporter.createServiceAccount" -}}
{{- with .Values.serviceAccount }}
{{- default "false" .create }}
{{- end }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "sql-exporter.serviceAccountName" -}}
{{- if (include "sql-exporter.createServiceAccount" . ) }}
{{- default (include "sql-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- "default" }}
{{- end }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}

{{- define "sql-exporter.volumes" -}}
Expand Down
2 changes: 1 addition & 1 deletion helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
serviceAccount: {{ include "sql-exporter.serviceAccountName" . }}
serviceAccountName: {{ if .Values.serviceAccount.create }}{{ template "sql-exporter.fullname" . }}{{ else }}{{ include "sql-exporter.serviceAccountName" . }}{{end}}
{{- if eq (include "sql-exporter.volumes" .) "\"true\"" }}
volumes:
{{- if .Values.createConfig }}
Expand Down
6 changes: 3 additions & 3 deletions helm/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{- if (include "sql-exporter.createServiceAccount" . ) }}
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "sql-exporter.serviceAccountName" . }}
name: {{ template "sql-exporter.fullname" . }}
{{- with .Values.serviceAccount.annotations}}
annotations:
{{- toYaml . | nindent 4 }}
Expand All @@ -13,4 +13,4 @@ metadata:
{{- end }}
{{- include "sql-exporter.labels" . | nindent 4 }}
automountServiceAccountToken: {{ default "false" .Values.serviceAccount.automountServiceAccountToken }}
{{- end }}
{{- end }}
15 changes: 10 additions & 5 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,27 @@ service:
# example of prometheus usage
# prometheus.io/scrape: "true"
# prometheus.io/path: "/metrics"
# -- Arbitrary sidecar containers list
extraContainers: {}
# - name: your_sidecar
# image: gcr.io/your_image:your_tag
# args:
# resources:
# requests:{}
serviceAccount:
# Specifies whether a service account should be created
create: false
# Annotations to add to the service account
# -- Specifies whether a Service Account should be created, creates "sql-exporter" service account if true, unless
# overriden. Otherwise, set to `default` if false, and custom service account name is not provided. Check all the
# available parameters.
create: true
# -- References a custom Service Account if it already exists
# name: "sql-exporter-custom-sa"
# -- Annotations to add to the Service Account
annotations: {}
## example annotations ##
# annotations:
# iam.gke.io/gcp-service-account: [email protected]
name: ""
automountServiceAccountToken: false
# -- Defines if token is automatically mounted to the pod after it has been created
# automountServiceAccountToken: false
# -- Resource limits and requests for the application controller pods
resources: {}
# limits:
Expand Down

0 comments on commit 881da5b

Please sign in to comment.