Skip to content

Commit 60ea552

Browse files
committed
feat: add snapshot-controller
Signed-off-by: Tadas Sutkaitis <[email protected]> Signed-off-by: Tadas Sutkaitis <[email protected]>
1 parent de2e3e3 commit 60ea552

18 files changed

+2803
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ inventory = "0.3.19"
2424
json-patch = "4.0.0"
2525
k8s-openapi = { version = "0.24.0", features = ["schemars", "latest"] }
2626
kube = { version = "0.99.0", features = ["runtime", "derive"] }
27+
lazy_static = "1.4.0"
2728
log = "0.4.27"
2829
maplit = "1.0.2"
2930
pyo3-async-runtimes = { version = "0.25.0", features = ["tokio-runtime"] }

magnum_cluster_api/cmd/image_loader.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ def _get_cloud_provider_images(config: Optional[Dict] = None) -> List[str]:
375375
"registry.k8s.io/provider-os/cinder-csi-plugin:v1.31.1",
376376
"registry.k8s.io/provider-os/manila-csi-plugin:v1.31.1",
377377
"registry.k8s.io/provider-os/openstack-cloud-controller-manager:v1.31.1",
378+
# v1.32.0
379+
"registry.k8s.io/provider-os/k8s-keystone-auth:v1.32.0",
380+
"registry.k8s.io/provider-os/cinder-csi-plugin:v1.32.0",
381+
"registry.k8s.io/provider-os/manila-csi-plugin:v1.32.0",
382+
"registry.k8s.io/provider-os/openstack-cloud-controller-manager:v1.32.0",
378383
]
379384

380385

@@ -388,24 +393,33 @@ def _get_infra_images(config: Optional[Dict] = None) -> List[str]:
388393
return [
389394
"registry.k8s.io/sig-storage/csi-attacher:v3.4.0",
390395
"registry.k8s.io/sig-storage/csi-attacher:v4.2.0",
396+
"registry.k8s.io/sig-storage/csi-attacher:v4.7.0",
391397
"registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.4.0",
392398
"registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.5.1",
393399
"registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.6.2",
394400
"registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.6.3",
395401
"registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.9.0",
402+
"registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.12.0",
396403
"registry.k8s.io/sig-storage/csi-provisioner:v3.0.0",
397404
"registry.k8s.io/sig-storage/csi-provisioner:v3.1.0",
398405
"registry.k8s.io/sig-storage/csi-provisioner:v3.3.0",
399406
"registry.k8s.io/sig-storage/csi-provisioner:v3.4.1",
407+
"registry.k8s.io/sig-storage/csi-provisioner:v5.1.0",
400408
"registry.k8s.io/sig-storage/csi-resizer:v1.4.0",
401409
"registry.k8s.io/sig-storage/csi-resizer:v1.8.0",
410+
"registry.k8s.io/sig-storage/csi-resizer:v1.12.0",
402411
"registry.k8s.io/sig-storage/csi-snapshotter:v5.0.1",
403412
"registry.k8s.io/sig-storage/csi-snapshotter:v6.0.1",
404413
"registry.k8s.io/sig-storage/csi-snapshotter:v6.2.1",
414+
"registry.k8s.io/sig-storage/csi-snapshotter:v8.1.0",
415+
"registry.k8s.io/sig-storage/csi-snapshotter:v8.2.1",
405416
"registry.k8s.io/sig-storage/livenessprobe:v2.7.0",
406417
"registry.k8s.io/sig-storage/livenessprobe:v2.8.0",
407418
"registry.k8s.io/sig-storage/livenessprobe:v2.9.0",
419+
"registry.k8s.io/sig-storage/livenessprobe:v2.14.0",
408420
"registry.k8s.io/sig-storage/nfsplugin:v4.2.0",
421+
"registry.k8s.io/sig-storage/snapshot-controller:v7.0.2",
422+
"registry.k8s.io/sig-storage/snapshot-controller:v8.2.1",
409423
]
410424

411425

magnum_cluster_api/image_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def get_image(name: str, repository: str = None):
6363
new_image_name = name.replace("gcr.io/k8s-staging-sig-storage", repository)
6464
if new_image_name.startswith(f"{repository}/livenessprobe"):
6565
return new_image_name.replace("livenessprobe", "csi-livenessprobe")
66+
if new_image_name.startswith(f"{repository}/snapshot-controller"):
67+
return new_image_name.replace("snapshot-controller", "csi-snapshot-controller")
6668
if new_image_name.startswith("registry.k8s.io/coredns"):
6769
return new_image_name.replace("registry.k8s.io/coredns", repository)
6870
if new_image_name.startswith("registry.k8s.io/autoscaling"):
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# RBAC file for the snapshot controller.
2+
#
3+
# The snapshot controller implements the control loop for CSI snapshot functionality.
4+
# It should be installed as part of the base Kubernetes distribution in an appropriate
5+
# namespace for components implementing base system functionality. For installing with
6+
# Vanilla Kubernetes, kube-system makes sense for the namespace.
7+
8+
---
9+
apiVersion: v1
10+
kind: ServiceAccount
11+
metadata:
12+
name: snapshot-controller
13+
namespace: kube-system
14+
15+
---
16+
kind: ClusterRole
17+
apiVersion: rbac.authorization.k8s.io/v1
18+
metadata:
19+
name: snapshot-controller-runner
20+
rules:
21+
- apiGroups: [""]
22+
resources: ["persistentvolumes"]
23+
verbs: ["get", "list", "watch"]
24+
- apiGroups: [""]
25+
resources: ["persistentvolumeclaims"]
26+
verbs: ["get", "list", "watch", "update"]
27+
- apiGroups: [""]
28+
resources: ["events"]
29+
verbs: ["list", "watch", "create", "update", "patch"]
30+
- apiGroups: ["snapshot.storage.k8s.io"]
31+
resources: ["volumesnapshotclasses"]
32+
verbs: ["get", "list", "watch"]
33+
- apiGroups: ["snapshot.storage.k8s.io"]
34+
resources: ["volumesnapshotcontents"]
35+
verbs: ["create", "get", "list", "watch", "update", "delete", "patch"]
36+
- apiGroups: ["snapshot.storage.k8s.io"]
37+
resources: ["volumesnapshotcontents/status"]
38+
verbs: ["patch"]
39+
- apiGroups: ["snapshot.storage.k8s.io"]
40+
resources: ["volumesnapshots"]
41+
verbs: ["get", "list", "watch", "update", "patch", "delete"]
42+
- apiGroups: ["snapshot.storage.k8s.io"]
43+
resources: ["volumesnapshots/status"]
44+
verbs: ["update", "patch"]
45+
46+
- apiGroups: ["groupsnapshot.storage.k8s.io"]
47+
resources: ["volumegroupsnapshotclasses"]
48+
verbs: ["get", "list", "watch"]
49+
- apiGroups: ["groupsnapshot.storage.k8s.io"]
50+
resources: ["volumegroupsnapshotcontents"]
51+
verbs: ["create", "get", "list", "watch", "update", "delete", "patch"]
52+
- apiGroups: ["groupsnapshot.storage.k8s.io"]
53+
resources: ["volumegroupsnapshotcontents/status"]
54+
verbs: ["patch"]
55+
- apiGroups: ["groupsnapshot.storage.k8s.io"]
56+
resources: ["volumegroupsnapshots"]
57+
verbs: ["get", "list", "watch", "update", "patch"]
58+
- apiGroups: ["groupsnapshot.storage.k8s.io"]
59+
resources: ["volumegroupsnapshots/status"]
60+
verbs: ["update", "patch"]
61+
62+
# Enable this RBAC rule only when using distributed snapshotting, i.e. when the enable-distributed-snapshotting flag is set to true
63+
# - apiGroups: [""]
64+
# resources: ["nodes"]
65+
# verbs: ["get", "list", "watch"]
66+
---
67+
kind: ClusterRoleBinding
68+
apiVersion: rbac.authorization.k8s.io/v1
69+
metadata:
70+
name: snapshot-controller-role
71+
subjects:
72+
- kind: ServiceAccount
73+
name: snapshot-controller
74+
namespace: kube-system
75+
roleRef:
76+
kind: ClusterRole
77+
name: snapshot-controller-runner
78+
apiGroup: rbac.authorization.k8s.io
79+
80+
---
81+
kind: Role
82+
apiVersion: rbac.authorization.k8s.io/v1
83+
metadata:
84+
name: snapshot-controller-leaderelection
85+
namespace: kube-system
86+
rules:
87+
- apiGroups: ["coordination.k8s.io"]
88+
resources: ["leases"]
89+
verbs: ["get", "watch", "list", "delete", "update", "create"]
90+
91+
---
92+
kind: RoleBinding
93+
apiVersion: rbac.authorization.k8s.io/v1
94+
metadata:
95+
name: snapshot-controller-leaderelection
96+
namespace: kube-system
97+
subjects:
98+
- kind: ServiceAccount
99+
name: snapshot-controller
100+
roleRef:
101+
kind: Role
102+
name: snapshot-controller-leaderelection
103+
apiGroup: rbac.authorization.k8s.io
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/814"
7+
controller-gen.kubebuilder.io/version: v0.12.0
8+
creationTimestamp: null
9+
name: volumesnapshotclasses.snapshot.storage.k8s.io
10+
spec:
11+
group: snapshot.storage.k8s.io
12+
names:
13+
kind: VolumeSnapshotClass
14+
listKind: VolumeSnapshotClassList
15+
plural: volumesnapshotclasses
16+
shortNames:
17+
- vsclass
18+
- vsclasses
19+
singular: volumesnapshotclass
20+
scope: Cluster
21+
versions:
22+
- additionalPrinterColumns:
23+
- jsonPath: .driver
24+
name: Driver
25+
type: string
26+
- description: Determines whether a VolumeSnapshotContent created through the
27+
VolumeSnapshotClass should be deleted when its bound VolumeSnapshot is deleted.
28+
jsonPath: .deletionPolicy
29+
name: DeletionPolicy
30+
type: string
31+
- jsonPath: .metadata.creationTimestamp
32+
name: Age
33+
type: date
34+
name: v1
35+
schema:
36+
openAPIV3Schema:
37+
description: VolumeSnapshotClass specifies parameters that a underlying storage
38+
system uses when creating a volume snapshot. A specific VolumeSnapshotClass
39+
is used by specifying its name in a VolumeSnapshot object. VolumeSnapshotClasses
40+
are non-namespaced
41+
properties:
42+
apiVersion:
43+
description: 'APIVersion defines the versioned schema of this representation
44+
of an object. Servers should convert recognized schemas to the latest
45+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
46+
type: string
47+
deletionPolicy:
48+
description: deletionPolicy determines whether a VolumeSnapshotContent
49+
created through the VolumeSnapshotClass should be deleted when its bound
50+
VolumeSnapshot is deleted. Supported values are "Retain" and "Delete".
51+
"Retain" means that the VolumeSnapshotContent and its physical snapshot
52+
on underlying storage system are kept. "Delete" means that the VolumeSnapshotContent
53+
and its physical snapshot on underlying storage system are deleted.
54+
Required.
55+
enum:
56+
- Delete
57+
- Retain
58+
type: string
59+
driver:
60+
description: driver is the name of the storage driver that handles this
61+
VolumeSnapshotClass. Required.
62+
type: string
63+
kind:
64+
description: 'Kind is a string value representing the REST resource this
65+
object represents. Servers may infer this from the endpoint the client
66+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
67+
type: string
68+
metadata:
69+
type: object
70+
parameters:
71+
additionalProperties:
72+
type: string
73+
description: parameters is a key-value map with storage driver specific
74+
parameters for creating snapshots. These values are opaque to Kubernetes.
75+
type: object
76+
required:
77+
- deletionPolicy
78+
- driver
79+
type: object
80+
served: true
81+
storage: true
82+
subresources: {}
83+
- additionalPrinterColumns:
84+
- jsonPath: .driver
85+
name: Driver
86+
type: string
87+
- description: Determines whether a VolumeSnapshotContent created through the VolumeSnapshotClass should be deleted when its bound VolumeSnapshot is deleted.
88+
jsonPath: .deletionPolicy
89+
name: DeletionPolicy
90+
type: string
91+
- jsonPath: .metadata.creationTimestamp
92+
name: Age
93+
type: date
94+
name: v1beta1
95+
# This indicates the v1beta1 version of the custom resource is deprecated.
96+
# API requests to this version receive a warning in the server response.
97+
deprecated: true
98+
# This overrides the default warning returned to clients making v1beta1 API requests.
99+
deprecationWarning: "snapshot.storage.k8s.io/v1beta1 VolumeSnapshotClass is deprecated; use snapshot.storage.k8s.io/v1 VolumeSnapshotClass"
100+
schema:
101+
openAPIV3Schema:
102+
description: VolumeSnapshotClass specifies parameters that a underlying storage system uses when creating a volume snapshot. A specific VolumeSnapshotClass is used by specifying its name in a VolumeSnapshot object. VolumeSnapshotClasses are non-namespaced
103+
properties:
104+
apiVersion:
105+
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
106+
type: string
107+
deletionPolicy:
108+
description: deletionPolicy determines whether a VolumeSnapshotContent created through the VolumeSnapshotClass should be deleted when its bound VolumeSnapshot is deleted. Supported values are "Retain" and "Delete". "Retain" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are kept. "Delete" means that the VolumeSnapshotContent and its physical snapshot on underlying storage system are deleted. Required.
109+
enum:
110+
- Delete
111+
- Retain
112+
type: string
113+
driver:
114+
description: driver is the name of the storage driver that handles this VolumeSnapshotClass. Required.
115+
type: string
116+
kind:
117+
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
118+
type: string
119+
parameters:
120+
additionalProperties:
121+
type: string
122+
description: parameters is a key-value map with storage driver specific parameters for creating snapshots. These values are opaque to Kubernetes.
123+
type: object
124+
required:
125+
- deletionPolicy
126+
- driver
127+
type: object
128+
served: false
129+
storage: false
130+
subresources: {}
131+
status:
132+
acceptedNames:
133+
kind: ""
134+
plural: ""
135+
conditions: []
136+
storedVersions: []

0 commit comments

Comments
 (0)