@@ -41,6 +41,10 @@ function is_podman() {
4141 [[ " $DOCKER_CMD " == " podman" ]]
4242}
4343
44+ function should_install_olm() {
45+ [[ " $INSTALL_OLM " == " true" ]]
46+ }
47+
4448function install_kubectl {
4549 if [ " ${TEST_KUBECTL_VERSION:- latest} " = " latest" ]; then
4650 TEST_KUBECTL_VERSION=$( curl -L -s https://dl.k8s.io/release/stable.txt)
@@ -363,6 +367,35 @@ function configure_network {
363367 fi
364368}
365369
370+ : '
371+ @brief: Installs OLM related components to the cluster.
372+ @global:
373+ INSTALL_OLM - environment variable determining if the OLM should be installed or not.
374+ @note: `operator-sdk` has to be installed before running this script (in case that INSTALL_OLM is set to `true`).
375+ '
376+ function setup_olm_on_cluster {
377+ if should_install_olm; then
378+ if ! operator-sdk --help > /dev/null 2>&1
379+ then
380+ echo " [ERROR] operator-sdk could not be found, be sure to install it before running this script with INSTALL_OLM set to true."
381+ exit 1
382+ fi
383+
384+ echo " [INFO] INSTALL_OLM is set to 'true', going to setup OLM on the cluster."
385+ operator-sdk olm install
386+
387+ echo " [INFO] Checking if the OLM related Pods are app and running before proceeding"
388+ if ! kubectl wait --for=condition=Ready pods -l app=olm-operator -n olm --timeout=120s && \
389+ kubectl wait --for=condition=Ready pods -l app=catalog-operator -n olm --timeout=120s; then
390+ echo " [ERROR] OLM pods did not become ready in time. Current state:"
391+ kubectl get pods -n olm
392+ exit 1
393+ fi
394+
395+ echo " [INFO] OLM successfully configured on cluster."
396+ fi
397+ }
398+
366399setup_kube_directory
367400install_kubectl
368401install_kubernetes_provisioner
452485
453486create_cluster_role_binding_admin
454487label_node
455- run_cloud_provider_kind ${network_name}
488+ run_cloud_provider_kind ${network_name}
489+ setup_olm_on_cluster
0 commit comments