@@ -322,6 +322,9 @@ configvar CSI_PROW_E2E_ALPHA_GATES_1_16 'VolumeSnapshotDataSource=true' "alpha f
322322configvar CSI_PROW_E2E_ALPHA_GATES_LATEST ' VolumeSnapshotDataSource=true' " alpha feature gates for latest Kubernetes"
323323configvar CSI_PROW_E2E_ALPHA_GATES " $( get_versioned_variable CSI_PROW_E2E_ALPHA_GATES " ${csi_prow_kubernetes_version_suffix} " ) " " alpha E2E feature gates"
324324
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+
325328# Some tests are known to be unusable in a KinD cluster. For example,
326329# stopping kubelet with "ssh <node IP> systemctl stop kubelet" simply
327330# doesn't work. Such tests should be written in a way that they verify
@@ -657,6 +660,61 @@ install_hostpath () {
657660 fi
658661}
659662
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+ until kubectl get volumesnapshotclasses.snapshot.storage.k8s.io
669+ do
670+ sleep 2
671+ done
672+
673+ kubectl apply -f " ${CRD_BASE_DIR} /snapshot.storage.k8s.io_volumesnapshots.yaml" --validate=false
674+ until kubectl get volumesnapshots.snapshot.storage.k8s.io
675+ do
676+ sleep 2
677+ done
678+
679+ kubectl apply -f " ${CRD_BASE_DIR} /snapshot.storage.k8s.io_volumesnapshotcontents.yaml" --validate=false
680+ until kubectl get volumesnapshotcontents.snapshot.storage.k8s.io
681+ do
682+ sleep 2
683+ done
684+ }
685+
686+ # Install snapshot controller and associated RBAC, retrying until the pod is running.
687+ install_snapshot_controller () {
688+ kubectl apply -f " https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml"
689+ cnt=0
690+ until kubectl get clusterrolebinding snapshot-controller-role; do
691+ if [ $cnt -gt 30 ]; then
692+ echo " Cluster role bindings:"
693+ kubectl describe clusterrolebinding
694+ echo >&2 " ERROR: snapshot controller RBAC not ready after over 5min"
695+ exit 1
696+ fi
697+ echo " $( date +%H:%M:%S) " " waiting for snapshot RBAC setup complete, attempt #$cnt "
698+ cnt=$(( cnt + 1 ))
699+ sleep 10
700+ done
701+
702+
703+ kubectl apply -f " https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
704+ cnt=0
705+ until kubectl get statefulset snapshot-controller | grep snapshot-controller | grep " 1/1" ; do
706+ if [ $cnt -gt 30 ]; then
707+ echo " Running statefulsets:"
708+ kubectl describe statefulsets
709+ echo >&2 " ERROR: snapshot controller not ready after over 5min"
710+ exit 1
711+ fi
712+ echo " $( date +%H:%M:%S) " " waiting for snapshot controller deployment to complete, attempt #$cnt "
713+ cnt=$(( cnt + 1 ))
714+ sleep 10
715+ done
716+ }
717+
660718# collect logs and cluster status (like the version of all components, Kubernetes version, test version)
661719collect_cluster_info () {
662720 cat << EOF
@@ -927,6 +985,10 @@ make_test_to_junit () {
927985 fi
928986}
929987
988+ function version_gt() {
989+ test " $( printf ' %s\n' " $@ " | sort -V | head -n 1) " ! = " $1 " ;
990+ }
991+
930992main () {
931993 local images ret
932994 ret=0
@@ -987,6 +1049,18 @@ main () {
9871049 if tests_need_non_alpha_cluster; then
9881050 start_cluster || die " starting the non-alpha cluster failed"
9891051
1052+ # Install necessary snapshot CRDs and snapshot controller
1053+ # For Kubernetes 1.16+, we will install the CRDs and snapshot controller.
1054+ #
1055+ # TODO: Once 1.17 is released, this should be updated to 1.16.255
1056+ if version_gt " ${CSI_PROW_KUBERNETES_VERSION} " " 1.15.255" ; then
1057+ info " Version ${CSI_PROW_KUBERNETES_VERSION} , installing CRDs and snapshot controller"
1058+ install_snapshot_crds
1059+ install_snapshot_controller
1060+ else
1061+ info " Version ${CSI_PROW_KUBERNETES_VERSION} , skipping CRDs and snapshot controller"
1062+ fi
1063+
9901064 # Installing the driver might be disabled.
9911065 if install_hostpath " $images " ; then
9921066 collect_cluster_info
0 commit comments