Skip to content

Commit

Permalink
[#39] Parametrize common values
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Nov 9, 2021
1 parent d654032 commit f43468b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
7 changes: 7 additions & 0 deletions k8s/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- define "infracheck.appName" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "infracheck.chartName" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
45 changes: 43 additions & 2 deletions k8s/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# todo: support annotations and other things required for Vault, support taints and node selector
# todo: sqlite3 database (cache) volume

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
labels:
helm.sh/chart: {{ include "infracheck.chartName" . }}
app.kubernetes.io/name: {{ include "infracheck.appName" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- if .Values.deployment.labels }}
{{ toYaml .Values.deployment.labels | indent 4 }}
{{- end }}
spec:
replicas: 1
replicas: {{ .Values.deployment.replicas }}
selector:
matchLabels:
app: {{ .Release.Name }}
Expand All @@ -15,6 +27,15 @@ spec:
labels:
app: {{ .Release.Name }}
spec:
{{- with .Values.deployment.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 16 }}
{{- end }}

{{- with .Values.deployment.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 16 }}
{{- end }}
volumes:
- name: scripts
configMap:
Expand All @@ -23,13 +44,33 @@ spec:
configMap:
name: {{ .Release.Name }}-configs

{{- with .Values.deployment.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 16 }}
{{- end }}
{{- with .Values.deployment.affinity }}
affinity:
{{- toYaml . | nindent 16 }}
{{- end }}
{{- with .Values.deployment.tolerations }}
tolerations:
{{- toYaml . | nindent 16 }}
{{- end }}

containers:
- name: app
image: {{ .Values.deployment.image }}:{{ .Values.deployment.version }}
image: {{ .Values.deployment.image }}:v{{ .Chart.AppVersion }}-x86_64
ports:
- containerPort: 8000
volumeMounts:
- name: scripts
mountPath: /data/checks
- name: configs
mountPath: /data/configured
{{- with .Values.deployment.environment }}
env:
{{- range $key, $val := . }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
{{ end }}
9 changes: 9 additions & 0 deletions k8s/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
deployment:
image: quay.io/riotkit/infracheck
version: v2.1.2-x86_64
replicas: 1
imagePullSecrets: []
podSecurityContext: {}
environment:
AUTHORS: https://github.com/riotkit-org
labels: {}
nodeSelector: {}
affinity: {}
tolerations: []

ingress:
enabled: true
Expand Down

0 comments on commit f43468b

Please sign in to comment.