Skip to content

Commit 3dfc5d4

Browse files
committed
csi: v1.0.0
CSI v1.0.0 is released (\o/): https://github.com/container-storage-interface/spec/releases/tag/v1.0.0. With that, there were many changes and updates so this PR combines all these changes. * Create a default `VolumeSnapshotClass` so people don't have to define them when they use DO for their snapshotting needs. * Add new `csi-snapshotter` sidecar that is responsible of calling the three CSI methods we implemented: `ListSnapshots`, `CreateSnapshot` and `DeleteSnapshot`. In addition to this, the `csi-snapshotter` sidecar is also responsible of creating the `VolumeSnapshotClasss` CRD * Updated sidecars to the newest and latest * Added back the ClusterRole's for each sidecar. Kubernetes no more carries them and it's up to the sidecars to provider them to the users.
1 parent fe1cf6e commit 3dfc5d4

File tree

7 files changed

+77
-118
lines changed

7 files changed

+77
-118
lines changed

deploy/kubernetes/releases/csi-digitalocean-dev.yaml

+22-58
Original file line numberDiff line numberDiff line change
@@ -66,53 +66,6 @@ status:
6666

6767
---
6868

69-
apiVersion: apiextensions.k8s.io/v1beta1
70-
kind: CustomResourceDefinition
71-
metadata:
72-
creationTimestamp: null
73-
name: csidrivers.csi.storage.k8s.io
74-
spec:
75-
group: csi.storage.k8s.io
76-
names:
77-
kind: CSIDriver
78-
plural: csidrivers
79-
scope: Cluster
80-
validation:
81-
openAPIV3Schema:
82-
properties:
83-
spec:
84-
description: Specification of the CSI Driver.
85-
properties:
86-
attachRequired:
87-
description: Indicates this CSI volume driver requires an attach operation,
88-
and that Kubernetes should call attach and wait for any attach operation
89-
to complete before proceeding to mount.
90-
type: boolean
91-
podInfoOnMountVersion:
92-
description: Indicates this CSI volume driver requires additional pod
93-
information (like podName, podUID, etc.) during mount operations.
94-
type: string
95-
version: v1alpha1
96-
status:
97-
acceptedNames:
98-
kind: ""
99-
plural: ""
100-
conditions: []
101-
storedVersions: []
102-
103-
---
104-
105-
# CSIDriverRegistry feature gate needs to be enabled
106-
apiVersion: csi.storage.k8s.io/v1alpha1
107-
kind: CSIDriver
108-
metadata:
109-
name: dobs.csi.digitalocean.com
110-
spec:
111-
attachRequired: true
112-
podInfoOnMountVersion: "v1"
113-
114-
---
115-
11669
##############################################
11770
########### ############
11871
########### Snapshot CRDs ############
@@ -190,7 +143,6 @@ provisioner: dobs.csi.digitalocean.com
190143

191144
---
192145

193-
194146
##############################################
195147
########### ############
196148
########### Controller plugin ############
@@ -215,7 +167,7 @@ spec:
215167
serviceAccount: csi-do-controller-sa
216168
containers:
217169
- name: csi-provisioner
218-
image: quay.io/k8scsi/csi-provisioner:v0.4.1
170+
image: quay.io/k8scsi/csi-provisioner:v1.0.1
219171
args:
220172
- "--provisioner=dobs.csi.digitalocean.com"
221173
- "--csi-address=$(ADDRESS)"
@@ -228,7 +180,7 @@ spec:
228180
- name: socket-dir
229181
mountPath: /var/lib/csi/sockets/pluginproxy/
230182
- name: csi-attacher
231-
image: quay.io/k8scsi/csi-attacher:v0.4.1
183+
image: quay.io/k8scsi/csi-attacher:v1.0.1
232184
args:
233185
- "--v=5"
234186
- "--csi-address=$(ADDRESS)"
@@ -240,7 +192,7 @@ spec:
240192
- name: socket-dir
241193
mountPath: /var/lib/csi/sockets/pluginproxy/
242194
- name: csi-snapshotter
243-
image: quay.io/k8scsi/csi-snapshotter:v0.4.1
195+
image: quay.io/k8scsi/csi-snapshotter:v1.0.1
244196
args:
245197
- "--connection-timeout=15s"
246198
- "--csi-address=$(ADDRESS)"
@@ -251,6 +203,18 @@ spec:
251203
volumeMounts:
252204
- name: socket-dir
253205
mountPath: /var/lib/csi/sockets/pluginproxy/
206+
- name: csi-cluster-driver-registrar
207+
image: quay.io/k8scsi/csi-cluster-driver-registrar:v1.0.1
208+
args:
209+
- "--v=5"
210+
- "--pod-info-mount-version=\"v1\""
211+
- "--csi-address=$(ADDRESS)"
212+
env:
213+
- name: ADDRESS
214+
value: /var/lib/csi/sockets/pluginproxy/csi.sock
215+
volumeMounts:
216+
- name: socket-dir
217+
mountPath: /var/lib/csi/sockets/pluginproxy/
254218
- name: csi-do-plugin
255219
image: digitalocean/do-csi-plugin:dev
256220
args :
@@ -436,15 +400,16 @@ spec:
436400
serviceAccount: csi-do-node-sa
437401
hostNetwork: true
438402
containers:
439-
- name: driver-registrar
440-
image: quay.io/k8scsi/driver-registrar:v0.4.1
403+
- name: csi-node-driver-registrar
404+
image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.1
441405
args:
442406
- "--v=5"
443407
- "--csi-address=$(ADDRESS)"
444-
- "--mode=node-register"
445-
- "--driver-requires-attachment=true"
446-
- "--pod-info-mount-version=\"v1\""
447408
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
409+
lifecycle:
410+
preStop:
411+
exec:
412+
command: ["/bin/sh", "-c", "rm -rf /registration/dobs.csi.digitalocean.com /registration/dobs.csi.digitalocean.com-reg.sock"]
448413
env:
449414
- name: ADDRESS
450415
value: /csi/csi.sock
@@ -494,7 +459,7 @@ spec:
494459
volumes:
495460
- name: registration-dir
496461
hostPath:
497-
path: /var/lib/kubelet/plugins/
462+
path: /var/lib/kubelet/plugins_registry/
498463
type: DirectoryOrCreate
499464
- name: plugin-dir
500465
hostPath:
@@ -541,4 +506,3 @@ roleRef:
541506
kind: ClusterRole
542507
name: csi-do-driver-registrar-role
543508
apiGroup: rbac.authorization.k8s.io
544-

driver/controller.go

+25-32
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ import (
2424
"strings"
2525
"time"
2626

27-
csi "github.com/container-storage-interface/spec/lib/go/csi/v0"
27+
"github.com/container-storage-interface/spec/lib/go/csi"
2828
"github.com/digitalocean/godo"
29+
"github.com/golang/protobuf/ptypes"
2930
"github.com/sirupsen/logrus"
3031
"google.golang.org/grpc/codes"
3132
"google.golang.org/grpc/status"
@@ -135,7 +136,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
135136
ll.Info("volume already created")
136137
return &csi.CreateVolumeResponse{
137138
Volume: &csi.Volume{
138-
Id: vol.ID,
139+
VolumeId: vol.ID,
139140
CapacityBytes: vol.SizeGigaBytes * GB,
140141
},
141142
}, nil
@@ -161,7 +162,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
161162

162163
resp := &csi.CreateVolumeResponse{
163164
Volume: &csi.Volume{
164-
Id: vol.ID,
165+
VolumeId: vol.ID,
165166
CapacityBytes: size,
166167
AccessibleTopology: []*csi.Topology{
167168
{
@@ -267,7 +268,7 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
267268
if id == dropletID {
268269
ll.Info("volume is already attached")
269270
return &csi.ControllerPublishVolumeResponse{
270-
PublishInfo: map[string]string{
271+
PublishContext: map[string]string{
271272
PublishInfoVolumeName: vol.Name,
272273
},
273274
}, nil
@@ -291,7 +292,7 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
291292
"resp": resp,
292293
}).Warn("assuming volume is attached already")
293294
return &csi.ControllerPublishVolumeResponse{
294-
PublishInfo: map[string]string{
295+
PublishContext: map[string]string{
295296
PublishInfoVolumeName: vol.Name,
296297
},
297298
}, nil
@@ -319,7 +320,7 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
319320

320321
ll.Info("volume is attached")
321322
return &csi.ControllerPublishVolumeResponse{
322-
PublishInfo: map[string]string{
323+
PublishContext: map[string]string{
323324
PublishInfoVolumeName: vol.Name,
324325
},
325326
}, nil
@@ -414,7 +415,6 @@ func (d *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.Valida
414415
ll := d.log.WithFields(logrus.Fields{
415416
"volume_id": req.VolumeId,
416417
"volume_capabilities": req.VolumeCapabilities,
417-
"accessible_topology": req.AccessibleTopology,
418418
"supported_capabilities": supportedAccessMode,
419419
"method": "validate_volume_capabilities",
420420
})
@@ -429,29 +429,18 @@ func (d *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.Valida
429429
return nil, err
430430
}
431431

432-
if req.AccessibleTopology != nil {
433-
for _, t := range req.AccessibleTopology {
434-
region, ok := t.Segments["region"]
435-
if !ok {
436-
continue // nothing to do
437-
}
438-
439-
if region != d.region {
440-
// return early if a different region is expected
441-
ll.WithField("supported", false).Info("supported capabilities")
442-
return &csi.ValidateVolumeCapabilitiesResponse{
443-
Supported: false,
444-
}, nil
445-
}
446-
}
447-
}
448-
449432
// if it's not supported (i.e: wrong region), we shouldn't override it
450433
resp := &csi.ValidateVolumeCapabilitiesResponse{
451-
Supported: validateCapabilities(req.VolumeCapabilities),
434+
Confirmed: &csi.ValidateVolumeCapabilitiesResponse_Confirmed{
435+
VolumeCapabilities: []*csi.VolumeCapability{
436+
{
437+
AccessMode: supportedAccessMode,
438+
},
439+
},
440+
},
452441
}
453442

454-
ll.WithField("supported", resp.Supported).Info("supported capabilities")
443+
ll.WithField("confirmed", resp.Confirmed).Info("supported capabilities")
455444
return resp, nil
456445
}
457446

@@ -515,7 +504,7 @@ func (d *Driver) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (
515504
for _, vol := range volumes {
516505
entries = append(entries, &csi.ListVolumesResponse_Entry{
517506
Volume: &csi.Volume{
518-
Id: vol.ID,
507+
VolumeId: vol.ID,
519508
CapacityBytes: vol.SizeGigaBytes * GB,
520509
},
521510
})
@@ -931,14 +920,18 @@ func toCSISnapshot(snap *godo.Snapshot) (*csi.Snapshot, error) {
931920
return nil, fmt.Errorf("couldn't parse snapshot's created field: %s", err.Error())
932921
}
933922

923+
tstamp, err := ptypes.TimestampProto(createdAt)
924+
if err != nil {
925+
return nil, fmt.Errorf("couldn't convert protobuf timestamp to go time.Time: %s",
926+
err.Error())
927+
}
928+
934929
return &csi.Snapshot{
935-
Id: snap.ID,
930+
SnapshotId: snap.ID,
936931
SourceVolumeId: snap.ResourceID,
937932
SizeBytes: int64(snap.SizeGigaBytes) * GB,
938-
CreatedAt: createdAt.UTC().UnixNano(),
939-
Status: &csi.SnapshotStatus{
940-
Type: csi.SnapshotStatus_READY,
941-
},
933+
CreationTime: tstamp,
934+
ReadyToUse: true,
942935
}, nil
943936
}
944937

driver/driver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"strconv"
2828
"sync"
2929

30-
csi "github.com/container-storage-interface/spec/lib/go/csi/v0"
30+
"github.com/container-storage-interface/spec/lib/go/csi"
3131
metadata "github.com/digitalocean/go-metadata"
3232
"github.com/digitalocean/godo"
3333
"github.com/sirupsen/logrus"

driver/identity.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package driver
1919
import (
2020
"context"
2121

22-
csi "github.com/container-storage-interface/spec/lib/go/csi/v0"
22+
"github.com/container-storage-interface/spec/lib/go/csi"
2323
"github.com/golang/protobuf/ptypes/wrappers"
2424
"github.com/sirupsen/logrus"
2525
)
@@ -52,7 +52,7 @@ func (d *Driver) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCa
5252
{
5353
Type: &csi.PluginCapability_Service_{
5454
Service: &csi.PluginCapability_Service{
55-
Type: csi.PluginCapability_Service_ACCESSIBILITY_CONSTRAINTS,
55+
Type: csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS,
5656
},
5757
},
5858
},

driver/node.go

+18-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)