2023-11-17 11:19:48 +00:00
|
|
|
{{ $smbconfchecksum := tpl (.Files.Get "conf/smb.conf") . | sha256sum -}}
|
|
|
|
{{ $userschecksum := include "userstocreate" . | sha256sum -}}
|
|
|
|
{{ $scriptchecksum := tpl (.Files.Get "scripts/k8s.sh") . | sha256sum -}}
|
|
|
|
{{ $fullName := include "samba4.fullname" . }}
|
|
|
|
apiVersion: apps/v1
|
|
|
|
kind: Deployment
|
|
|
|
metadata:
|
|
|
|
name: {{ $fullName }}
|
|
|
|
labels:
|
|
|
|
app.kubernetes.io/name: {{ include "samba4.name" . }}
|
|
|
|
helm.sh/chart: {{ include "samba4.chart" . }}
|
|
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
|
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
|
|
annotations:
|
|
|
|
checksum/smbconf: {{ $smbconfchecksum }}
|
|
|
|
checksum/users: {{ $userschecksum }}
|
|
|
|
{{ if .Values.image.lacksK8sScript -}}
|
|
|
|
checksum/script: {{ $scriptchecksum }}
|
|
|
|
{{- end }}
|
|
|
|
spec:
|
|
|
|
replicas: {{ .Values.replicaCount }}
|
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
app.kubernetes.io/name: {{ include "samba4.name" . }}
|
|
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app.kubernetes.io/name: {{ include "samba4.name" . }}
|
|
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
|
|
annotations:
|
|
|
|
checksum/smbconf: {{ $smbconfchecksum }}
|
|
|
|
checksum/users: {{ $userschecksum }}
|
|
|
|
{{- if .Values.image.lacksK8sScript }}
|
|
|
|
checksum/script: {{ $scriptchecksum }}
|
|
|
|
{{- end }}
|
|
|
|
spec:
|
|
|
|
{{- with .Values.podSecurityContext }}
|
|
|
|
securityContext:
|
|
|
|
{{- toYaml . | nindent 8 }}
|
|
|
|
{{- end }}
|
|
|
|
containers:
|
2024-03-04 11:27:08 +00:00
|
|
|
{{- if .Values.persistence.combineShares }}
|
|
|
|
- name: overlaymagic
|
|
|
|
image: busybox
|
2024-03-04 11:41:46 +00:00
|
|
|
securityContext:
|
|
|
|
privileged: true
|
2024-03-04 11:27:08 +00:00
|
|
|
command:
|
|
|
|
- /bin/sh
|
|
|
|
- -c
|
|
|
|
- --
|
|
|
|
args:
|
2024-09-13 14:51:03 +00:00
|
|
|
- {{ range .Values.persistence.sharesToCombine -}}
|
2024-09-13 14:45:25 +00:00
|
|
|
mkdir -p /combined/{{ .destName }};
|
2024-03-04 11:58:25 +00:00
|
|
|
mkdir -p /data/overlay-{{ .destName }}-upper;
|
|
|
|
mkdir -p /data/overlay-{{ .destName }}-work;
|
|
|
|
mount -t overlay -o lowerdir=/extras/{{ join ":/extras/" .shares }},upperdir=/data/overlay-{{ .destName }}-upper,workdir=/data/overlay-{{ .destName }}-work overlay /combined/{{ .destName }};
|
2024-03-04 11:27:08 +00:00
|
|
|
{{- end }}
|
2024-03-04 12:52:05 +00:00
|
|
|
touch /combined/overlays-mounted; sleep infinity;
|
2024-03-04 11:27:08 +00:00
|
|
|
lifecycle:
|
|
|
|
preStop:
|
|
|
|
exec:
|
|
|
|
command:
|
|
|
|
- /bin/sh
|
|
|
|
- -c
|
|
|
|
- {{ range .Values.persistence.sharesToCombine }}umount /combined/{{ .destName }}; {{- end }}
|
2024-03-04 11:41:46 +00:00
|
|
|
volumeMounts:
|
|
|
|
- mountPath: /data
|
|
|
|
name: data
|
|
|
|
{{- range .Values.persistence.extraPVCShares }}
|
|
|
|
- mountPath: /extras/{{ .name }}
|
|
|
|
name: {{ .name }}
|
|
|
|
{{- end }}
|
|
|
|
- mountPath: /combined
|
|
|
|
mountPropagation: Bidirectional
|
2024-03-04 11:43:14 +00:00
|
|
|
name: combined
|
2024-03-04 17:43:16 +00:00
|
|
|
{{- end }}
|
2023-11-17 11:19:48 +00:00
|
|
|
- name: {{ .Chart.Name }}
|
|
|
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
|
|
|
command:
|
|
|
|
- /bin/sh
|
|
|
|
- -c
|
2024-03-04 12:08:17 +00:00
|
|
|
- {{ if .Values.persistence.combineShares }}until [ -f /combined/overlays-mounted ]; do sleep 5; done; {{ end }}cd /scripts ; sh ./k8s.sh
|
2023-11-17 11:19:48 +00:00
|
|
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
|
|
ports:
|
|
|
|
- name: cifs
|
|
|
|
containerPort: 445
|
|
|
|
protocol: TCP
|
|
|
|
{{- if .Values.livenessProbe.enabled | default true }}
|
|
|
|
livenessProbe:
|
|
|
|
exec:
|
|
|
|
command:
|
|
|
|
- /bin/sh
|
|
|
|
- -c
|
|
|
|
- {{ .Values.livenessProbe.command | default "echo | smbclient -L 127.0.0.1" | quote }}
|
|
|
|
{{- end }}
|
|
|
|
readinessProbe:
|
|
|
|
tcpSocket:
|
|
|
|
port: cifs
|
|
|
|
resources:
|
|
|
|
{{- toYaml .Values.resources | nindent 12 }}
|
|
|
|
volumeMounts:
|
|
|
|
{{- if .Values.image.lacksK8sScript }}
|
|
|
|
- mountPath: /configmaps/scripts
|
|
|
|
name: scripts
|
|
|
|
{{- end }}
|
|
|
|
- mountPath: /secrets
|
|
|
|
name: users
|
|
|
|
- mountPath: /etc/samba/smb.conf
|
|
|
|
name: smbconf
|
|
|
|
subPath: smb.conf
|
|
|
|
- mountPath: /data
|
|
|
|
name: data
|
|
|
|
{{- range .Values.persistence.extraPVCShares }}
|
|
|
|
- mountPath: /extras/{{ .name }}
|
|
|
|
name: {{ .name }}
|
|
|
|
{{- end }}
|
|
|
|
- mountPath: /privatepersist
|
|
|
|
name: private
|
2024-03-04 12:30:40 +00:00
|
|
|
- mountPath: /combined
|
|
|
|
name: combined
|
2023-11-17 11:19:48 +00:00
|
|
|
{{- with .Values.nodeSelector }}
|
|
|
|
nodeSelector:
|
|
|
|
{{- toYaml . | nindent 8 }}
|
|
|
|
{{- end }}
|
|
|
|
{{- with .Values.affinity }}
|
|
|
|
affinity:
|
|
|
|
{{- toYaml . | nindent 8 }}
|
|
|
|
{{- end }}
|
|
|
|
{{- with .Values.tolerations }}
|
|
|
|
tolerations:
|
|
|
|
{{- toYaml . | nindent 8 }}
|
|
|
|
{{- end }}
|
|
|
|
volumes:
|
|
|
|
{{ if .Values.image.lacksK8sScript -}}
|
|
|
|
- name: scripts
|
|
|
|
configMap:
|
|
|
|
name: {{ $fullName }}-packagescripts
|
|
|
|
defaultMode: 0555
|
|
|
|
items:
|
|
|
|
- key: k8s.sh
|
|
|
|
path: k8s.sh
|
|
|
|
{{- end }}
|
|
|
|
- name: smbconf
|
|
|
|
configMap:
|
|
|
|
name: {{ $fullName }}-smbconf
|
|
|
|
defaultMode: 0644
|
|
|
|
items:
|
|
|
|
- key: smb.conf
|
|
|
|
path: smb.conf
|
|
|
|
- name: users
|
|
|
|
secret:
|
|
|
|
secretName: {{ $fullName }}-users
|
|
|
|
defaultMode: 0600
|
|
|
|
- name: data
|
|
|
|
{{ if .Values.persistence.enabled -}}
|
|
|
|
{{ if eq .Values.persistence.type "pvc" }}
|
|
|
|
persistentVolumeClaim:
|
|
|
|
claimName: {{ if .Values.persistence.pvc.existingClaim }}{{ .Values.persistence.pvc.existingClaim }}{{- else }}{{ template "samba4.fullname" . }}-data{{- end }}
|
|
|
|
{{ else if eq .Values.persistence.type "flexVolume" }}
|
|
|
|
#{{ required "A valid flexVolume block is required when using flexVolume persistence!" .Values.persistence.flexVolume }}
|
|
|
|
flexVolume:
|
|
|
|
{{ .Values.persistence.flexVolume | toYaml | indent 10 }}
|
|
|
|
{{- else if eq .Values.persistence.type "hostPath" }}
|
|
|
|
#{{ required "A valid hostPath.path is required when using hostPath persistence!" .Values.persistence.hostPath.path }}
|
|
|
|
hostPath:
|
|
|
|
path: {{ .Values.persistence.hostPath.path }}
|
|
|
|
{{ if .Values.persistence.hostPath.type -}}
|
|
|
|
type: {{ .Values.persistence.hostPath.type }}
|
|
|
|
{{ end -}}
|
|
|
|
{{ else if eq .Values.persistence.type "other" -}}
|
|
|
|
#{{ required "A valid other block is required when using flexVolume persistence!" .Values.persistence.other }}
|
|
|
|
{{ .Values.persistence.other | toYaml | indent 8 }}
|
|
|
|
{{ else -}}
|
|
|
|
{{ fail "if persistence is enabled, persistence.type must be one of 'pvc','flexVolume','hostPath' or 'other'!" }}
|
|
|
|
{{ end -}}
|
|
|
|
{{ else }}
|
|
|
|
emptyDir: {}
|
|
|
|
{{ end }}
|
|
|
|
- name: private
|
|
|
|
{{ if .Values.privatePersistence.enabled -}}
|
|
|
|
{{- $p := .Values.persistence -}}
|
|
|
|
{{- $pp := .Values.privatePersistence -}}
|
|
|
|
{{- if eq ($pp.type | default $p.type) "pvc" }}
|
|
|
|
persistentVolumeClaim:
|
|
|
|
claimName: {{ if $pp.pvc.existingClaim }}{{ $pp.pvc.existingClaim }}{{- else }}{{ template "samba4.fullname" . }}-private{{- end }}
|
|
|
|
{{ else if eq ($pp.type | default $p.type) "flexVolume" }}
|
|
|
|
#{{ required "A valid flexVolume block is required when using hostPath persistence!" $pp.flexVolume }}
|
|
|
|
flexVolume:
|
|
|
|
{{ $pp.flexVolume | toYaml | indent 10 }}
|
|
|
|
{{ else if eq ($pp.type | default $p.type) "hostPath" }}
|
|
|
|
#{{ required "A valid flexVolume block is required when using flexVolume persistence!" .Values.privatePersistence.flexVolume }}
|
|
|
|
hostPath:
|
|
|
|
path: {{ if .Values.privatePersistence.hostPath.path }}{{ .Values.privatePersistence.hostPath.path }}{{ else }}{{ .Values.persistence.hostPath.path }}/.smbprivate/{{ end }}
|
|
|
|
{{ if .Values.privatePersistence.hostPath.type -}}
|
|
|
|
type: {{ $pp.hostPath.type | $p.hostPath.type | default "Directory" | quote }}
|
|
|
|
{{ end -}}
|
|
|
|
{{ else if eq ($pp.type | default $p.type) "other" -}}
|
|
|
|
#{{ required "A valid other block is required when using flexVolume persistence!" .Values.privatePersistence.other }}
|
|
|
|
{{ $pp.other | toYaml | indent 8 }}
|
|
|
|
{{ else -}}
|
|
|
|
{{ fail "if privatePersistence is enabled, privatePersistence.type must be one of 'pvc','flexVolume','hostPath' or 'other'!" }}
|
|
|
|
{{ end -}}
|
|
|
|
{{ else }}
|
|
|
|
emptyDir: {}
|
|
|
|
{{ end -}}
|
|
|
|
{{ if .Values.persistence.enabled }}
|
|
|
|
{{- range .Values.persistence.extraPVCShares }}
|
|
|
|
- name: {{ .name }}
|
|
|
|
persistentVolumeClaim:
|
|
|
|
claimName: {{ $fullName }}-{{ .name }}
|
|
|
|
{{- end }}
|
2024-03-04 17:41:44 +00:00
|
|
|
{{- end }}
|
2024-03-04 11:43:14 +00:00
|
|
|
- name: combined
|
2024-03-04 11:41:46 +00:00
|
|
|
emptyDir: {}
|