From 3b2e5fc5f6a3840ac8e6542560ed6e365240f228 Mon Sep 17 00:00:00 2001 From: Samuel Alfageme Date: Thu, 17 Sep 2020 15:03:33 +0200 Subject: [PATCH] useStatefulSet switch in revad for stateful workloads This is specially useful when running into sharded scenarios as e.g. different storage providers to map users with different rules. Ref. https://github.com/cs3org/reva/pull/1142 This commit contains a preliminary version, where the "real" uniqueness of each replica in the set (in terms of config) is yet to be implemented. First version will simply rely on the hostname as selector inside the 'configFiles' value for a user-provided toml file. --- revad/Chart.yaml | 4 ++-- revad/README.md | 6 +++++ revad/templates/deployment.yaml | 39 +++++++++++++++++++++++++++------ revad/templates/service.yaml | 4 ++++ revad/values.yaml | 2 ++ 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/revad/Chart.yaml b/revad/Chart.yaml index d884b24..b4a5219 100644 --- a/revad/Chart.yaml +++ b/revad/Chart.yaml @@ -3,8 +3,8 @@ apiVersion: v2 name: revad description: The Reva daemon (revad) helm chart type: application -version: 1.2.0 -appVersion: v1.2.0 +version: 1.2.1 +appVersion: v1.2.1 icon: https://reva.link/logo.svg home: https://reva.link source: https://github.com/cs3org/reva diff --git a/revad/README.md b/revad/README.md index 6960701..cade2c3 100644 --- a/revad/README.md +++ b/revad/README.md @@ -41,6 +41,7 @@ The following configurations may be set. It is recommended to use `values.yaml` | `extraVolumeMounts` | Array of additional volume mounts. | `[]` | | `extraVolumes` | Array of additional volumes. | `[]` | | `emptyDir.sizeLimit` | `emptyDir` `sizeLimit` if a Persistent Volume is not used | `""` | +| `useStatefulSet` | If true, Revad will be deployed using a `StatefulSet` rather than the usual `Deployment`. | `false` | | `persistentVolume.enabled` | If true, Revad will create a Persistent Volume Claim. | `false` | | `persistentVolume.accessModes` | Revad data Persistent Volume access modes. | `[ReadWriteOnce]` | | `persistentVolume.annotations` | Revad data Persistent Volume annotations. | `{}` | @@ -62,3 +63,8 @@ The following configurations may be set. It is recommended to use `values.yaml` $ helm install custom-reva cs3org/revad \ --set-file configFiles.revad\\.toml=custom-config.toml ``` + +### Stateful deployment + +```console +``` diff --git a/revad/templates/deployment.yaml b/revad/templates/deployment.yaml index 540d9ab..7fd4add 100644 --- a/revad/templates/deployment.yaml +++ b/revad/templates/deployment.yaml @@ -1,10 +1,13 @@ apiVersion: apps/v1 -kind: Deployment +kind: {{ if .Values.useStatefulSet }}{{ "StatefulSet" }}{{- else }}{{ "Deployment" }}{{- end }} metadata: name: {{ include "revad.fullname" . }} labels: {{- include "revad.labels" . | nindent 4 }} spec: + {{- if .Values.useStatefulSet }} + serviceName: {{ include "revad.fullname" . }} + {{- end }} replicas: {{ .Values.replicaCount }} selector: matchLabels: @@ -51,18 +54,40 @@ spec: - name: {{ include "revad.fullname" . }}-configfiles configMap: name: {{ template "revad.fullname" . }}-config + {{- if .Values.extraVolumes }} + {{ toYaml .Values.extraVolumes | nindent 8 }} + {{- end }} + {{- if .Values.persistentVolume.enabled }} + {{- if .Values.useStatefulSet }} + volumeClaimTemplates: + - metadata: + name: {{ include "revad.fullname" . }}-datadir + {{- if .Values.persistentVolume.annotations }} + annotations: + {{- toYaml .Values.persistentVolume.annotations | indent 10 }} + {{- end }} + spec: + accessModes: + {{- toYaml .Values.persistentVolume.accessModes | indent 10 }} + resources: + requests: + storage: "{{ .Values.persistentVolume.size }}" + {{- if (eq "-" .Values.persistentVolume.storageClass) }} + storageClassName: "" + {{- else }} + storageClassName: "{{ .Values.persistentVolume.storageClass }}" + {{- end }} + {{- else }} - name: {{ include "revad.fullname" . }}-datadir - {{- if .Values.persistentVolume.enabled }} persistentVolumeClaim: claimName: {{ if .Values.persistentVolume.existingClaim }}{{ .Values.persistentVolume.existingClaim }}{{- else }}{{ template "revad.fullname" . }}{{- end }} - {{- else }} + {{- end }} + {{- else }} + - name: {{ include "revad.fullname" . }}-datadir emptyDir: {{- if .Values.emptyDir.sizeLimit }} sizeLimit: {{ .Values.emptyDir.sizeLimit }} {{- else }} {} {{- end -}} - {{- end -}} - {{- if .Values.extraVolumes }} - {{ toYaml .Values.extraVolumes | nindent 8 }} - {{- end }} + {{- end }} diff --git a/revad/templates/service.yaml b/revad/templates/service.yaml index 5fba114..7616ea2 100644 --- a/revad/templates/service.yaml +++ b/revad/templates/service.yaml @@ -5,7 +5,11 @@ metadata: labels: {{- include "revad.labels" . | nindent 4 }} spec: + {{- if .Values.useStatefulSet }} + clusterIP: None + {{- else }} type: {{ .Values.service.type }} + {{- end }} ports: {{- if .Values.service.http }} - port: {{ .Values.service.http.port }} diff --git a/revad/values.yaml b/revad/values.yaml index 19839ce..7ab4e76 100644 --- a/revad/values.yaml +++ b/revad/values.yaml @@ -18,6 +18,8 @@ extraVolumes: [] emptyDir: sizeLimit: "" +useStatefulSet: false + persistentVolume: ## If true, revad will create/use a Persistent Volume Claim ## If false, use emptyDir