Skip to content

Commit

Permalink
Fixes helm chart, sets liveness probe. Uses Helm standard fullname.
Browse files Browse the repository at this point in the history
  • Loading branch information
excalq authored and kuskoman committed Apr 12, 2023
1 parent a37796b commit ad8ffd9
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 92 deletions.
17 changes: 15 additions & 2 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
{{/*
Create a default fully qualified app name.
If release name contains chart name it will be used as a full name.
*/}}
{{- define "logstash-exporter.fullname" -}}
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- 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 }}

{{- define "logstash-exporter.name" -}}
{{- printf "%s" .Chart.Name | trunc 63 | trimSuffix "-" -}}
Expand Down
179 changes: 97 additions & 82 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,102 +10,117 @@ metadata:
{{- end }}
{{- with .Values.deployment.annotations }}
annotations:
{{ toYaml . | nindent 4 }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ required "deployment.replicas is required" .Values.deployment.replicas }}
selector:
matchLabels:
spec:
replicas: {{ required "deployment.replicas is required" .Values.deployment.replicas }}
selector:
matchLabels:
app: {{ include "logstash-exporter.name" . }}
release: {{ .Release.Name }}
strategy:
rollingUpdate:
maxSurge: {{ required "deployment.rollingUpdate.maxSurge is required" .Values.deployment.rollingUpdate.maxSurge }}
maxUnavailable: {{ required "deployment.rollingUpdate.maxUnavailable is required" .Values.deployment.rollingUpdate.maxUnavailable }}
type: RollingUpdate
template:
metadata:
labels:
app: {{ include "logstash-exporter.name" . }}
release: {{ .Release.Name }}
strategy:
rollingUpdate:
maxSurge: {{ required "deployment.rollingUpdate.maxSurge is required" .Values.deployment.rollingUpdate.maxSurge }}
maxUnavailable: {{ required "deployment.rollingUpdate.maxUnavailable is required" .Values.deployment.rollingUpdate.maxUnavailable }}
type: RollingUpdate
securityContext:
{{- toYaml .Values.deployment.securityContext | nindent 6 }}
dnsConfig:
{{- toYaml .Values.deployment.dnsConfig | nindent 6 }}
restartPolicy: {{ required "deployment.restartPolicy is required" .Values.deployment.restartPolicy }}
template:
metadata:
labels:
app: {{ include "logstash-exporter.name" . }}
release: {{ .Release.Name }}
{{- with .Values.deployment.podLabels }}
{{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.deployment.podAnnotations }}
annotations:
{{ toYaml . | nindent 10 }}
{{- end }}
spec:
{{- if .Values.deployment.imagePullSecrets }}
imagePullSecrets:
{{- range $pullSecret := .Values.deployment.pullSecret }}
- name: {{ $pullSecret }}
{{- end }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.deployment.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if .Values.deployment.imagePullSecrets }}
imagePullSecrets:
{{- range $pullSecret := .Values.deployment.pullSecret }}
- name: {{ $pullSecret }}
{{- end }}
{{- end }}

{{- if .Values.serviceAccount.enabled }}
{{- if .Values.serviceAccount.create }}
serviceAccountName: {{ include "logstash-exporter.serviceAccountName" . }}
{{- else }}
serviceAccountName: {{ .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- if .Values.deployment.priorityClassName }}
priorityClassName: {{ .Values.deployment.priorityClassName }}
{{- end }}

restartPolicy: {{ required "deployment.restartPolicy is required" .Values.deployment.restartPolicy }}

{{- if .Values.deployment.tolerations }}
tolerations:
{{- toYaml .Values.deployment.tolerations | nindent 8 }}
{{- end }}

{{- if .Values.deployment.affinity }}
affinity:
{{- toYaml .Values.deployment.affinity | nindent 8 }}
{{- end }}

{{- if .Values.deployment.nodeSelector }}
nodeSelector:
{{- toYaml .Values.deployment.nodeSelector | nindent 8 }}
{{- end }}

{{- if .Values.deployment.securityContext }}
securityContext:
{{- toYaml .Values.deployment.securityContext | nindent 8 }}
{{- end }}

{{- if .Values.deployment.dnsConfig }}
dnsConfig:
{{- toYaml .Values.deployment.dnsConfig | nindent 8 }}
{{- end }}

{{- if .Values.serviceAccount.enabled }}
{{- if .Values.serviceAccount.create }}
serviceAccountName: {{ include "logstash-exporter.serviceAccountName" . }}
{{- else }}
serviceAccountName: {{ .Values.serviceAccount.name }}
containers:
- name: exporter
env:
- name: LOGSTASH_URL
value: {{ required "logstash.url is required" .Values.logstash.url | quote }}
- name: PORT
value: {{ required "service.port is required" .Values.service.port | quote }}
{{- range $key, $value := .Values.deployment.env }}
- name: {{ $key | quote }}
value: {{ $value | quote }}
{{- end }}
{{- range $key, $value := .Values.deployment.envFrom }}
- name: {{ $key | quote }}
valueFrom:
{{- toYaml $value | nindent 14 }}
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}

{{- if .Values.deployment.priorityClassName }}
priorityClassName: {{ .Values.deployment.priorityClassName }}
{{- if .Values.deployment.resources }}
resources:
{{- toYaml .Values.deployment.resources | nindent 12 }}
{{- end }}

{{- if .Values.deployment.tolerations }}
{{- toYaml .Values.deployment.tolerations | nindent 8 }}
{{- if .Values.deployment.livenessProbe }}
livenessProbe:
{{- toYaml .Values.deployment.livenessProbe | nindent 12 }}
{{- end }}

{{- if .Values.deployment.affinity }}
{{- toYaml .Values.deployment.affinity | nindent 8 }}
{{- if .Values.deployment.readinessProbe }}
readinessProbe:
{{- toYaml .Values.deployment.readinessProbe | nindent 12 }}
{{- end }}

{{- if .Values.deployment.nodeSelector }}
{{- toYaml .Values.deployment.nodeSelector | nindent 8 }}
{{- with .Values.deployment.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
containers:
- name: exporter
env:
- name: LOGSTASH_URL
value: {{ required "logstash.url is required" .Values.logstash.url | quote }}
- name: PORT
value: {{ required "service.port is required" .Values.service.port | quote }}
{{- range $key, $value := .Values.deployment.env }}
- name: {{ $key | quote }}
value: {{ $value | quote }}
{{- end }}
{{- range $key, $value := .Values.deployment.envFrom }}
- name: {{ $key | quote }}
valueFrom:
{{- toYaml $value | nindent 14 }}
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.deployment.resources }}
resources:
{{- toYaml .Values.deployment.resources | nindent 12 }}
{{- end }}
{{- with .Values.deployment.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.deployment.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.deployment.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: {{ required "service.port is required" .Values.service.port }}
ports:
- name: http
containerPort: {{ required "service.port is required" .Values.service.port }}

14 changes: 6 additions & 8 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ image:
tag: "v1.0.2"
pullPolicy: IfNotPresent

fullnameOverride: ""

deployment:
replicas: 1
restartPolicy: Always
Expand All @@ -24,19 +26,15 @@ deployment:
dnsConfig: {}
securityContext: {}
livenessProbe:
enabled: true
httpGet:
path: /health
port: 9198
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
readinessProbe:
enabled: true
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
readinessProbe: {}
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
Expand Down

0 comments on commit ad8ffd9

Please sign in to comment.