Skip to content

Commit

Permalink
useStatefulSet switch in revad for stateful workloads
Browse files Browse the repository at this point in the history
This is specially useful when running into sharded scenarios as
e.g. different storage providers to map users with different
rules. Ref. cs3org/reva#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.
  • Loading branch information
SamuAlfageme committed Sep 17, 2020
1 parent d8c1c33 commit 3b2e5fc
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 9 deletions.
4 changes: 2 additions & 2 deletions revad/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions revad/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | `{}` |
Expand All @@ -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
```
39 changes: 32 additions & 7 deletions revad/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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 }}
4 changes: 4 additions & 0 deletions revad/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 2 additions & 0 deletions revad/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ extraVolumes: []
emptyDir:
sizeLimit: ""

useStatefulSet: false

persistentVolume:
## If true, revad will create/use a Persistent Volume Claim
## If false, use emptyDir
Expand Down

0 comments on commit 3b2e5fc

Please sign in to comment.