Skip to content

Commit bab7f7d

Browse files
committed
[azure-keyvault-exporter] initial revision
Signed-off-by: Markus Blaschke <mblaschke82@gmail.com>
1 parent 51352f5 commit bab7f7d

File tree

10 files changed

+493
-1
lines changed

10 files changed

+493
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ dependencies:
2727
2828
## charts
2929
30-
| Chart | Description | Project |
30+
| Chart | Description | GitHub project |
3131
|---------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
3232
| [azure-janitor](./charts/azure-janitor) | Automated removal of Azure resources based on ttl tag | [![](https://img.shields.io/badge/github-webdevops%2Fazure--janitor-blue)](https://github.com/webdevops/azure-janitor) |
33+
| [azure-keyvault-exporter](./charts/azure-keyvault-exporter) | Prometheus exporter for Azure KeyVault metrics (secrets, certificates, ...) eg expiry time | [![](https://img.shields.io/badge/github-webdevops%2Fazure--keyvault--exporter-blue)](https://github.com/webdevops/azure-keyvault-exporter) |
3334
| [azure-metrics-exporter](./charts/azure-metrics-exporter) | Prometheus exporter for Azure Monitor metrics | [![](https://img.shields.io/badge/github-webdevops%2Fazure--metrics--exporter-blue)](https://github.com/webdevops/azure-metrics-exporter) |
3435
| [azure-resourcemanager-exporter](./charts/azure-resourcemanager-exporter) | Prometheus exporter for Azure ResourceManager information | [![](https://img.shields.io/badge/github-webdevops%2Fazure--resourcemanager--exporter-blue)](https://github.com/webdevops/azure-resourcemanager-exporter) |
3536
| [azure-scheduledevents-manager](./charts/azure-scheduledevents-manager) | Manages [Azure ScheduledEvents](https://learn.microsoft.com/en-us/azure/virtual-machines/windows/scheduled-events) (drain nodes) and provides metrics for upcoming Azure ScheduledEvents | [![](https://img.shields.io/badge/github-webdevops%2Fazure--scheduledevents--manager-blue)](https://github.com/webdevops/azure-scheduledevents-manager) |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v2
2+
name: azure-keyvault-exporter
3+
type: application
4+
description: A Helm chart for azure-keyvault-exporter
5+
home: https://github.com/webdevops/azure-keyvault-exporter
6+
version: 1.0.0
7+
appVersion: 22.9.0
8+
keywords:
9+
- azure-keyvault-exporter
10+
maintainers:
11+
- email: mblaschke82@gmail.com
12+
name: mblaschke
13+
sources:
14+
- https://github.com/webdevops/azure-keyvault-exporter/
15+
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/* Expand the name of the chart. */}}
3+
{{- define "azure-keyvault-exporter.name" -}}
4+
{{- default .Chart.Name .Values.nameOverride | trunc 50 | trimSuffix "-" -}}
5+
{{- end }}
6+
7+
{{/*
8+
Create a default fully qualified app name.
9+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
10+
*/}}
11+
{{- define "azure-keyvault-exporter.fullname" -}}
12+
{{- if .Values.fullnameOverride -}}
13+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
14+
{{- else -}}
15+
{{- $name := default .Chart.Name .Values.nameOverride -}}
16+
{{- if contains $name .Release.Name -}}
17+
{{- .Release.Name | trunc 26 | trimSuffix "-" -}}
18+
{{- else -}}
19+
{{- printf "%s-%s" .Release.Name $name | trunc 26 | trimSuffix "-" -}}
20+
{{- end -}}
21+
{{- end -}}
22+
{{- end -}}
23+
24+
{{/*
25+
Create chart name and version as used by the chart label.
26+
*/}}
27+
{{- define "azure-keyvault-exporter.chart" -}}
28+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
29+
{{- end -}}
30+
31+
32+
{{/*
33+
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
34+
*/}}
35+
{{- define "azure-keyvault-exporter.namespace" -}}
36+
{{- if .Values.namespaceOverride -}}
37+
{{- .Values.namespaceOverride -}}
38+
{{- else -}}
39+
{{- .Release.Namespace -}}
40+
{{- end -}}
41+
{{- end -}}
42+
43+
{{/* Generate basic labels */}}
44+
{{- define "azure-keyvault-exporter.labels" }}
45+
helm.sh/chart: {{ template "azure-keyvault-exporter.chart" . }}
46+
app.kubernetes.io/managed-by: {{ .Release.Service }}
47+
app.kubernetes.io/component: metrics
48+
app.kubernetes.io/part-of: {{ template "azure-keyvault-exporter.name" . }}
49+
{{- include "azure-keyvault-exporter.selectorLabels" . }}
50+
{{- if .Chart.AppVersion }}
51+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
52+
{{- end }}
53+
{{- if .Values.podLabels}}
54+
{{ toYaml .Values.podLabels }}
55+
{{- end }}
56+
{{- if .Values.releaseLabel }}
57+
release: {{ .Release.Name }}
58+
{{- end }}
59+
{{- end }}
60+
61+
{{/*
62+
Selector labels
63+
*/}}
64+
{{- define "azure-keyvault-exporter.selectorLabels" }}
65+
app.kubernetes.io/instance: {{ .Release.Name }}
66+
app.kubernetes.io/name: {{ template "azure-keyvault-exporter.name" . }}
67+
{{- end }}
68+
69+
{{/*
70+
The image to use
71+
*/}}
72+
{{- define "azure-keyvault-exporter.image" -}}
73+
{{- if .Values.image.sha -}}
74+
{{- printf "%s/%s:%s@%s" .Values.image.registry .Values.image.repository (default (printf "%s" .Chart.AppVersion) .Values.image.tag) .Values.image.sha }}
75+
{{- else -}}
76+
{{- printf "%s/%s:%s" .Values.image.registry .Values.image.repository (default (printf "%s" .Chart.AppVersion) .Values.image.tag) }}
77+
{{- end }}
78+
{{- end }}
79+
80+
81+
{{/*
82+
Create the name of the service account to use
83+
*/}}
84+
{{- define "azure-keyvault-exporter.serviceAccountName" -}}
85+
{{- if .Values.serviceAccount.create }}
86+
{{- default (include "azure-keyvault-exporter.fullname" .) .Values.serviceAccount.name }}
87+
{{- else }}
88+
{{- default "default" .Values.serviceAccount.name }}
89+
{{- end }}
90+
{{- end }}
91+
92+
{{/* Sets default scrape limits for servicemonitor */}}
93+
{{- define "servicemonitor.scrapeLimits" -}}
94+
{{- if .sampleLimit }}
95+
sampleLimit: {{ .sampleLimit }}
96+
{{- end }}
97+
{{- if .targetLimit }}
98+
targetLimit: {{ .targetLimit }}
99+
{{- end }}
100+
{{- if .labelLimit }}
101+
labelLimit: {{ .labelLimit }}
102+
{{- end }}
103+
{{- if .labelNameLengthLimit }}
104+
labelNameLengthLimit: {{ .labelNameLengthLimit }}
105+
{{- end }}
106+
{{- if .labelValueLengthLimit }}
107+
labelValueLengthLimit: {{ .labelValueLengthLimit }}
108+
{{- end }}
109+
{{- end }}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{{- $secretHash := include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
2+
---
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: {{ template "azure-keyvault-exporter.fullname" . }}
7+
namespace: {{ template "azure-keyvault-exporter.namespace" . }}
8+
labels: {{ include "azure-keyvault-exporter.labels" . | indent 4 }}
9+
spec:
10+
{{- with .Values.replicas }}
11+
replicas: {{ . }}
12+
{{- end }}
13+
{{- with .Values.strategy }}
14+
strategy: {{ toYaml . | nindent 4 }}
15+
{{- end }}
16+
17+
selector:
18+
matchLabels: {{- include "azure-keyvault-exporter.selectorLabels" . | nindent 6 }}
19+
20+
minReadySeconds: {{ .minReadySeconds }}
21+
template:
22+
metadata:
23+
labels:
24+
{{ include "azure-keyvault-exporter.labels" . | indent 8 }}
25+
{{- with .Values.podLabels }}
26+
{{ toYaml . | indent 8 }}
27+
{{- end }}
28+
annotations:
29+
checksum/secret: {{ $secretHash | quote }}
30+
{{- with .Values.podAnnotations }}
31+
{{ toYaml . | indent 8 }}
32+
{{- end }}
33+
34+
spec:
35+
serviceAccountName: {{ .Values.serviceAccount.name | quote }}
36+
priorityClassName: {{ .Values.priorityClassName | quote }}
37+
38+
securityContext: {{ toYaml .Values.securityContext | nindent 8 }}
39+
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
40+
41+
containers:
42+
#######################
43+
# Kube pool manager
44+
#######################
45+
- name: azure-keyvault-exporter
46+
image: {{ include "azure-keyvault-exporter.image" . | quote }}
47+
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
48+
49+
securityContext: {{ toYaml .Values.containerSecurityContext | nindent 12 }}
50+
51+
env:
52+
{{- range $index, $val := .Values.secrets }}
53+
- name: {{ $index | quote }}
54+
valueFrom:
55+
secretKeyRef:
56+
name: {{ template "azure-keyvault-exporter.fullname" . }}
57+
key: {{ $index | quote }}
58+
{{- end }}
59+
{{ with .Values.env }}
60+
{{ toYaml . | nindent 12 }}
61+
{{end}}
62+
63+
ports:
64+
- containerPort: 8080
65+
name: http-metrics
66+
protocol: TCP
67+
68+
{{- with .Values.resources }}
69+
resources: {{ toYaml . | nindent 12 }}
70+
{{- end }}
71+
{{- with .Values.startupProbe }}
72+
startupProbe: {{ toYaml . | nindent 12 }}
73+
{{- end }}
74+
{{- with .Values.livenessProbe }}
75+
livenessProbe: {{ toYaml . | nindent 12 }}
76+
{{- end }}
77+
{{- with .Values.readinessProbe }}
78+
readinessProbe: {{ toYaml . | nindent 12 }}
79+
{{- end }}
80+
81+
{{- with .Values.nodeSelector }}
82+
nodeSelector: {{ toYaml . | nindent 8 }}
83+
{{- end }}
84+
{{- with .Values.affinity }}
85+
affinity: {{ toYaml . | nindent 8 }}
86+
{{- end }}
87+
{{- with .Values.tolerations }}
88+
tolerations: {{ toYaml . | nindent 8 }}
89+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if .Values.netpol.enabled }}
2+
---
3+
apiVersion: networking.k8s.io/v1
4+
kind: NetworkPolicy
5+
metadata:
6+
name: {{ template "azure-keyvault-exporter.fullname" . }}
7+
namespace: {{ template "azure-keyvault-exporter.namespace" . }}
8+
labels: {{ include "azure-keyvault-exporter.labels" . | indent 4 }}
9+
spec:
10+
podSelector:
11+
matchLabels: {{- include "azure-keyvault-exporter.selectorLabels" . | nindent 6 }}
12+
policyTypes: {{ toYaml .Values.netpol.policyTypes | nindent 4 }}
13+
ingress: {{ toYaml .Values.netpol.ingress | nindent 4 }}
14+
egress: {{ toYaml .Values.netpol.egress | nindent 4 }}
15+
{{- end }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- if .Values.prometheus.monitor.enabled }}
2+
---
3+
apiVersion: monitoring.coreos.com/v1
4+
kind: ServiceMonitor
5+
metadata:
6+
name: {{ template "azure-keyvault-exporter.fullname" . }}
7+
namespace: {{ template "azure-keyvault-exporter.namespace" . }}
8+
labels: {{ include "azure-keyvault-exporter.labels" . | indent 4 }}
9+
spec:
10+
jobLabel: {{ default "app.kubernetes.io/name" .Values.prometheus.monitor.jobLabel }}
11+
{{ include "servicemonitor.scrapeLimits" .Values.prometheus.monitor | indent 2 }}
12+
selector:
13+
matchLabels: {{- include "azure-keyvault-exporter.selectorLabels" . | nindent 6 }}
14+
endpoints:
15+
- port: {{ .Values.service.portName }}
16+
scheme: {{ .Values.prometheus.monitor.scheme }}
17+
{{- with .Values.prometheus.monitor.basicAuth }}
18+
basicAuth: {{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
{{- with .Values.prometheus.monitor.bearerTokenFile }}
21+
bearerTokenFile: {{ . }}
22+
{{- end }}
23+
{{- with .Values.prometheus.monitor.tlsConfig }}
24+
tlsConfig: {{- toYaml . | nindent 8 }}
25+
{{- end }}
26+
{{- with .Values.prometheus.monitor.proxyUrl }}
27+
proxyUrl: {{ . }}
28+
{{- end }}
29+
{{- with .Values.prometheus.monitor.interval }}
30+
interval: {{ . }}
31+
{{- end }}
32+
{{- with .Values.prometheus.monitor.scrapeTimeout }}
33+
scrapeTimeout: {{ . }}
34+
{{- end }}
35+
{{- with .Values.prometheus.monitor.relabelings }}
36+
relabelings: {{- toYaml . | nindent 8 }}
37+
{{- end }}
38+
{{- with .Values.prometheus.monitor.metricRelabelings }}
39+
metricRelabelings: {{- toYaml . | nindent 8 }}
40+
{{- end }}
41+
{{ end }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{- if .Values.secrets }}
2+
---
3+
apiVersion: v1
4+
kind: Secret
5+
type: Opaque
6+
metadata:
7+
name: {{ template "azure-keyvault-exporter.fullname" . }}
8+
namespace: {{ template "azure-keyvault-exporter.namespace" . }}
9+
labels: {{ include "azure-keyvault-exporter.labels" . | indent 4 }}
10+
data:
11+
{{- range $index, $val := .Values.secrets }}
12+
{{ $index | quote }}: {{ $val | b64enc | quote }}
13+
{{- end }}
14+
{{- end }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
kind: Service
3+
apiVersion: v1
4+
metadata:
5+
name: {{ template "azure-keyvault-exporter.fullname" . }}
6+
namespace: {{ template "azure-keyvault-exporter.namespace" . }}
7+
labels:
8+
{{ include "azure-keyvault-exporter.labels" . | indent 4 }}
9+
{{- if .Values.service.labels }}
10+
{{ toYaml .Values.service.labels | indent 4 }}
11+
{{- end }}
12+
{{- if .Values.service.annotations }}
13+
annotations: {{ toYaml .Values.service.annotations | nindent 4 }}
14+
{{- end }}
15+
spec:
16+
type: {{ .Values.service.type }}
17+
ports:
18+
- port: {{ .Values.service.port }}
19+
{{- if ( and (eq .Values.service.type "NodePort" ) (not (empty .Values.service.nodePort)) ) }}
20+
nodePort: {{ .Values.service.nodePort }}
21+
{{- end }}
22+
targetPort: {{ .Values.service.targetPort }}
23+
protocol: TCP
24+
name: {{ .Values.service.portName }}
25+
appProtocol: http
26+
selector: {{- include "azure-keyvault-exporter.selectorLabels" . | nindent 4 }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: {{ .Values.serviceAccount.name | quote }}
5+
namespace: {{ template "azure-keyvault-exporter.namespace" . }}
6+
labels:
7+
{{ include "azure-keyvault-exporter.labels" . | indent 4 }}
8+
{{- if .Values.serviceAccount.labels }}
9+
{{ toYaml .Values.serviceAccount.labels | indent 4 }}
10+
{{- end }}
11+
{{- if .Values.serviceAccount.annotations }}
12+
annotations: {{ toYaml .Values.serviceAccount.annotations | nindent 4 }}
13+
{{- end }}
14+
{{- if .Values.global.imagePullSecrets }}
15+
imagePullSecrets:
16+
{{ include "azure-keyvault-exporter.imagePullSecrets" . | trim | indent 2 }}
17+
{{- end }}

0 commit comments

Comments
 (0)