feat(helm): add helm chart

This commit is contained in:
2022-10-11 16:48:46 +02:00
parent 5cab1cd96d
commit 86bfdd5622
9 changed files with 247 additions and 73 deletions

View File

@ -56,9 +56,13 @@ app.kubernetes.io/instance: {{ .Release.Name }}
Create the name of the service account to use
*/}}
{{- define "pod-cleaner.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "pod-cleaner.fullname" .) .Values.serviceAccount.name }}
{{- if .Values.rbac.serviceAccount.create }}
{{- default (include "pod-cleaner.fullname" .) .Values.rbac.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- default "default" .Values.rbac.serviceAccount.name }}
{{- end }}
{{- end }}
{{- define "pod-cleaner.metrics.portName" -}}
http-metric
{{- end -}}

View File

@ -8,6 +8,11 @@ spec:
selector:
matchLabels:
{{- include "pod-cleaner.selectorLabels" . | nindent 6 }}
{{- if .Values.updateStrategy }}
updateStrategy:
{{ toYaml .Values.updateStrategy | nindent 4 | trim }}
{{- end }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
template:
metadata:
{{- with .Values.podAnnotations }}
@ -17,7 +22,7 @@ spec:
labels:
{{- include "pod-cleaner.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
{{- with .Values.image.pullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
@ -31,33 +36,40 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "--metric-path=/metrics"
- "--metric-path={{ .Values.podMonitor.path }}"
- "--metric-port=0.0.0.0:{{ .Values.service.port }}"
- "--log-file={{ .Values.podCleaner.logfile }}"
- "--log={{ .Values.podCleaner.logLevel }}"
ports:
- name: http-metric
- name: {{ include "pod-cleaner.metrics.portName" . }}
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /metrics
port: http-metric
path: {{ .Values.podMonitor.path }}
port: {{ include "pod-cleaner.metrics.portName" . }}
readinessProbe:
httpGet:
path: /metrics
port: http-metric
path: {{ .Values.podMonitor.path }}
port: {{ include "pod-cleaner.metrics.portName" . }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if or .Values.nodeAffinity }}
affinity:
{{- toYaml .Values.nodeAffinity | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{ tpl (toYaml . ) $ | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- tpl (toYaml . ) $ | nindent 8 }}
{{- end }}
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints: {{ tpl (toYaml . ) $ | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "pod-cleaner.serviceAccountName" . }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName | quote }}
{{- end }}

View File

@ -0,0 +1,30 @@
{{- if .Values.podMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "pod-cleaner.fullname" . }}
labels:
{{- include "pod-cleaner.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "pod-cleaner.labels" . | nindent 4 }}
podMetricsEndpoints:
- port: {{ include "pod-cleaner.metrics.portName" . | quote }}
path: {{ .Values.podMonitor.path | quote }}
{{- if .Values.podMonitor.tlsConfig }}
scheme: "https"
tlsConfig:
{{- toYaml .Values.podMonitor.tlsConfig | trim | nindent 8 }}
{{- end }}
interval: {{ .Values.podMonitor.interval }}
scrapeTimeout: {{ .Values.podMonitor.additionalLabels }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- if .Values.podMonitor.additionalLabels }}
jobLabel:
{{- toYaml .Values.podMonitor.additionalLabels | trim | nindent 4 }}
{{- end }}
{{- end }}

View File

@ -1,18 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "pod-cleaner.fullname" . }}
labels:
{{- include "pod-cleaner.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http-metric
protocol: TCP
name: http-metric
{{- if semverCompare ">= 1.24-0" .Capabilities.KubeVersion.Version }}
appProtocol: http
{{- end }}
selector:
{{- include "pod-cleaner.selectorLabels" . | nindent 4 }}

View File

@ -1,11 +1,11 @@
{{- if .Values.serviceAccount.create -}}
{{- if .Values.rbac.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "pod-cleaner.serviceAccountName" . }}
labels:
{{- include "pod-cleaner.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
{{- with .Values.rbac.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}