Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Volume:

LazyDBA247-Anyvision02be7ea2fcbc
diff --git a/k8s/README.md b/k8s/README.md
index 36230f7b22..c5615522c9 100644
--- a/k8s/README.md
+++ b/k8s/README.md
@@ -29,6 +29,14 @@ please set/update the corresponding affinity rule in values.yaml to an empty one
```affinity: ""```
+### PVC - storage class ###
+
+on the volume stateful set added support for K8S PVC, currently example
+with the simple local-path-provisioner from Rancher (comes included with k3d / k3s)
+https://github.com/rancher/local-path-provisioner
+
+you can use ANY storage class you like, just update the correct storage-class
+for your deployment.
### current instances config (AIO):
1 instance for each type (master/filer+s3/volume)
diff --git a/k8s/seaweedfs/templates/_helpers.tpl b/k8s/seaweedfs/templates/_helpers.tpl
index f6c4fa5709..a9ee89f03e 100644
--- a/k8s/seaweedfs/templates/_helpers.tpl
+++ b/k8s/seaweedfs/templates/_helpers.tpl
@@ -126,3 +126,26 @@ Inject extra environment vars in the format key:value, if populated
{{- printf "%s%s%s:%s" $registryName $repositoryName $name $tag -}}
{{- end -}}
{{- end -}}
+
+
+{{/* check if any PVC exists */}}
+{{- define "volume.pvc_exists" -}}
+{{- if or (or (eq .Values.volume.data.type "persistentVolumeClaim") (and (eq .Values.volume.idx.type "persistentVolumeClaim") .Values.volume.dir_idx )) (eq .Values.volume.logs.type "persistentVolumeClaim") -}}
+{{- printf "true" -}}
+{{- else -}}
+{{- printf "false" -}}
+{{- end -}}
+{{- end -}}
+
+{{/* check if any HostPath exists */}}
+{{- define "volume.hostpath_exists" -}}
+{{- if or (or (eq .Values.volume.data.type "hostPath") (and (eq .Values.volume.idx.type "hostPath") .Values.volume.dir_idx )) (eq .Values.volume.logs.type "hostPath") -}}
+{{- printf "true" -}}
+{{- else -}}
+{{- if or .Values.global.enableSecurity .Values.volume.extraVolumes -}}
+{{- printf "true" -}}
+{{- else -}}
+{{- printf "false" -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
diff --git a/k8s/seaweedfs/templates/volume-statefulset.yaml b/k8s/seaweedfs/templates/volume-statefulset.yaml
index f9e55e0d36..652fd9ea36 100644
--- a/k8s/seaweedfs/templates/volume-statefulset.yaml
+++ b/k8s/seaweedfs/templates/volume-statefulset.yaml
@@ -45,6 +45,19 @@ spec:
priorityClassName: {{ .Values.volume.priorityClassName | quote }}
{{- end }}
enableServiceLinks: false
+ {{- if .Values.volume.dir_idx }}
+ initContainers:
+ - name: seaweedfs-vol-move-idx
+ image: {{ template "volume.image" . }}
+ imagePullPolicy: {{ .Values.global.pullPolicy | default "IfNotPresent" }}
+ command: [ '/bin/sh', '-c' ]
+ args: ['if ls {{ .Values.volume.dir }}/*.idx >/dev/null 2>&1; then mv {{ .Values.volume.dir }}/*.idx {{ .Values.volume.dir_idx }}/; fi;']
+ volumeMounts:
+ - name: idx
+ mountPath: {{ .Values.volume.dir_idx }}
+ - name: data
+ mountPath: {{ .Values.volume.dir }}
+ {{- end }}
containers:
- name: seaweedfs
image: {{ template "volume.image" . }}
@@ -118,9 +131,13 @@ spec:
-compactionMBps={{ .Values.volume.compactionMBps }} \
-mserver={{ range $index := until (.Values.master.replicas | int) }}${SEAWEEDFS_FULLNAME}-master-{{ $index }}.${SEAWEEDFS_FULLNAME}-master:{{ $.Values.master.port }}{{ if lt $index (sub ($.Values.master.replicas | int) 1) }},{{ end }}{{ end }}
volumeMounts:
- - name: seaweedfs-volume-storage
- mountPath: "/data/"
- - name: seaweedfs-volume-log-volume
+ - name: data
+ mountPath: "{{ .Values.volume.dir }}/"
+ {{- if .Values.volume.dir_idx }}
+ - name: idx
+ mountPath: "{{ .Values.volume.dir_idx }}/"
+ {{- end }}
+ - name: logs
mountPath: "/logs/"
{{- if .Values.global.enableSecurity }}
- name: security-config
@@ -173,15 +190,27 @@ spec:
resources:
{{ tpl .Values.volume.resources . | nindent 12 | trim }}
{{- end }}
+ {{- $hostpath_exists := include "volume.hostpath_exists" . -}}
+ {{- if $hostpath_exists }}
volumes:
- - name: seaweedfs-volume-log-volume
+ {{- if eq .Values.volume.data.type "hostPath" }}
+ - name: data
hostPath:
- path: /storage/logs/seaweedfs/volume
+ path: /storage/object_store/
type: DirectoryOrCreate
- - name: seaweedfs-volume-storage
+ {{- end }}
+ {{- if and (eq .Values.volume.idx.type "hostPath") .Values.volume.dir_idx }}
+ - name: idx
hostPath:
- path: /storage/object_store/
+ path: /ssd/seaweedfs-volume-idx/
type: DirectoryOrCreate
+ {{- end }}
+ {{- if eq .Values.volume.logs.type "hostPath" }}
+ - name: logs
+ hostPath:
+ path: /storage/logs/seaweedfs/volume
+ type: DirectoryOrCreate
+ {{- end }}
{{- if .Values.global.enableSecurity }}
- name: security-config
configMap:
@@ -205,8 +234,43 @@ spec:
{{- if .Values.volume.extraVolumes }}
{{ tpl .Values.volume.extraVolumes . | indent 8 | trim }}
{{- end }}
+ {{- end }}
{{- if .Values.volume.nodeSelector }}
nodeSelector:
{{ tpl .Values.volume.nodeSelector . | indent 8 | trim }}
{{- end }}
+ {{- $pvc_exists := include "volume.pvc_exists" . -}}
+ {{- if $pvc_exists }}
+ volumeClaimTemplates:
+ {{- if eq .Values.volume.data.type "persistentVolumeClaim"}}
+ - metadata:
+ name: data
+ spec:
+ accessModes: [ "ReadWriteOnce" ]
+ storageClassName: {{ .Values.volume.data.storageClass }}
+ resources:
+ requests:
+ storage: {{ .Values.volume.data.size }}
+ {{- end }}
+ {{- if and (eq .Values.volume.idx.type "persistentVolumeClaim") .Values.volume.dir_idx }}
+ - metadata:
+ name: idx
+ spec:
+ accessModes: [ "ReadWriteOnce" ]
+ storageClassName: {{ .Values.volume.idx.storageClass }}
+ resources:
+ requests:
+ storage: {{ .Values.volume.idx.size }}
+ {{- end }}
+ {{- if eq .Values.volume.logs.type "persistentVolumeClaim" }}
+ - metadata:
+ name: logs
+ spec:
+ accessModes: [ "ReadWriteOnce" ]
+ storageClassName: {{ .Values.volume.logs.storageClass }}
+ resources:
+ requests:
+ storage: {{ .Values.volume.logs.size }}
+ {{- end }}
+ {{- end }}
{{- end }}
diff --git a/k8s/seaweedfs/values.yaml b/k8s/seaweedfs/values.yaml
index a055de8211..8768b32f6b 100644
--- a/k8s/seaweedfs/values.yaml
+++ b/k8s/seaweedfs/values.yaml
@@ -138,6 +138,24 @@ volume:
# minimum free disk space(in percents). If free disk space lower this value - all volumes marks as ReadOnly
minFreeSpacePercent: 7
+# can use ANY storage-class , example with local-path-provisner
+# data:
+# type: "persistentVolumeClaim"
+# size: "24Ti"
+# storageClass: "local-path-provisioner"
+ data:
+ type: "hostPath"
+ size: ""
+ storageClass: ""
+ idx:
+ type: "hostPath"
+ size: ""
+ storageClass: ""
+
+ logs:
+ type: "hostPath"
+ size: ""
+ storageClass: ""
# limit background compaction or copying speed in mega bytes per second
compactionMBps: "50"