Skip to content

Commit 9b483e1

Browse files
committed
Add snapshotter CRDs after cluster setup
Signed-off-by: Grant Griffiths <grant@portworx.com>
1 parent 4fcafec commit 9b483e1

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

prow.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ configvar CSI_PROW_E2E_ALPHA_GATES_1_16 'VolumeSnapshotDataSource=true' "alpha f
322322
configvar CSI_PROW_E2E_ALPHA_GATES_LATEST 'VolumeSnapshotDataSource=true' "alpha feature gates for latest Kubernetes"
323323
configvar 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,48 @@ 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"
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"
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"
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+
690+
kubectl apply -f "https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION}/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
691+
cnt=0
692+
while [ "$(kubectl get pods 2>/dev/null | grep -c '^snapshot-controller.* Running ')" -lt 1 ]; do
693+
if [ $cnt -gt 30 ]; then
694+
echo "Running pods:"
695+
kubectl describe pods
696+
echo >&2 "ERROR: snapshot controller not ready after over 5min"
697+
exit 1
698+
fi
699+
echo "$(date +%H:%M:%S)" "waiting for snapshot controller deployment to complete, attempt #$cnt"
700+
cnt=$((cnt + 1))
701+
sleep 10
702+
done
703+
}
704+
660705
# collect logs and cluster status (like the version of all components, Kubernetes version, test version)
661706
collect_cluster_info () {
662707
cat <<EOF
@@ -987,6 +1032,10 @@ main () {
9871032
if tests_need_non_alpha_cluster; then
9881033
start_cluster || die "starting the non-alpha cluster failed"
9891034

1035+
# Install necessary snapshot CRDs and snapshot controller
1036+
install_snapshot_crds
1037+
install_snapshot_controller
1038+
9901039
# Installing the driver might be disabled.
9911040
if install_hostpath "$images"; then
9921041
collect_cluster_info

0 commit comments

Comments
 (0)