aboutsummaryrefslogtreecommitdiff
path: root/k8s
diff options
context:
space:
mode:
Diffstat (limited to 'k8s')
-rw-r--r--k8s/README.md8
-rw-r--r--k8s/seaweedfs/templates/_helpers.tpl23
-rw-r--r--k8s/seaweedfs/templates/cronjob.yaml2
-rw-r--r--k8s/seaweedfs/templates/filer-service-client.yaml1
-rw-r--r--k8s/seaweedfs/templates/volume-statefulset.yaml78
-rw-r--r--k8s/seaweedfs/values.yaml18
6 files changed, 122 insertions, 8 deletions
diff --git a/k8s/README.md b/k8s/README.md
index 36230f7b2..c5615522c 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 f6c4fa570..a9ee89f03 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/cronjob.yaml b/k8s/seaweedfs/templates/cronjob.yaml
index c7dcd52b1..4caf4bad1 100644
--- a/k8s/seaweedfs/templates/cronjob.yaml
+++ b/k8s/seaweedfs/templates/cronjob.yaml
@@ -40,7 +40,7 @@ spec:
{{ if .Values.volume.dataCenter }} -dataCenter {{ .Values.volume.dataCenter }}{{ end }}\
{{ if .Values.cronjob.collection }} -collection {{ .Values.cronjob.collection }}{{ end }}\n\
{{- if .Values.cronjob.enableFixReplication }}
- volume.fix.replication {{ if .Values.cronjob.collectionPattern }} -collectionPattern={{ .Values.cronjob.collectionPattern }} {{ end }} \n\
+ volume.fix.replication -collectionPattern={{ .Values.cronjob.collectionPattern }} \n\
{{- end }}
unlock\n" | \
/usr/bin/weed shell \
diff --git a/k8s/seaweedfs/templates/filer-service-client.yaml b/k8s/seaweedfs/templates/filer-service-client.yaml
index f509086e3..929b6f8bc 100644
--- a/k8s/seaweedfs/templates/filer-service-client.yaml
+++ b/k8s/seaweedfs/templates/filer-service-client.yaml
@@ -10,6 +10,7 @@ metadata:
monitoring: "true"
{{- end }}
spec:
+ clusterIP: None
ports:
- name: "swfs-filer"
port: {{ .Values.filer.port }}
diff --git a/k8s/seaweedfs/templates/volume-statefulset.yaml b/k8s/seaweedfs/templates/volume-statefulset.yaml
index f9e55e0d3..652fd9ea3 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 a055de821..8768b32f6 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"