From 7d0efead892fff337feb6c3d5f2cdd099401031e Mon Sep 17 00:00:00 2001 From: jklein Date: Fri, 20 Feb 2026 10:55:14 +0100 Subject: [PATCH] feat(samba): added chart --- samba/.helmignore | 23 +++++++ samba/Chart.yaml | 9 +++ samba/templates/samba-config.configmap.yaml | 29 ++++++++ samba/templates/samba-shares.pvc.yaml | 14 ++++ samba/templates/samba-users.secret.yaml | 6 ++ samba/templates/samba.service.yaml | 19 ++++++ samba/templates/samba.sfs.yaml | 73 +++++++++++++++++++++ samba/values.yaml | 21 ++++++ 8 files changed, 194 insertions(+) create mode 100644 samba/.helmignore create mode 100644 samba/Chart.yaml create mode 100644 samba/templates/samba-config.configmap.yaml create mode 100644 samba/templates/samba-shares.pvc.yaml create mode 100644 samba/templates/samba-users.secret.yaml create mode 100644 samba/templates/samba.service.yaml create mode 100644 samba/templates/samba.sfs.yaml create mode 100644 samba/values.yaml diff --git a/samba/.helmignore b/samba/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/samba/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/samba/Chart.yaml b/samba/Chart.yaml new file mode 100644 index 0000000..aa28fb5 --- /dev/null +++ b/samba/Chart.yaml @@ -0,0 +1,9 @@ +apiVersion: v2 +name: samba +description: A Helm chart for Samba + +type: application + +version: 1.2.0-release-4-22-6 + +appVersion: 4.22.6 diff --git a/samba/templates/samba-config.configmap.yaml b/samba/templates/samba-config.configmap.yaml new file mode 100644 index 0000000..0aa9330 --- /dev/null +++ b/samba/templates/samba-config.configmap.yaml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-config-cfm +data: + smb.conf: |- + [global] + server string = cluster-samba + security = user + server signing = mandatory + server min protocol = SMB3 + server smb encrypt = required + + # disable printing services + load printers = no + printing = bsd + printcap name = /dev/null + disable spoolss = yes + + {{- range $index, $value := .Values.samba.shares }} + + [{{ $value.name }}] + path = /shares/{{ $value.name }} + comment = {{ $value.description }} + valid users = {{ $value.validUsers }} + writable = yes + vfs objects = streams_xattr + + {{- end }} \ No newline at end of file diff --git a/samba/templates/samba-shares.pvc.yaml b/samba/templates/samba-shares.pvc.yaml new file mode 100644 index 0000000..89eed63 --- /dev/null +++ b/samba/templates/samba-shares.pvc.yaml @@ -0,0 +1,14 @@ +{{- range $index, $value := .Values.samba.shares }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: "{{ $.Release.Name }}-{{ required "A name for the storage-share must be provided" $value.name }}-volume-claim" +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "{{ required "A size of the share-volume must be provided" $value.size }}" + storageClassName: {{ required "A storage-class must be provided" $.Values.samba.storageClass }} +--- +{{- end }} diff --git a/samba/templates/samba-users.secret.yaml b/samba/templates/samba-users.secret.yaml new file mode 100644 index 0000000..23c73cd --- /dev/null +++ b/samba/templates/samba-users.secret.yaml @@ -0,0 +1,6 @@ +apiVersion: onepassword.com/v1 +kind: OnePasswordItem +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-users-secret +spec: + itemPath: {{ required "A secret-reference for the samba-users-secret must be provided" .Values.secrets.sambaUsersRef }} diff --git a/samba/templates/samba.service.yaml b/samba/templates/samba.service.yaml new file mode 100644 index 0000000..9b40612 --- /dev/null +++ b/samba/templates/samba.service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-service +spec: + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }}-sfs + ports: + - protocol: TCP + port: 445 + targetPort: 445 + nodePort: 30445 + name: smb-port-445 + - protocol: TCP + port: 139 + targetPort: 139 + nodePort: 30139 + name: smb-port-139 + type: NodePort diff --git a/samba/templates/samba.sfs.yaml b/samba/templates/samba.sfs.yaml new file mode 100644 index 0000000..3ee24de --- /dev/null +++ b/samba/templates/samba.sfs.yaml @@ -0,0 +1,73 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-sfs + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }}-sfs +spec: + replicas: 1 + serviceName: {{ .Release.Name }}-{{ .Chart.Name }}-service + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }}-sfs + template: + metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-sfs + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }}-sfs + spec: + containers: + - name: {{ .Release.Name }}-{{ .Chart.Name }}-sfs + image: "ghcr.io/dockur/samba:{{ .Chart.AppVersion }}" + imagePullPolicy: IfNotPresent + ports: + - containerPort: 445 + protocol: TCP + - containerPort: 139 + protocol: TCP + volumeMounts: + - name: smb-config + mountPath: "/etc/samba/smb.conf" + readOnly: true + subPath: smb.conf + - name: smb-users + mountPath: "/etc/samba/users.conf" + readOnly: true + subPath: users.conf + {{- range $index, $value := .Values.samba.shares }} + + - name: "{{ $value.name }}" + mountPath: "/shares/{{ $value.name }}" + {{- end }} + resources: + requests: + memory: "{{ .Values.samba.resources.requests.memory }}" + cpu: "{{ .Values.samba.resources.requests.cpu }}" + ephemeral-storage: "{{ .Values.samba.resources.requests.ephemeralStorage }}" + limits: + memory: "{{ .Values.samba.resources.limits.memory }}" + cpu: "{{ .Values.samba.resources.limits.cpu }}" + ephemeral-storage: "{{ .Values.samba.resources.limits.ephemeralStorage }}" + restartPolicy: Always + automountServiceAccountToken: false + securityContext: + fsGroup: 1000 + volumes: + - name: smb-config + configMap: + name: {{ .Release.Name }}-{{ .Chart.Name }}-config-cfm + items: + - key: smb.conf + path: smb.conf + - name: smb-users + secret: + secretName: {{ .Release.Name }}-{{ .Chart.Name }}-users-secret + items: + - key: users.conf + path: users.conf + {{- range $index, $value := .Values.samba.shares }} + + - name: "{{ $value.name }}" + persistentVolumeClaim: + claimName: "{{ $.Release.Name }}-{{ $value.name }}-volume-claim" + {{- end }} diff --git a/samba/values.yaml b/samba/values.yaml new file mode 100644 index 0000000..1a3b16c --- /dev/null +++ b/samba/values.yaml @@ -0,0 +1,21 @@ +secrets: + sambaUsersRef: null + +samba: + shares: + - name: null + validUsers: null + description: null + size: null + resources: + requests: + memory: 50Mi + cpu: 0.1 + ephemeralStorage: 50Mi + limits: + memory: 100Mi + cpu: 1 + ephemeralStorage: 100Mi + + globalConfig: null + storageClass: longhorn \ No newline at end of file