@@ -700,6 +700,10 @@ install_csi_driver () {
700
700
install_snapshot_crds () {
701
701
# Wait until volumesnapshot CRDs are in place.
702
702
CRD_BASE_DIR=" https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /client/config/crd"
703
+ if [[ ${REPO_DIR} == * " external-snapshotter" * ]]; then
704
+ CRD_BASE_DIR=" ${REPO_DIR} /client/config/crd"
705
+ fi
706
+ echo " Installing snapshot CRDs from ${CRD_BASE_DIR} "
703
707
kubectl apply -f " ${CRD_BASE_DIR} /snapshot.storage.k8s.io_volumesnapshotclasses.yaml" --validate=false
704
708
kubectl apply -f " ${CRD_BASE_DIR} /snapshot.storage.k8s.io_volumesnapshots.yaml" --validate=false
705
709
kubectl apply -f " ${CRD_BASE_DIR} /snapshot.storage.k8s.io_volumesnapshotcontents.yaml" --validate=false
@@ -719,7 +723,16 @@ install_snapshot_crds() {
719
723
720
724
# Install snapshot controller and associated RBAC, retrying until the pod is running.
721
725
install_snapshot_controller () {
722
- kubectl apply -f " https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml"
726
+ CONTROLLER_DIR=" https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} "
727
+ if [[ ${REPO_DIR} == * " external-snapshotter" * ]]; then
728
+ CONTROLLER_DIR=" ${REPO_DIR} "
729
+ fi
730
+ SNAPSHOT_RBAC_YAML=" ${CONTROLLER_DIR} /deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml"
731
+ echo " kubectl apply -f ${SNAPSHOT_RBAC_YAML} "
732
+ # Ignore: Double quote to prevent globbing and word splitting.
733
+ # shellcheck disable=SC2086
734
+ kubectl apply -f ${SNAPSHOT_RBAC_YAML}
735
+
723
736
cnt=0
724
737
until kubectl get clusterrolebinding snapshot-controller-role; do
725
738
if [ $cnt -gt 30 ]; then
@@ -733,8 +746,60 @@ install_snapshot_controller() {
733
746
sleep 10
734
747
done
735
748
749
+ SNAPSHOT_CONTROLLER_YAML=" ${CONTROLLER_DIR} /deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
750
+ if [[ ${REPO_DIR} == * " external-snapshotter" * ]]; then
751
+ # snapshot-controller image built from the PR will get a "csiprow" tag.
752
+ # Load it into the "kind" cluster so that we can deploy it.
753
+ NEW_TAG=" csiprow"
754
+ NEW_IMG=" snapshot-controller:${NEW_TAG} "
755
+ echo " kind load docker-image --name csi-prow ${NEW_IMG} "
756
+ kind load docker-image --name csi-prow ${NEW_IMG} || die " could not load the snapshot-controller:csiprow image into the kind cluster"
757
+
758
+ # deploy snapshot-controller
759
+ echo " Deploying snapshot-controller"
760
+ # Replace image in SNAPSHOT_CONTROLLER_YAML with snapshot-controller:csiprow and deploy
761
+ # NOTE: This logic is similar to the logic here:
762
+ # https://github.com/kubernetes-csi/csi-driver-host-path/blob/v1.4.0/deploy/util/deploy-hostpath.sh#L155
763
+ # Ignore: Double quote to prevent globbing and word splitting.
764
+ # shellcheck disable=SC2086
765
+ # Ignore: Use find instead of ls to better handle non-alphanumeric filenames.
766
+ # shellcheck disable=SC2012
767
+ for i in $( ls ${SNAPSHOT_CONTROLLER_YAML} | sort) ; do
768
+ echo " $i "
769
+ # Ignore: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
770
+ # shellcheck disable=SC2002
771
+ # Ignore: See if you can use ${variable//search/replace} instead.
772
+ # shellcheck disable=SC2001
773
+ modified=" $( cat " $i " | while IFS= read -r line; do
774
+ nocomments=" $( echo " $line " | sed -e ' s/ *#.*$//' ) "
775
+ if echo " $nocomments " | grep -q ' ^[[:space:]]*image:[[:space:]]*' ; then
776
+ # Split 'image: k8s.gcr.io/sig-storage/snapshot-controller:v3.0.0'
777
+ # into image (snapshot-controller:v3.0.0),
778
+ # name (snapshot-controller),
779
+ # tag (v3.0.0).
780
+ image=$( echo " $nocomments " | sed -e ' s;.*image:[[:space:]]*;;' )
781
+ name=$( echo " $image " | sed -e ' s;.*/\([^:]*\).*;\1;' )
782
+ tag=$( echo " $image " | sed -e ' s;.*:;;' )
783
+
784
+ # Now replace registry and/or tag
785
+ NEW_TAG=" csiprow"
786
+ line=" $( echo " $nocomments " | sed -e " s;$image ;${name} :${NEW_TAG} ;" ) "
787
+ echo " using $line " >&2
788
+ fi
789
+ echo " $line "
790
+ done)"
791
+ if ! echo " $modified " | kubectl apply -f -; then
792
+ echo " modified version of $i :"
793
+ echo " $modified "
794
+ exit 1
795
+ fi
796
+ echo " kubectl apply -f ${SNAPSHOT_CONTROLLER_YAML} (modified)"
797
+ done
798
+ else
799
+ echo " kubectl apply -f ${CONTROLLER_DIR} /deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
800
+ kubectl apply -f " ${CONTROLLER_DIR} /deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
801
+ fi
736
802
737
- kubectl apply -f " https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${CSI_SNAPSHOTTER_VERSION} /deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"
738
803
cnt=0
739
804
expected_running_pods=$( curl https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/" ${CSI_SNAPSHOTTER_VERSION} " /deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml | grep replicas | cut -d ' :' -f 2-)
740
805
while [ " $( kubectl get pods -l app=snapshot-controller | grep ' Running' -c) " -lt " $expected_running_pods " ]; do
0 commit comments