Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CSI] OFFLINE volume expansion support #338

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

[[constraint]]
name = "github.com/container-storage-interface/spec"
version = "1.0.0"
version = "1.2.0"

[[override]]
name = "github.com/golang/protobuf"
Expand Down
Empty file modified Makefile
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion csi/cmd/block/Dockerfile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COPY nvme-cli-1.8.1 /nvme-cli-1.8.1

# Install iscsi
RUN apt-get update && \
apt-get -y install open-iscsi \
apt-get -y install open-iscsi lsscsi\
sysfsutils \
kmod \
ceph-common \
Expand Down
7 changes: 7 additions & 0 deletions csi/common/controller.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ func ControllerGetCapabilities(
},
},
},
{
Type: &csi.ControllerServiceCapability_Rpc{
Rpc: &csi.ControllerServiceCapability_RPC{
Type: csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
},
},
},
},
}, nil
}
Expand Down
7 changes: 7 additions & 0 deletions csi/common/identity.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ func GetPluginCapabilities(
},
},
},
{
Type: &csi.PluginCapability_VolumeExpansion_{
VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
Type: csi.PluginCapability_VolumeExpansion_OFFLINE,
},
},
},
},
}, nil
}
7 changes: 7 additions & 0 deletions csi/common/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ func NodeGetCapabilities(
},
},
},
{
Type: &csi.NodeServiceCapability_Rpc{
Rpc: &csi.NodeServiceCapability_RPC{
Type: csi.NodeServiceCapability_RPC_EXPAND_VOLUME,
},
},
},
},
}, nil
}
Expand Down
124 changes: 124 additions & 0 deletions csi/deploy/kubernetes/block/csi-resizer-opensdsplugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# This YAML file contains attacher & csi driver API objects,
# which are necessary to run external csi resizer for opensds.

kind: Service
apiVersion: v1
metadata:
name: csi-resizer-opensdsplugin-block
labels:
app: csi-resizer-opensdsplugin-block
spec:
selector:
app: csi-resizer-opensdsplugin-block
ports:
- name: dummy
port: 12345

---
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: csi-resizer-opensdsplugin-block
spec:
serviceName: "csi-resizer-opensdsplugin-block"
replicas: 1
selector:
matchLabels:
app: csi-resizer-opensdsplugin-block
template:
metadata:
labels:
app: csi-resizer-opensdsplugin-block
spec:
serviceAccount: csi-resizer-block
containers:
- name: csi-resizer
image: quay.io/k8scsi/csi-resizer:v0.3.0
args:
- "--csi-address=$(ADDRESS)"
- "--csiTimeout=15s"
env:
- name: ADDRESS
value: /csi/csi.sock
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: socket-dir
mountPath: /csi
- name: opensds
image: opensdsio/csiplugin-block:latest
args :
- "--csiEndpoint=$(CSI_ENDPOINT)"
- "--opensdsEndpoint=$(OPENSDS_ENDPOINT)"
- "--opensdsAuthStrategy=$(OPENSDS_AUTH_STRATEGY)"
- "--v=8"
env:
- name: CSI_ENDPOINT
value: unix://csi/csi.sock
- name: OPENSDS_ENDPOINT
valueFrom:
configMapKeyRef:
name: csi-configmap-opensdsplugin-block
key: opensdsendpoint
- name: OPENSDS_AUTH_STRATEGY
valueFrom:
configMapKeyRef:
name: csi-configmap-opensdsplugin-block
key: opensdsauthstrategy
- name: OS_AUTH_URL
valueFrom:
configMapKeyRef:
name: csi-configmap-opensdsplugin-block
key: osauthurl
- name: OS_USERNAME
valueFrom:
configMapKeyRef:
name: csi-configmap-opensdsplugin-block
key: osusername
- name: PASSWORD_ENCRYPTER
valueFrom:
configMapKeyRef:
name: csi-configmap-opensdsplugin-block
key: passwordencrypter
- name: OS_PASSWORD
valueFrom:
configMapKeyRef:
name: csi-configmap-opensdsplugin-block
key: ospassword
- name: PASSWORD_ENCRYPTER
valueFrom:
configMapKeyRef:
name: csi-configmap-opensdsplugin-block
key: passwordencrypter
- name: ENABLE_ENCRYPTED
valueFrom:
configMapKeyRef:
name: csi-configmap-opensdsplugin-block
key: enableEncrypted
- name: OS_TENANT_NAME
valueFrom:
configMapKeyRef:
name: csi-configmap-opensdsplugin-block
key: ostenantname
- name: OS_PROJECT_NAME
valueFrom:
configMapKeyRef:
name: csi-configmap-opensdsplugin-block
key: osprojectname
- name: OS_USER_DOMAIN_ID
valueFrom:
configMapKeyRef:
name: csi-configmap-opensdsplugin-block
key: osuserdomainid
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: socket-dir
mountPath: /csi
- name: certificate-path
mountPath: /opt/opensds-security
volumes:
- name: socket-dir
emptyDir:
- name: certificate-path
hostPath:
path: /opt/opensds-security
type: DirectoryOrCreate
60 changes: 60 additions & 0 deletions csi/deploy/kubernetes/block/csi-resizer-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This YAML file contains RBAC API objects,
# which are necessary to run external csi resizer for opensds.

apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-resizer-block

---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: external-resizer-runner-block
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete", "patch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: [""]
resources: ["persistentvolumeclaims/status"]
verbs: ["update", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses", "csinodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["get", "create", "update"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["create","get", "list", "watch","update", "delete"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots/status"]
verbs: ["update"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["create","get", "list", "watch","update", "delete"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-resizer-role-block
subjects:
- kind: ServiceAccount
name: csi-resizer-block
namespace: default
roleRef:
kind: ClusterRole
name: external-resizer-runner-block
apiGroup: rbac.authorization.k8s.io
3 changes: 2 additions & 1 deletion csi/examples/kubernetes/block/nginx.yaml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ provisioner: csi-opensdsplugin-block
parameters:
attachMode: rw
profile: abc
allowVolumeExpansion: true
allowedTopologies:
- matchLabelExpressions:
- key: topology.csi-opensdsplugin-block/zone
Expand All @@ -21,7 +22,7 @@ metadata:
name: csi-pvc-opensdsplugin-block
spec:
accessModes:
- ReadWriteMany
- ReadWriteOnce
resources:
requests:
storage: 1Gi
Expand Down
12 changes: 12 additions & 0 deletions csi/plugins/block/controller.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ func (p *Plugin) ControllerUnpublishVolume(
return p.VolumeClient.ControllerUnpublishVolume(req)
}

// ControllerExpandVolume implementation
func (p *Plugin) ControllerExpandVolume(
ctx context.Context,
req *csi.ControllerExpandVolumeRequest) (
*csi.ControllerExpandVolumeResponse, error) {

glog.V(5).Infof("start to controller expand volume")
defer glog.V(5).Info("end to controller expand volume")

return p.VolumeClient.ExpandVolume(req)
}

// ValidateVolumeCapabilities implementation
func (p *Plugin) ValidateVolumeCapabilities(
ctx context.Context,
Expand Down
7 changes: 7 additions & 0 deletions csi/plugins/block/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ func TestControllerGetCapabilities(t *testing.T) {
},
},
},
&csi.ControllerServiceCapability{
Type: &csi.ControllerServiceCapability_Rpc{
Rpc: &csi.ControllerServiceCapability_RPC{
Type: csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
},
},
},
}

rs, err := fakePlugin.ControllerGetCapabilities(fakeCtx, fakeReq)
Expand Down
Loading