diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5b5df82bd1b0..caa99c429b78 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -47,6 +47,7 @@ /charts/prometheus-redis-exporter/ @acondrat @zanhsieh /charts/prometheus-smartctl-exporter/ @kfox1111 @zeritti /charts/prometheus-snmp-exporter/ @miouge1 @walker-tom @xiu +/charts/prometheus-sql-exporter/ @wilfriedroset /charts/prometheus-stackdriver-exporter/ @apenney @rpahli /charts/prometheus-statsd-exporter/ @scDisorder /charts/prometheus-systemd-exporter/ @capuche2412 @maxime1907 diff --git a/charts/prometheus-sql-exporter/.helmignore b/charts/prometheus-sql-exporter/.helmignore new file mode 100644 index 000000000000..0e8a0eb36f4c --- /dev/null +++ b/charts/prometheus-sql-exporter/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/prometheus-sql-exporter/Chart.yaml b/charts/prometheus-sql-exporter/Chart.yaml new file mode 100644 index 000000000000..36f8e60484da --- /dev/null +++ b/charts/prometheus-sql-exporter/Chart.yaml @@ -0,0 +1,16 @@ +apiVersion: v2 +description: Prometheus SQL Exporter +name: prometheus-sql-exporter +version: 0.1.0 +appVersion: v0.5.4 +home: https://github.com/justwatchcom/sql_exporter +sources: + - https://github.com/justwatchcom/sql_exporter + - https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-sql-exporter +keywords: + - prometheus + - sql + - monitoring +maintainers: + - name: wilfriedroset +type: application diff --git a/charts/prometheus-sql-exporter/README.md b/charts/prometheus-sql-exporter/README.md new file mode 100644 index 000000000000..c7b29476f8e7 --- /dev/null +++ b/charts/prometheus-sql-exporter/README.md @@ -0,0 +1,57 @@ +# Prometheus SQL Exporter + +Prometheus exporter for SQL testing + +Learn more: [https://github.com/justwatchcom/sql_exporter](https://github.com/justwatchcom/sql_exporter) + +This chart creates a SQL-Exporter deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes 1.27+ +- Helm >= 3.0 + +## Get Repository Info + +```console +helm repo add prometheus-community https://prometheus-community.github.io/helm-charts +helm repo update +``` + +_See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentation._ + +## Install Chart + +```console +helm install [RELEASE_NAME] prometheus-community/prometheus-sql-exporter +``` + +_See [configuration](#configuration) below._ + +_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._ + +## Uninstall Chart + +```console +helm uninstall [RELEASE_NAME] +``` + +This removes all the Kubernetes components associated with the chart and deletes the release. + +_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._ + +## Upgrading Chart + +```console +helm upgrade [RELEASE_NAME] [CHART] --install +``` + +_See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._ + +## Configuration + +See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with detailed comments, visit the chart's [values.yaml](./values.yaml), or run these configuration commands: + +```console +helm show values prometheus-community/prometheus-sql-exporter +``` diff --git a/charts/prometheus-sql-exporter/templates/NOTES.txt b/charts/prometheus-sql-exporter/templates/NOTES.txt new file mode 100644 index 000000000000..e83d522b6eb2 --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "prometheus-sql-exporter.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "prometheus-sql-exporter.fullname" . }}' + 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}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:9187 +{{- end }} diff --git a/charts/prometheus-sql-exporter/templates/_helpers.tpl b/charts/prometheus-sql-exporter/templates/_helpers.tpl new file mode 100644 index 000000000000..e2b11ec12bc2 --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/_helpers.tpl @@ -0,0 +1,305 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "prometheus-sql-exporter.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "prometheus-sql-exporter.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "prometheus-sql-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "prometheus-sql-exporter.labels" -}} +helm.sh/chart: {{ include "prometheus-sql-exporter.chart" . }} +{{ include "prometheus-sql-exporter.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- if .Values.releaseLabel }} +release: {{ .Release.Name }} +{{- end }} +{{- if .Values.commonLabels }} +{{ toYaml .Values.commonLabels }} +{{- end }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "prometheus-sql-exporter.selectorLabels" -}} +app.kubernetes.io/name: {{ include "prometheus-sql-exporter.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "prometheus-sql-exporter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "prometheus-sql-exporter.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Return the appropriate apiVersion for rbac. +*/}} +{{- define "rbac.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" }} +{{- print "rbac.authorization.k8s.io/v1" -}} +{{- else -}} +{{- print "rbac.authorization.k8s.io/v1beta1" -}} +{{- end -}} +{{- end -}} + + +{{- define "prometheus-sql-exporter.namespace" -}} + {{- if .Values.namespaceOverride -}} + {{- .Values.namespaceOverride -}} + {{- else -}} + {{- .Release.Namespace -}} + {{- end -}} +{{- end -}} + +{{/* Enable overriding Kubernetes version for some use cases */}} +{{- define "prometheus-sql-exporter.kubeVersion" -}} + {{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride -}} +{{- end -}} + + +{{/* +The image to use +*/}} +{{- define "prometheus-sql-exporter.image" -}} +{{- with (.Values.global.imageRegistry | default .Values.image.registry) -}}{{ . }}/{{- end }} +{{- .Values.image.repository -}}:{{- .Values.image.tag | default .Chart.AppVersion -}} +{{- with .Values.image.digest -}}@{{ .}}{{- end -}} +{{- end -}} + +{{/* +The image to use +*/}} +{{- define "prometheus-sql-exporter.config-reloader.image" -}} +{{- with (.Values.global.imageRegistry | default .Values.configReloader.image.registry) -}}{{ . }}/{{- end }} +{{- .Values.configReloader.image.repository -}}:{{- .Values.configReloader.image.tag -}} +{{- with .Values.configReloader.image.digest -}}@{{ .}}{{- end -}} +{{- end -}} + +{{/* +Define pod spec to be reused by highlevel resources (deployment, daemonset) +*/}} +{{- define "prometheus-sql-exporter.podSpec" -}} +automountServiceAccountToken: {{ .Values.automountServiceAccountToken }} +serviceAccountName: {{ template "prometheus-sql-exporter.serviceAccountName" . }} +{{- with .Values.topologySpreadConstraints }} +topologySpreadConstraints: +{{ toYaml . }} +{{- end }} +{{- with .Values.nodeSelector }} +nodeSelector: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- with .Values.affinity }} +affinity: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- with .Values.tolerations }} +tolerations: +{{ toYaml . }} +{{- end }} +{{- if .Values.image.pullSecrets }} +imagePullSecrets: +{{- range .Values.image.pullSecrets }} +- name: {{ . }} +{{- end }} +{{- end }} +{{- if .Values.hostAliases }} +hostAliases: +{{- range .Values.hostAliases }} +- ip: {{ .ip }} + hostnames: + {{- range .hostNames }} + - {{ . }} + {{- end }} +{{- end }} +{{- end }} +restartPolicy: {{ .Values.restartPolicy }} +{{- with .Values.priorityClassName }} +priorityClassName: "{{ . }}" +{{- end }} +{{- with .Values.podSecurityContext }} +securityContext: +{{ toYaml . | indent 2 }} +{{- end }} +{{- with .Values.extraInitContainers }} +initContainers: +{{- if kindIs "string" . }} + {{- tpl . $ | nindent 2 }} +{{- else }} + {{- toYaml . | nindent 2 }} +{{- end -}} +{{- end }} + +containers: +{{ with .Values.extraContainers }} +{{- if kindIs "string" . }} + {{- tpl . $ }} +{{- else }} + {{- toYaml . }} +{{- end -}} +{{- end }} + +{{- if .Values.configReloader.enabled }} +- name: config-reloader + image: {{ include "prometheus-sql-exporter.config-reloader.image" . }} + imagePullPolicy: {{ .Values.configReloader.image.pullPolicy }} + args: + - --config-file={{ .Values.configPath | default "/config/sql.yaml" }} + - --watch-interval={{ .Values.configReloader.config.watchInterval }} + - --reload-url=http://127.0.0.1:{{ .Values.containerPort }}/-/reload + - --listen-address=:{{ .Values.configReloader.containerPort }} + - --log-format={{ .Values.configReloader.config.logFormat }} + - --log-level={{ .Values.configReloader.config.logLevel }} + {{- with .Values.resources }} + resources: +{{- toYaml . | nindent 4 }} + {{- end }} + ports: + - name: reloader-web + containerPort: {{ .Values.configReloader.containerPort }} + protocol: TCP + livenessProbe: + {{- toYaml .Values.configReloader.livenessProbe | nindent 4 }} + readinessProbe: + {{- toYaml .Values.configReloader.readinessProbe | nindent 4 }} + volumeMounts: + - mountPath: /config + name: config + {{- with .Values.configReloader.securityContext }} + securityContext: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} +- name: sql-exporter + image: {{ include "prometheus-sql-exporter.image" . }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 4 }} + {{- end }} + env: + {{- range $key, $value := .Values.extraEnv }} + - name: {{ $key }} + value: {{ $value | quote }} + {{- end }} + {{- if .Values.extraEnvFromSecret }} + envFrom: + {{- range .Values.extraEnvFromSecret }} + - secretRef: + name: {{ . }} + {{- end }} + {{- end }} + args: + {{- if .Values.config }} + {{- if .Values.configPath }} + - "--config.file={{ .Values.configPath }}" + {{- else }} + - "--config.file=/config/sql.yaml" + {{- end }} + {{- else }} + - "--config.file=/etc/sql_exporter/config.yml" + {{- end }} + {{- with .Values.extraArgs }} +{{ tpl (toYaml .) $ | indent 2 }} + {{- end }} + {{- with .Values.resources }} + resources: +{{ toYaml . | indent 4 }} + {{- end }} + ports: + - containerPort: {{ .Values.containerPort }} + name: http + livenessProbe: + {{- toYaml .Values.livenessProbe | trim | nindent 4 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | trim | nindent 4 }} + volumeMounts: + - mountPath: /config + name: config + {{- range .Values.extraConfigmapMounts }} + - name: {{ .name }} + mountPath: {{ .mountPath }} + subPath: {{ .subPath | default "" }} + readOnly: {{ .readOnly }} + {{- end }} + {{- range .Values.extraSecretMounts }} + - name: {{ .name }} + mountPath: {{ .mountPath }} + subPath: {{ .subPath }} + readOnly: {{ .readOnly }} + {{- end }} + {{- if .Values.extraVolumeMounts }} +{{ toYaml .Values.extraVolumeMounts | indent 2 }} + {{- end }} + {{- if .Values.dnsPolicy }} +dnsPolicy: {{ .Values.dnsPolicy | toString }} +{{- end }} +hostNetwork: {{ .Values.hostNetwork }} +{{- with .Values.dnsConfig }} +dnsConfig: + {{- toYaml . | nindent 2 }} +{{- end }} +volumes: +{{- if .Values.extraVolumes }} +{{ toYaml .Values.extraVolumes }} +{{- end }} +- name: config +{{- if .Values.secretConfig }} + secret: + secretName: {{ template "prometheus-sql-exporter.fullname" . }} +{{- else if .Values.configExistingSecretName }} + secret: + secretName: {{ .Values.configExistingSecretName }} +{{- else }} + configMap: + name: {{ template "prometheus-sql-exporter.fullname" . }} +{{- end }} +{{- range .Values.extraConfigmapMounts }} +- name: {{ .name }} + configMap: + name: {{ .configMap }} + defaultMode: {{ .defaultMode }} +{{- end }} +{{- range .Values.extraSecretMounts }} +- name: {{ .name }} + secret: + secretName: {{ .secretName }} + defaultMode: {{ .defaultMode }} +{{- end }} +{{- end -}} diff --git a/charts/prometheus-sql-exporter/templates/config.yaml b/charts/prometheus-sql-exporter/templates/config.yaml new file mode 100644 index 000000000000..3baf28c5cb37 --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/config.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "prometheus-sql-exporter.fullname" . }} + labels: + {{- include "prometheus-sql-exporter.labels" $ | nindent 4 }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +data: + config.yml: | + {{- .Values.config | toYaml | nindent 4 }} diff --git a/charts/prometheus-sql-exporter/templates/deployment.yaml b/charts/prometheus-sql-exporter/templates/deployment.yaml new file mode 100644 index 000000000000..c08cec753ec2 --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/deployment.yaml @@ -0,0 +1,122 @@ +apiVersion: apps/v1 +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 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "prometheus-sql-exporter.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "prometheus-sql-exporter.name" . }} + release: {{ .Release.Name }} +{{- if .Values.podLabels }} +{{ toYaml .Values.podLabels | trim | indent 8 }} +{{- end }} + annotations: + kubectl.kubernetes.io/default-container: {{ .Chart.Name }} +{{- if .Values.annotations }} +{{ toYaml .Values.annotations | indent 8 }} +{{- end }} + spec: + serviceAccountName: {{ template "prometheus-sql-exporter.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- if .Values.initContainers }} + initContainers: +{{ toYaml .Values.initContainers | indent 8 }} +{{- end }} + {{- if .Values.image.pullSecrets }} + imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + command: + {{- range .Values.containerCommand }} + - {{ tpl (quote .) $ }} + {{- end }} + env: + {{- with .Values.extraEnvs }} + {{- if kindIs "map" . }} + {{- range $name, $value := . }} + - name: {{ $name }} + value: {{ tpl $value $ | quote }} + {{- end }} + {{- end }} + {{- if kindIs "slice" . -}} + {{ toYaml . | nindent 10 }} + {{- end }} + {{- end }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.targetPort }} + protocol: TCP + livenessProbe: + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} + timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} + httpGet: + path: / + port: http + readinessProbe: + initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} + timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} + httpGet: + path: / + port: http + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + - name: config + mountPath: /config.yml + subPath: config.yml +{{- with .Values.extraVolumeMounts }} +{{ toYaml . | indent 12 }} +{{- end }} +{{- with .Values.extraContainers }} +{{ toYaml . | indent 8 }} +{{- end }} +{{- if .Values.hostAliases }} + hostAliases: +{{ toYaml .Values.hostAliases | indent 8 }} +{{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + volumes: + - name: config + configMap: + name: {{ include "prometheus-sql-exporter.fullname" . }} + items: + - key: config.yml + path: config.yml +{{- with .Values.extraVolumes }} +{{ toYaml . | indent 8 }} +{{- end }} diff --git a/charts/prometheus-sql-exporter/templates/networkpolicy.yaml b/charts/prometheus-sql-exporter/templates/networkpolicy.yaml new file mode 100644 index 000000000000..1ee1281cb8c9 --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/networkpolicy.yaml @@ -0,0 +1,20 @@ +{{- if .Values.networkPolicy.enabled }} +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ template "prometheus-sql-exporter.fullname" . }} + labels: + {{- if .Values.networkPolicy.labels }} + {{ toYaml .Values.networkPolicy.labels | indent 4 }} + {{- end }} +spec: + podSelector: + matchLabels: + app: {{ template "prometheus-sql-exporter.name" . }} + release: {{ .Release.Name }} + policyTypes: + - Ingress + ingress: + - ports: + - port: {{ .Values.service.targetPort }} +{{- end }} diff --git a/charts/prometheus-sql-exporter/templates/pdb.yaml b/charts/prometheus-sql-exporter/templates/pdb.yaml new file mode 100644 index 000000000000..9b759bf08729 --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/pdb.yaml @@ -0,0 +1,17 @@ +{{- if .Values.podDisruptionBudget.enabled }} +apiVersion: policy/v1beta1 +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 }}" +spec: + maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }} + selector: + matchLabels: + app: {{ template "prometheus-sql-exporter.name" . }} + release: {{ .Release.Name }} +{{- end }} diff --git a/charts/prometheus-sql-exporter/templates/prometheusrule.yaml b/charts/prometheus-sql-exporter/templates/prometheusrule.yaml new file mode 100644 index 000000000000..13228d42f94d --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/prometheusrule.yaml @@ -0,0 +1,23 @@ +{{- if .Values.prometheusRule.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ template "prometheus-sql-exporter.fullname" . }} +{{- with .Values.prometheusRule.namespace }} + namespace: {{ . }} +{{- end }} + labels: + app: {{ template "prometheus-sql-exporter.name" . }} + chart: {{ template "prometheus-sql-exporter.chart" . }} + release: {{ .Release.Name | quote }} + heritage: {{ .Release.Service | quote }} +{{- with .Values.prometheusRule.additionalLabels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- with .Values.prometheusRule.rules }} + groups: + - name: {{ template "prometheus-sql-exporter.name" $ }} + rules: {{ tpl (toYaml .) $ | nindent 8 }} +{{- end }} +{{- end }} diff --git a/charts/prometheus-sql-exporter/templates/role.yaml b/charts/prometheus-sql-exporter/templates/role.yaml new file mode 100644 index 000000000000..9fa8b11bd42d --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/role.yaml @@ -0,0 +1,18 @@ +{{- if .Values.rbac.create }} +apiVersion: {{ template "rbac.apiVersion" . }} +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 }} +{{- if .Values.rbac.pspEnabled }} +rules: +- apiGroups: ['extensions'] + resources: ['podsecuritypolicies'] + verbs: ['use'] + resourceNames: [{{ template "prometheus-sql-exporter.fullname" . }}] +{{- end }} +{{- end }} diff --git a/charts/prometheus-sql-exporter/templates/rolebinding.yaml b/charts/prometheus-sql-exporter/templates/rolebinding.yaml new file mode 100644 index 000000000000..424b77fc5e9e --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/rolebinding.yaml @@ -0,0 +1,18 @@ +{{- if .Values.rbac.create -}} +apiVersion: {{ template "rbac.apiVersion" . }} +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 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ template "prometheus-sql-exporter.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ template "prometheus-sql-exporter.serviceAccountName" . }} +{{- end -}} diff --git a/charts/prometheus-sql-exporter/templates/service.yaml b/charts/prometheus-sql-exporter/templates/service.yaml new file mode 100644 index 000000000000..4f04d717fa2d --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/service.yaml @@ -0,0 +1,26 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "prometheus-sql-exporter.fullname" . }} + {{- if .Values.service.annotations }} + annotations: +{{ 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 }} +{{- if .Values.service.labels }} +{{ toYaml .Values.service.labels | trim | indent 4 }} +{{- end }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + protocol: TCP + name: {{ .Values.service.name }} + selector: + app: {{ template "prometheus-sql-exporter.name" . }} + release: {{ .Release.Name }} diff --git a/charts/prometheus-sql-exporter/templates/serviceaccount.yaml b/charts/prometheus-sql-exporter/templates/serviceaccount.yaml new file mode 100644 index 000000000000..1757c901d922 --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/serviceaccount.yaml @@ -0,0 +1,15 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +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 }}" + {{- if .Values.serviceAccount.annotations }} + annotations: + {{ toYaml .Values.serviceAccount.annotations }} + {{- end }} +{{- end -}} diff --git a/charts/prometheus-sql-exporter/templates/servicemonitor.yaml b/charts/prometheus-sql-exporter/templates/servicemonitor.yaml new file mode 100644 index 000000000000..518b08a66951 --- /dev/null +++ b/charts/prometheus-sql-exporter/templates/servicemonitor.yaml @@ -0,0 +1,47 @@ +{{- if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: +{{- if .Values.serviceMonitor.labels }} + labels: +{{ toYaml .Values.serviceMonitor.labels | indent 4}} +{{- end }} + name: {{ template "prometheus-sql-exporter.fullname" . }} +{{- if .Values.serviceMonitor.namespace }} + namespace: {{ .Values.serviceMonitor.namespace }} +{{- end }} +spec: + endpoints: + - targetPort: {{ .Values.service.name }} +{{- if .Values.serviceMonitor.interval }} + interval: {{ .Values.serviceMonitor.interval }} +{{- end }} +{{- if .Values.serviceMonitor.telemetryPath }} + path: {{ .Values.serviceMonitor.telemetryPath }} +{{- end }} +{{- if .Values.serviceMonitor.timeout }} + scrapeTimeout: {{ .Values.serviceMonitor.timeout }} +{{- end }} +{{- if .Values.serviceMonitor.metricRelabelings }} + metricRelabelings: +{{ toYaml .Values.serviceMonitor.metricRelabelings | indent 4 }} +{{- end }} +{{- if .Values.serviceMonitor.relabelings }} + relabelings: +{{ toYaml .Values.serviceMonitor.relabelings | nindent 4 }} +{{- end }} + jobLabel: {{ template "prometheus-sql-exporter.fullname" . }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + app: {{ template "prometheus-sql-exporter.name" . }} + release: {{ .Release.Name }} +{{- if .Values.serviceMonitor.targetLabels }} + targetLabels: +{{- range .Values.serviceMonitor.targetLabels }} + - {{ . }} +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/prometheus-sql-exporter/values.yaml b/charts/prometheus-sql-exporter/values.yaml new file mode 100644 index 000000000000..221cfed17678 --- /dev/null +++ b/charts/prometheus-sql-exporter/values.yaml @@ -0,0 +1,187 @@ +# Default values for prometheus-sql-exporter. + +replicaCount: 1 + +image: + repository: ghcr.io/justwatchcom/sql_exporter + # if not set appVersion field from Chart.yaml is used + tag: "" + pullPolicy: IfNotPresent + + ## Optionally specify an array of imagePullSecrets. + ## Secrets must be manually created in the namespace. + ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ + ## + # pullSecrets: + # - myRegistrKeySecretName + +service: + type: ClusterIP + port: 80 + targetPort: 9237 + name: http + labels: {} + annotations: {} + +serviceMonitor: + # When set true then use a ServiceMonitor to configure scraping + enabled: false + # Set the namespace the ServiceMonitor should be deployed + # namespace: monitoring + # Set how frequently Prometheus should scrape + # interval: 30s + # telemetryPath: /metrics + # Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator + # labels: + # Set timeout for scrape + # timeout: 10s + # Set of labels to transfer from the Kubernetes Service onto the target + # targetLabels: [] + # MetricRelabelConfigs to apply to samples before ingestion + # metricRelabelings: [] + # Set relabel_configs as per https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config + # relabelings: [] + +prometheusRule: + enabled: false + additionalLabels: {} + namespace: "" + rules: [] + +resources: + {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +rbac: + # Specifies whether RBAC resources should be created + create: true + +serviceAccount: + # Specifies whether a ServiceAccount should be created + create: true + # The name of the ServiceAccount to use. + # If not set and create is true, a name is generated using the fullname template + name: + # Add annotations to the ServiceAccount, useful for EKS IAM Roles for Service Accounts or Google Workload Identity. + annotations: {} + +# Add a default ingress to allow namespace access to service.targetPort +# Helpful if other NetworkPolicies are configured in the namespace +networkPolicy: + # Specifies whether a NetworkPolicy should be created + enabled: false + # Set labels for the NetworkPolicy + labels: {} + +# The securityContext of the pod. +# See https://kubernetes.io/docs/concepts/policy/security-context/ for more. +podSecurityContext: + runAsUser: 1001 + runAsGroup: 1001 + runAsNonRoot: true + seccompProfile: + type: RuntimeDefault + +# The securityContext of the container. +# See https://kubernetes.io/docs/concepts/policy/security-context/ for more. +securityContext: + runAsUser: 1001 + runAsGroup: 1001 + readOnlyRootFilesystem: true + runAsNonRoot: true + allowPrivilegeEscalation: false + capabilities: + drop: ["ALL"] + seccompProfile: + type: RuntimeDefault + +hostAliases: + [] + # Set Host Aliases as per https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/ + # - ip: "127.0.0.1" + # hostnames: + # - "foo.local" + # - "bar.local" + +# See: https://github.com/justwatchcom/sql_exporter/blob/master/config.yml.dist +config: {} +# Allow to override the default file path. This can be useful if the initContainer needs to modify the values based configuration +configFilePath: "/config.yml" +# Allow to override how sql_exporter container is launched +# note that templating will be rendered +containerCommand: + - "sql_exporter" + - "-web.listen-address=:{{ .Values.service.targetPort }}" + - "-config.file={{ .Values.configFilePath }}" + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +annotations: {} + +podLabels: {} + +# Configurable health checks +livenessProbe: + initialDelaySeconds: 3 + timeoutSeconds: 3 + +readinessProbe: + initialDelaySeconds: 5 + timeoutSeconds: 10 + +# ExtraEnvs +extraEnvs: + [] + # - name: EXTRA_ENV + # value: value + # - name: POD_NAMESPACE + # valueFrom: + # fieldRef: + # fieldPath: metadata.namespace + +# Init containers, e. g. for secrets creation before the exporter +initContainers: + [] + # - name: + # image: + # volumeMounts: + # - name: creds + # mountPath: /creds + +# Additional sidecar containers, e. g. for a database proxy, such as Google's cloudsql-proxy +extraContainers: [] + +# Additional volumes, e. g. for secrets used in an extraContainer +extraVolumes: [] +# Uncomment for mounting custom ca-certificates +# - name: ssl-certs +# secret: +# defaultMode: 420 +# items: +# - key: ca-certificates.crt +# path: ca-certificates.crt +# secretName: ssl-certs + +# Additional volume mounts +extraVolumeMounts: [] +# Uncomment for mounting custom ca-certificates file into container +# - name: ssl-certs +# mountPath: /etc/ssl/certs/ca-certificates.crt +# subPath: ca-certificates.crt + +podDisruptionBudget: + enabled: false + maxUnavailable: 1