Skip to content

Commit 207bf5e

Browse files
authored
Merge pull request #1312 from leonardoce/dev-v1beta2
Introduce v1beta2 VolumeGroupSnapshot API
2 parents 6b2feaa + 3dd71b2 commit 207bf5e

File tree

206 files changed

+43942
-374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+43942
-374
lines changed

.github/workflows/trivy.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
make
2424
docker build -t test/csi-snapshotter:latest -f ./cmd/csi-snapshotter/Dockerfile --output=type=docker --label revision=latest .
2525
docker build -t test/snapshot-controller:latest -f ./cmd/snapshot-controller/Dockerfile --output=type=docker --label revision=latest .
26+
docker build -t test/snapshot-conversion-webhook:latest -f ./cmd/snapshot-conversion-webhook/Dockerfile --output=type=docker --label revision=latest .
2627
2728
- name: Run Trivy vulnerability scanner on csi-snapshotter image
2829
uses: aquasecurity/trivy-action@master
@@ -47,3 +48,15 @@ jobs:
4748
ignore-unfixed: true
4849
vuln-type: 'os,library'
4950
severity: 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN'
51+
52+
- name: Run Trivy vulnerability scanner on snapshot-conversion-webhook image
53+
uses: aquasecurity/trivy-action@master
54+
env:
55+
TRIVY_DB_REPOSITORY: "public.ecr.aws/aquasecurity/trivy-db:2"
56+
with:
57+
image-ref: 'test/snapshot-conversion-webhook:latest'
58+
format: 'table'
59+
exit-code: '1'
60+
ignore-unfixed: true
61+
vuln-type: 'os,library'
62+
severity: 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN'

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
.PHONY: all snapshot-controller csi-snapshotter clean test
15+
.PHONY: all snapshot-controller csi-snapshotter snapshot-conversion-webhook clean test
1616

17-
CMDS=snapshot-controller csi-snapshotter
17+
CMDS=snapshot-controller csi-snapshotter snapshot-conversion-webhook
1818
all: build
1919
include release-tools/build.make
2020

README.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ The volume snapshot feature supports CSI v1.0 and higher. It was introduced as a
66

77
The volume group snapshot feature supports CSI v1.10.0 and higher, and have been introduced in [Kubernetes 1.27 as an alpha feature](https://kubernetes.io/blog/2023/05/08/kubernetes-1-27-volume-group-snapshot-alpha/).
88

9-
> :warning: **WARNING**: The validation webhook was deprecated in v8.0.0 and it is now removed. The validation webhook would prevent creating multiple default volume snapshot classes and multiple default volume group snapshot classes for the same CSI driver. With the removal of the validation webhook, an error will still be raised when dynamically provisioning a VolumeSnapshot or VolumeGroupSnapshot when multiple default volume snapshot classes or multiple default volume group snapshot classes for the same CSI driver exist.
10-
119
## Overview
1210

1311
With the promotion of Volume Snapshot to GA, the feature is enabled by default on standard Kubernetes deployments and cannot be turned off.
@@ -22,15 +20,15 @@ Blog post for the Volume Group Snapshot Alpha feature can be found [here](https:
2220

2321
This information reflects the head of this branch.
2422

25-
| Minimum CSI Version | Recommended CSI Version | Container Image | [Min K8s Version](https://kubernetes-csi.github.io/docs/kubernetes-compatibility.html#minimum-version) | [Recommended K8s Version](https://kubernetes-csi.github.io/docs/project-policies.html#recommended-version) |
26-
| ------------------------------------------------------------------------------------------ | ----------------------------| --------------- | --------------- | --------------- |
27-
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.5.0](https://github.com/container-storage-interface/spec/releases/tag/v1.5.0) | k8s.gcr.io/sig-storage/csi-snapshotter | 1.20 | 1.20 |
28-
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.5.0](https://github.com/container-storage-interface/spec/releases/tag/v1.5.0) | k8s.gcr.io/sig-storage/snapshot-controller | 1.20 | 1.20 |
29-
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.5.0](https://github.com/container-storage-interface/spec/releases/tag/v1.5.0) | k8s.gcr.io/sig-storage/snapshot-validation-webhook | 1.20 | 1.20 |
23+
| Minimum CSI Version | Recommended CSI Version | Container Image | [Min K8s Version](https://kubernetes-csi.github.io/docs/kubernetes-compatibility.html#minimum-version) | [Recommended K8s Version](https://kubernetes-csi.github.io/docs/project-policies.html#recommended-version) |
24+
| ------------------------------------------------------------------------------------------ | ----------------------------|----------------------------------------------------| --------------- | --------------- |
25+
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.5.0](https://github.com/container-storage-interface/spec/releases/tag/v1.5.0) | k8s.gcr.io/sig-storage/csi-snapshotter | 1.20 | 1.20 |
26+
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.5.0](https://github.com/container-storage-interface/spec/releases/tag/v1.5.0) | k8s.gcr.io/sig-storage/snapshot-controller | 1.20 | 1.20 |
27+
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.5.0](https://github.com/container-storage-interface/spec/releases/tag/v1.5.0) | k8s.gcr.io/sig-storage/snapshot-conversion-webhook | 1.20 | 1.20 |
3028

31-
Note: snapshot-controller, csi-snapshotter v4.1 requires v1 snapshot CRDs to be installed, but it serves both v1 and v1beta1 snapshot objects. Storage version is changed from v1beta1 to v1 in 4.1.0 so v1beta1 is deprecated and will be removed in a future release.
29+
Note: snapshot-controller, snapshot-conversion-webhook, csi-snapshotter v4.1 requires v1 snapshot CRDs to be installed, but it serves both v1 and v1beta1 snapshot objects. Storage version is changed from v1beta1 to v1 in 4.1.0 so v1beta1 is deprecated and will be removed in a future release.
3230

33-
Note: when the volume group snapshot feature is enabled, snapshot-controller, csi-snapshotter require the v1alpha1 volumegroupsnapshot CRDs to be installed.
31+
Note: when the volume group snapshot feature is enabled, snapshot-controller, snapshot-conversion-webhook, csi-snapshotter require the v1beta2 volumegroupsnapshot CRDs to be installed.
3432

3533
## Feature Status
3634

@@ -48,16 +46,17 @@ The CSI external-snapshotter sidecar talks to CSI over socket (/run/csi/socket b
4846

4947
In the current release, both v1 and v1beta1 APIs are served while the stored API version is changed from v1beta1 to v1. v1beta1 APIs is deprecated and will be removed in a future release. It is recommended for users to switch to v1 APIs as soon as possible. Any previously created invalid v1beta1 objects have to be deleted before upgrading to version 4.1.
5048

51-
### Volume Group Snapshot v1alpha1 APIs
49+
### Volume Group Snapshot v1beta2 APIs
5250

53-
When enabled, the VolumeGroupSnapshot v1alpha1 APIs are being served.
51+
When enabled, the VolumeGroupSnapshot v1beta2 APIs are being served.
5452

5553
## Usage
5654

5755
Volume Snapshot feature contains the following components:
5856

5957
* [Kubernetes Volume Snapshot and Volume Group Snapshot CRDs](https://github.com/kubernetes-csi/external-snapshotter/tree/master/client/config/crd)
6058
* [Volume snapshot and volume group snapshot controller](https://github.com/kubernetes-csi/external-snapshotter/tree/master/pkg/common-controller)
59+
* [Volume group snapshot conversion webhook](https://github.com/kubernetes-csi/external-snapshotter/tree/master/pkg/webhook)
6160
* CSI Driver along with [CSI Snapshotter sidecar](https://github.com/kubernetes-csi/external-snapshotter/tree/master/pkg/sidecar-controller)
6261

6362
The Volume Snapshot feature depends on a volume snapshot controller and the volume snapshot CRDs. Both the controller and the CRDs are independent of any CSI driver. The CSI Snapshotter sidecar must run once per CSI driver. The single snapshot controller deployment works for all CSI drivers in a cluster. With leader election configured, the CSI sidecars and snapshot controller elect one leader per deployment. If deployed with two or more pods and leader election is enabled, the non-leader containers will attempt to get the lease. If the leader container dies, a non-leader will take over.
@@ -66,6 +65,8 @@ Therefore, it is strongly recommended that Kubernetes distributors bundle and de
6665

6766
If your Kubernetes distribution does not bundle the snapshot controller, you may manually install these components by executing the following steps. Note that the snapshot controller YAML files in the git repository deploy into the default namespace for system testing purposes. For general use, update the snapshot controller YAMLs with an appropriate namespace prior to installing. For example, on a Vanilla Kubernetes cluster update the namespace from 'default' to 'kube-system' prior to issuing the kubectl create command.
6867

68+
There is a new conversion webhook server which provides conversion between v1beta1 and v1beta2 group snapshot objects. The cluster admin or Kubernetes distribution admin should install the webhook alongside the snapshot controllers and CRDs if they want to provide group snapshot v1beta1 API. More details [below](#conversion-webhook).).
69+
6970
Install Snapshot and Volume Group Snapshot CRDs:
7071
* With the repo cloned locally: `kubectl kustomize client/config/crd | kubectl create -f -`
7172
* From the repo remotely: `kubectl kustomize https://github.com/kubernetes-csi/external-snapshotter/client/config/crd | kubectl create -f -`
@@ -82,23 +83,22 @@ Install CSI Driver:
8283
* With the repo cloned locally: `kubectl kustomize deploy/kubernetes/csi-snapshotter | kubectl create -f -`
8384
* From the repo remotely: `kubectl kustomize https://github.com/kubernetes-csi/external-snapshotter/deploy/kubernetes/csi-snapshotter | kubectl create -f -`
8485

85-
##### Volume Snapshot
86+
### Conversion Webhook
87+
8688

87-
* Spec.VolumeSnapshotClassName must not be an empty string or nil on creation
88-
* Spec.Source.PersistentVolumeClaimName must not be changed on update requests
89-
* Spec.Source.VolumeSnapshotContentName must not be changed on update requests
89+
The snapshot conversion webhook is an HTTP callback which responds to
90+
[conversion requests](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#webhook-conversion),
91+
allowing the API server to convert between the VolumeGroupSnapshotContent v1beta1 API to and from the v1beta2 API.
9092

91-
##### Volume Snapshot Content
93+
Read more about how to install the example webhook [here](deploy/kubernetes/webhook-example/README.md).
9294

93-
* Spec.VolumeSnapshotRef.Name must not be an empty string on creation
94-
* Spec.VolumeSnapshotRef.Namespace must not be an empty string on creation
95-
* Spec.Source.VolumeHandle must not be changed on update requests
96-
* Spec.Source.SnapshotHandle must not be changed on update requests
97-
* Spec.SourceVolumeMode must not be changes on update requests
95+
#### Conversion Webhook Command Line Options
9896

99-
##### Volume Snapshot Classes
97+
* `--tls-cert-file`: File containing the x509 Certificate for HTTPS. (CA cert, if any, concatenated after server cert). Required.
10098

101-
* There can only be a single default volume snapshot class for a particular driver.
99+
* `--tls-private-key-file`: File containing the x509 private key matching --tls-cert-file. Required.
100+
101+
* `--port`: Secure port that the webhook listens on (default 443)
102102

103103
### Distributed Snapshotting
104104

@@ -242,6 +242,8 @@ If you have already deployed v1alpha1 snapshot APIs and external-snapshotter sid
242242

243243
### Upgrade from v1beta1 to v1
244244

245+
Validation webhook should be installed before upgrading to v1. Potential impacts of not installing the validation webhook before upgrading to v1 include being unable to delete invalid snapshot objects. See the section on Validation Webhook for details.
246+
245247
* When upgrading to 4.0, change from v1beta1 to v1 is backward compatible because both v1 and v1beta1 are served while the stored API version is still v1beta1. Future releases will switch the stored version to v1 and gradually remove v1beta1 support.
246248
* When upgrading from 3.x to 4.1, change from v1beta1 to v1 is no longer backward compatible because stored API version is changed to v1 although both v1 and v1beta1 are still served. v1beta1 is deprecated in 4.1.
247249
* v1beta1 support will be removed in a future release. It is recommended for users to switch to v1 as soon as possible. Any previously created invalid v1beta1 objects have to be deleted before upgrading to version 4.1.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// +k8s:deepcopy-gen=package
18+
// +groupName=groupsnapshot.storage.k8s.io
19+
20+
package v1beta2
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package v1beta2
15+
16+
import (
17+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
18+
"k8s.io/apimachinery/pkg/runtime"
19+
"k8s.io/apimachinery/pkg/runtime/schema"
20+
)
21+
22+
// GroupName is the group name use in this package.
23+
const GroupName = "groupsnapshot.storage.k8s.io"
24+
25+
var (
26+
// SchemeBuilder is the new scheme builder
27+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
28+
// AddToScheme adds to scheme
29+
AddToScheme = SchemeBuilder.AddToScheme
30+
// SchemeGroupVersion is the group version used to register these objects.
31+
SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta2"}
32+
)
33+
34+
func Resource(resource string) schema.GroupResource {
35+
return SchemeGroupVersion.WithResource(resource).GroupResource()
36+
}
37+
38+
func init() {
39+
// We only register manually written functions here. The registration of the
40+
// generated functions takes place in the generated files. The separation
41+
// makes the code compile even when the generated files are missing.
42+
SchemeBuilder.Register(addKnownTypes)
43+
}
44+
45+
// addKnownTypes adds the set of types defined in this package to the supplied scheme.
46+
func addKnownTypes(scheme *runtime.Scheme) error {
47+
scheme.AddKnownTypes(SchemeGroupVersion,
48+
&VolumeGroupSnapshotClass{},
49+
&VolumeGroupSnapshotClassList{},
50+
&VolumeGroupSnapshot{},
51+
&VolumeGroupSnapshotList{},
52+
&VolumeGroupSnapshotContent{},
53+
&VolumeGroupSnapshotContentList{},
54+
)
55+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
56+
return nil
57+
}

0 commit comments

Comments
 (0)