Skip to content

Commit

Permalink
Merge pull request #208 from pure-jliao/volumeexpansion
Browse files Browse the repository at this point in the history
CSI volume expansion support
  • Loading branch information
pure-jliao authored Apr 21, 2020
2 parents d0cf4ee + 67d4ffa commit 46dbbbc
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 12 deletions.
32 changes: 20 additions & 12 deletions operator-csi-plugin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ rules:
- \"list\"
- \"watch\"
- \"update\"
- \"patch\"
- apiGroups:
- \"\"
resources:
Expand All @@ -213,6 +214,13 @@ rules:
- \"list\"
- \"update\"
- \"watch\"
- apiGroups:
- \"\"
resources:
- persistentvolumeclaims/status
verbs:
- \"update\"
- \"patch\"
- apiGroups:
- storage.k8s.io
resources:
Expand Down Expand Up @@ -267,40 +275,40 @@ rules:
- \"get\"
- \"list\"
- \"watch\"
- apiGroups:
- apiGroups:
- storage.k8s.io
resources:
resources:
- \"csinodes\"
verbs:
verbs:
- \"get\"
- \"list\"
- \"watch\"
- apiGroups:
- apiGroups:
- \"\"
resources:
- \"nodes\"
verbs:
- \"get\"
- \"list\"
- \"watch\"
# Need the same permissions as driver-registrar-runner clusterrole to be able to create it. Only for K8s 1.13
- apiGroups:
# Need the same permissions as driver-registrat-runner clusterrole to be able to create it. Only for K8s 1.13
- apiGroups:
- \"apiextensions.k8s.io\"
resources:
resources:
- \"customresourcedefinitions\"
verbs:
verbs:
- \"*\"
- apiGroups:
- apiGroups:
- \"csi.storage.k8s.io\"
resources:
- \"csidrivers\"
verbs:
verbs:
- \"*\"
- apiGroups:
- apiGroups:
- \"storage.k8s.io\"
resources:
- \"csidrivers\"
verbs:
verbs:
- \"*\"
# Need the same permissions as pure-topology-runner clusterrole to be able to create it.
Expand Down
1 change: 1 addition & 0 deletions pure-csi/templates/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ spec:
app: pure-csi
{{ include "pure_csi.labels" . | indent 8}}
spec:
serviceAccountName: {{ .Values.clusterrolebinding.serviceAccount.name }}
hostNetwork: true
hostPID: true
containers:
Expand Down
17 changes: 17 additions & 0 deletions pure-csi/templates/provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ spec:
- name: socket-dir
mountPath: /csi
{{- end }}
# The csi-resizer sidecar that watches the Kubernetes API server for PersistentVolumeClaim updates.
# Does not scale with more replicas, only one is elected as leader and running.
# PSO requires K8s 1.16+ for CSI VolumeExpansion
{{ if and (eq .Capabilities.KubeVersion.Major "1") (gt .Capabilities.KubeVersion.Minor "15") }}
- name: csi-resizer
{{- with .Values.csi.resizer.image }}
image: {{ .name | default "quay.io/k8scsi/csi-resizer" }}:v0.5.0
imagePullPolicy: {{ .pullPolicy }}
{{- end }}
args:
- "--csi-address=/csi/csi.sock"
- "--csiTimeout=15s"
- "--leader-election=false"
volumeMounts:
- name: socket-dir
mountPath: /csi
{{ end }}
# This is the cluster-driver-registrar sidecar that allows helm-install without CRD-hooks for the CSIDriver CRD
# The reason we do not want a crd-hook with helm-chart is to avoid upgrade issues like: https://github.com/helm/helm/issues/4489
{{ if and (eq .Capabilities.KubeVersion.Major "1") (eq .Capabilities.KubeVersion.Minor "13") }}
Expand Down
46 changes: 46 additions & 0 deletions pure-csi/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,49 @@ roleRef:
apiGroup: rbac.authorization.k8s.io

{{ end }}

{{ if and (eq .Capabilities.KubeVersion.Major "1") (gt .Capabilities.KubeVersion.Minor "15") }}
# PSO requires K8s 1.16+ for CSI VolumeExpansion
# This file is downloaded from https://github.com/kubernetes-csi/external-resizer/blob/master/deploy/kubernetes/rbac.yaml
---
kind: ClusterRole
apiVersion: {{ template "rbac.apiVersion" . }}
metadata:
name: external-resizer-runner
labels:
{{ include "pure_csi.labels" . | indent 4}}
rules:
# The following rule should be uncommented for plugins that require secrets
# for provisioning.
# - apiGroups: [""]
# resources: ["secrets"]
# verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims/status"]
verbs: ["update", "patch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
---

kind: ClusterRoleBinding
apiVersion: {{ template "rbac.apiVersion" . }}
metadata:
name: csi-resizer-role
labels:
{{ include "pure_csi.labels" . | indent 4}}
subjects:
- kind: ServiceAccount
name: {{ .Values.clusterrolebinding.serviceAccount.name }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: external-resizer-runner
apiGroup: rbac.authorization.k8s.io
{{ end }}
12 changes: 12 additions & 0 deletions pure-csi/templates/storageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ parameters:
csi.storage.k8s.io/fstype: {{ .Values.flasharray.defaultFSType | default "xfs" | quote }}
createoptions: {{ .Values.flasharray.defaultFSOpt | default "-q" | quote }}
{{- end }}
# PSO requires K8s 1.16+ for CSI VolumeExpansion
{{ if and (eq .Capabilities.KubeVersion.Major "1") (gt .Capabilities.KubeVersion.Minor "15") }}
allowVolumeExpansion: true
{{ end }}
{{- if eq .Values.storageclass.pureBackend "file"}}
mountOptions:
{{- else -}}
Expand All @@ -40,6 +44,10 @@ metadata:
provisioner: pure-csi # This must match the name of the CSIDriver. And the name of the CSI plugin from the RPC 'GetPluginInfo'
parameters:
backend: file
# PSO requires K8s 1.16+ for CSI VolumeExpansion
{{ if and (eq .Capabilities.KubeVersion.Major "1") (gt .Capabilities.KubeVersion.Minor "15") }}
allowVolumeExpansion: true
{{ end }}
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
Expand All @@ -53,6 +61,10 @@ parameters:
backend: block
csi.storage.k8s.io/fstype: xfs
createoptions: -q
# PSO requires K8s 1.16+ for CSI VolumeExpansion
{{ if and (eq .Capabilities.KubeVersion.Major "1") (gt .Capabilities.KubeVersion.Minor "15") }}
allowVolumeExpansion: true
{{ end }}
# support either string or list for .Values.flasharray.defaultMountOpt
{{- if or (kindIs "array" .Values.flasharray.defaultMountOpt) (kindIs "slice" .Values.flasharray.defaultMountOpt) }}
mountOptions:
Expand Down
4 changes: 4 additions & 0 deletions pure-csi/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ csi:
image:
name: quay.io/k8scsi/csi-snapshotter
pullPolicy: Always
resizer:
image:
name: quay.io/k8scsi/csi-resizer
pullPolicy: Always
clusterDriverRegistrar:
image:
name: quay.io/k8scsi/csi-cluster-driver-registrar
Expand Down

0 comments on commit 46dbbbc

Please sign in to comment.