@@ -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
@@ -657,6 +660,59 @@ install_hostpath () {
657
660
fi
658
661
}
659
662
663
+ # Installs all nessesary snapshotter CRDs
664
+ install_snapshot_crds () {
665
+ # Wait until volumesnapshot CRDs are in place.
666
+ CRD_BASE_DIR=" https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /config/crd"
667
+ kubectl apply -f " ${CRD_BASE_DIR} /snapshot.storage.k8s.io_volumesnapshotclasses.yaml" --validate=false
668
+ kubectl apply -f " ${CRD_BASE_DIR} /snapshot.storage.k8s.io_volumesnapshots.yaml" --validate=false
669
+ kubectl apply -f " ${CRD_BASE_DIR} /snapshot.storage.k8s.io_volumesnapshotcontents.yaml" --validate=false
670
+ cnt=0
671
+ until kubectl get volumesnapshotclasses.snapshot.storage.k8s.io \
672
+ && kubectl get volumesnapshots.snapshot.storage.k8s.io \
673
+ && kubectl get volumesnapshotcontents.snapshot.storage.k8s.io; do
674
+ if [ $cnt -gt 30 ]; then
675
+ echo >&2 " ERROR: snapshot CRDs not ready after over 1 min"
676
+ exit 1
677
+ fi
678
+ echo " $( date +%H:%M:%S) " " waiting for snapshot CRDs, attempt #$cnt "
679
+ cnt=$(( cnt + 1 ))
680
+ sleep 2
681
+ done
682
+ }
683
+
684
+ # Install snapshot controller and associated RBAC, retrying until the pod is running.
685
+ install_snapshot_controller () {
686
+ kubectl apply -f " https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml"
687
+ cnt=0
688
+ until kubectl get clusterrolebinding snapshot-controller-role; do
689
+ if [ $cnt -gt 30 ]; then
690
+ echo " Cluster role bindings:"
691
+ kubectl describe clusterrolebinding
692
+ echo >&2 " ERROR: snapshot controller RBAC not ready after over 5 min"
693
+ exit 1
694
+ fi
695
+ echo " $( date +%H:%M:%S) " " waiting for snapshot RBAC setup complete, attempt #$cnt "
696
+ cnt=$(( cnt + 1 ))
697
+ sleep 10
698
+ done
699
+
700
+
701
+ kubectl apply -f " https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
702
+ cnt=0
703
+ until kubectl get statefulset snapshot-controller | grep snapshot-controller | grep " 1/1" ; do
704
+ if [ $cnt -gt 30 ]; then
705
+ echo " Running statefulsets:"
706
+ kubectl describe statefulsets
707
+ echo >&2 " ERROR: snapshot controller not ready after over 5 min"
708
+ exit 1
709
+ fi
710
+ echo " $( date +%H:%M:%S) " " waiting for snapshot controller deployment to complete, attempt #$cnt "
711
+ cnt=$(( cnt + 1 ))
712
+ sleep 10
713
+ done
714
+ }
715
+
660
716
# collect logs and cluster status (like the version of all components, Kubernetes version, test version)
661
717
collect_cluster_info () {
662
718
cat << EOF
@@ -927,6 +983,10 @@ make_test_to_junit () {
927
983
fi
928
984
}
929
985
986
+ function version_gt() {
987
+ test " $( printf ' %s\n' " $@ " | sort -V | head -n 1) " ! = " $1 " ;
988
+ }
989
+
930
990
main () {
931
991
local images ret
932
992
ret=0
@@ -987,6 +1047,16 @@ main () {
987
1047
if tests_need_non_alpha_cluster; then
988
1048
start_cluster || die " starting the non-alpha cluster failed"
989
1049
1050
+ # Install necessary snapshot CRDs and snapshot controller
1051
+ # For Kubernetes 1.17+, we will install the CRDs and snapshot controller.
1052
+ if version_gt " ${CSI_PROW_KUBERNETES_VERSION} " " 1.16.255" || " ${CSI_PROW_KUBERNETES_VERSION} " == " latest" ; then
1053
+ info " Version ${CSI_PROW_KUBERNETES_VERSION} , installing CRDs and snapshot controller"
1054
+ install_snapshot_crds
1055
+ install_snapshot_controller
1056
+ else
1057
+ info " Version ${CSI_PROW_KUBERNETES_VERSION} , skipping CRDs and snapshot controller"
1058
+ fi
1059
+
990
1060
# Installing the driver might be disabled.
991
1061
if install_hostpath " $images " ; then
992
1062
collect_cluster_info
@@ -1023,6 +1093,16 @@ main () {
1023
1093
# Need to (re)create the cluster.
1024
1094
start_cluster " ${CSI_PROW_E2E_ALPHA_GATES} " || die " starting alpha cluster failed"
1025
1095
1096
+ # Install necessary snapshot CRDs and snapshot controller
1097
+ # For Kubernetes 1.17+, we will install the CRDs and snapshot controller.
1098
+ if version_gt " ${CSI_PROW_KUBERNETES_VERSION} " " 1.16.255" || " ${CSI_PROW_KUBERNETES_VERSION} " == " latest" ; then
1099
+ info " Version ${CSI_PROW_KUBERNETES_VERSION} , installing CRDs and snapshot controller"
1100
+ install_snapshot_crds
1101
+ install_snapshot_controller
1102
+ else
1103
+ info " Version ${CSI_PROW_KUBERNETES_VERSION} , skipping CRDs and snapshot controller"
1104
+ fi
1105
+
1026
1106
# Installing the driver might be disabled.
1027
1107
if install_hostpath " $images " ; then
1028
1108
collect_cluster_info
0 commit comments