@@ -322,6 +322,9 @@ configvar CSI_PROW_E2E_ALPHA_GATES_1_16 'VolumeSnapshotDataSource=true' "alpha f
322
322
configvar CSI_PROW_E2E_ALPHA_GATES_LATEST ' VolumeSnapshotDataSource=true' " alpha feature gates for latest Kubernetes"
323
323
configvar CSI_PROW_E2E_ALPHA_GATES " $( get_versioned_variable CSI_PROW_E2E_ALPHA_GATES " ${csi_prow_kubernetes_version_suffix} " ) " " alpha E2E feature gates"
324
324
325
+ # Which external-snapshotter tag to use for the snapshotter CRD and snapshot-controller deployment
326
+ configvar CSI_SNAPSHOTTER_VERSION ' v2.0.0-rc4' " external-snapshotter version tag"
327
+
325
328
# Some tests are known to be unusable in a KinD cluster. For example,
326
329
# stopping kubelet with "ssh <node IP> systemctl stop kubelet" simply
327
330
# doesn't work. Such tests should be written in a way that they verify
@@ -670,6 +673,59 @@ install_hostpath () {
670
673
fi
671
674
}
672
675
676
+ # Installs all nessesary snapshotter CRDs
677
+ install_snapshot_crds () {
678
+ # Wait until volumesnapshot CRDs are in place.
679
+ CRD_BASE_DIR=" https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /config/crd"
680
+ kubectl apply -f " ${CRD_BASE_DIR} /snapshot.storage.k8s.io_volumesnapshotclasses.yaml" --validate=false
681
+ kubectl apply -f " ${CRD_BASE_DIR} /snapshot.storage.k8s.io_volumesnapshots.yaml" --validate=false
682
+ kubectl apply -f " ${CRD_BASE_DIR} /snapshot.storage.k8s.io_volumesnapshotcontents.yaml" --validate=false
683
+ cnt=0
684
+ until kubectl get volumesnapshotclasses.snapshot.storage.k8s.io \
685
+ && kubectl get volumesnapshots.snapshot.storage.k8s.io \
686
+ && kubectl get volumesnapshotcontents.snapshot.storage.k8s.io; do
687
+ if [ $cnt -gt 30 ]; then
688
+ echo >&2 " ERROR: snapshot CRDs not ready after over 1 min"
689
+ exit 1
690
+ fi
691
+ echo " $( date +%H:%M:%S) " " waiting for snapshot CRDs, attempt #$cnt "
692
+ cnt=$(( cnt + 1 ))
693
+ sleep 2
694
+ done
695
+ }
696
+
697
+ # Install snapshot controller and associated RBAC, retrying until the pod is running.
698
+ install_snapshot_controller () {
699
+ kubectl apply -f " https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml"
700
+ cnt=0
701
+ until kubectl get clusterrolebinding snapshot-controller-role; do
702
+ if [ $cnt -gt 30 ]; then
703
+ echo " Cluster role bindings:"
704
+ kubectl describe clusterrolebinding
705
+ echo >&2 " ERROR: snapshot controller RBAC not ready after over 5 min"
706
+ exit 1
707
+ fi
708
+ echo " $( date +%H:%M:%S) " " waiting for snapshot RBAC setup complete, attempt #$cnt "
709
+ cnt=$(( cnt + 1 ))
710
+ sleep 10
711
+ done
712
+
713
+
714
+ kubectl apply -f " https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
715
+ cnt=0
716
+ until kubectl get statefulset snapshot-controller | grep snapshot-controller | grep " 1/1" ; do
717
+ if [ $cnt -gt 30 ]; then
718
+ echo " Running statefulsets:"
719
+ kubectl describe statefulsets
720
+ echo >&2 " ERROR: snapshot controller not ready after over 5 min"
721
+ exit 1
722
+ fi
723
+ echo " $( date +%H:%M:%S) " " waiting for snapshot controller deployment to complete, attempt #$cnt "
724
+ cnt=$(( cnt + 1 ))
725
+ sleep 10
726
+ done
727
+ }
728
+
673
729
# collect logs and cluster status (like the version of all components, Kubernetes version, test version)
674
730
collect_cluster_info () {
675
731
cat << EOF
@@ -940,6 +996,10 @@ make_test_to_junit () {
940
996
fi
941
997
}
942
998
999
+ function version_gt() {
1000
+ test " $( printf ' %s\n' " $@ " | sort -V | head -n 1) " ! = " $1 " ;
1001
+ }
1002
+
943
1003
main () {
944
1004
local images ret
945
1005
ret=0
@@ -1000,6 +1060,16 @@ main () {
1000
1060
if tests_need_non_alpha_cluster; then
1001
1061
start_cluster || die " starting the non-alpha cluster failed"
1002
1062
1063
+ # Install necessary snapshot CRDs and snapshot controller
1064
+ # For Kubernetes 1.17+, we will install the CRDs and snapshot controller.
1065
+ if version_gt " ${CSI_PROW_KUBERNETES_VERSION} " " 1.16.255" || " ${CSI_PROW_KUBERNETES_VERSION} " == " latest" ; then
1066
+ info " Version ${CSI_PROW_KUBERNETES_VERSION} , installing CRDs and snapshot controller"
1067
+ install_snapshot_crds
1068
+ install_snapshot_controller
1069
+ else
1070
+ info " Version ${CSI_PROW_KUBERNETES_VERSION} , skipping CRDs and snapshot controller"
1071
+ fi
1072
+
1003
1073
# Installing the driver might be disabled.
1004
1074
if install_hostpath " $images " ; then
1005
1075
collect_cluster_info
@@ -1037,6 +1107,16 @@ main () {
1037
1107
# Need to (re)create the cluster.
1038
1108
start_cluster " ${CSI_PROW_E2E_ALPHA_GATES} " || die " starting alpha cluster failed"
1039
1109
1110
+ # Install necessary snapshot CRDs and snapshot controller
1111
+ # For Kubernetes 1.17+, we will install the CRDs and snapshot controller.
1112
+ if version_gt " ${CSI_PROW_KUBERNETES_VERSION} " " 1.16.255" || " ${CSI_PROW_KUBERNETES_VERSION} " == " latest" ; then
1113
+ info " Version ${CSI_PROW_KUBERNETES_VERSION} , installing CRDs and snapshot controller"
1114
+ install_snapshot_crds
1115
+ install_snapshot_controller
1116
+ else
1117
+ info " Version ${CSI_PROW_KUBERNETES_VERSION} , skipping CRDs and snapshot controller"
1118
+ fi
1119
+
1040
1120
# Installing the driver might be disabled.
1041
1121
if install_hostpath " $images " ; then
1042
1122
collect_cluster_info
0 commit comments