diff --git a/.github/actions/dependencies/install-operator-sdk/action.yml b/.github/actions/dependencies/install-operator-sdk/action.yml new file mode 100644 index 0000000..ef83bcc --- /dev/null +++ b/.github/actions/dependencies/install-operator-sdk/action.yml @@ -0,0 +1,22 @@ +name: "Setup OperatorSDK" +description: "Setup OperatorSDK" + +inputs: + operatorSdkVersion: + description: "OperatorSDK version to be installed" + required: false + default: "1.42.2" + architecture: + description: "Architecture" + required: false + default: "amd64" + +runs: + using: "composite" + steps: + - name: Setup OperatorSDK + shell: bash + run: | + ${{ github.action_path }}/setup_operator_sdk.sh "${{ inputs.architecture }}" + env: + OPERATOR_SDK_VERSION: ${{ inputs.operatorSdkVersion }} diff --git a/.github/actions/dependencies/install-operator-sdk/setup_operator_sdk.sh b/.github/actions/dependencies/install-operator-sdk/setup_operator_sdk.sh new file mode 100644 index 0000000..639a01b --- /dev/null +++ b/.github/actions/dependencies/install-operator-sdk/setup_operator_sdk.sh @@ -0,0 +1,13 @@ +OPERATOR_SDK_VERSION=${OPERATOR_SDK_VERSION:-1.42.2} +OS=$(uname | awk '{print tolower($0)}') + +ARCH=$1 +if [ -z "$ARCH" ]; then + ARCH="amd64" +fi + +OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v${OPERATOR_SDK_VERSION} + +curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH} + +chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk diff --git a/.github/actions/dependencies/setup-kind/action.yml b/.github/actions/dependencies/setup-kind/action.yml index 41f6da6..591b390 100644 --- a/.github/actions/dependencies/setup-kind/action.yml +++ b/.github/actions/dependencies/setup-kind/action.yml @@ -26,6 +26,10 @@ inputs: description: "Version of kind cloud-provider image" required: false default: 0.6.0 + installOlm: + description: "Determines if OLM should be installed on Kind" + required: false + default: "false" runs: using: "composite" @@ -80,6 +84,7 @@ runs: WORKER_NODES: ${{ inputs.workerNodes }} KIND_CLOUD_PROVIDER_VERSION: v${{ inputs.cloudProviderVersion }} KIND_VERSION: v${{ inputs.kindVersion }} + INSTALL_OLM: ${{ inputs.installOlm }} - name: Set DOCKER_REGISTRY shell: bash diff --git a/.github/actions/dependencies/setup-kind/setup-kind.sh b/.github/actions/dependencies/setup-kind/setup-kind.sh index 4789e61..48b9974 100755 --- a/.github/actions/dependencies/setup-kind/setup-kind.sh +++ b/.github/actions/dependencies/setup-kind/setup-kind.sh @@ -41,6 +41,10 @@ function is_podman() { [[ "$DOCKER_CMD" == "podman" ]] } +function should_install_olm() { + [[ "$INSTALL_OLM" == "true" ]] +} + function install_kubectl { if [ "${TEST_KUBECTL_VERSION:-latest}" = "latest" ]; then TEST_KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt) @@ -363,6 +367,36 @@ function configure_network { fi } +: ' +@brief: Installs OLM related components to the cluster. +@global: + INSTALL_OLM - environment variable determining if the OLM should be installed or not. +@note: `operator-sdk` has to be installed before running this script (in case that INSTALL_OLM is set to `true`). +' +function setup_olm_on_cluster { + if should_install_olm; then + if ! operator-sdk --help >/dev/null 2>&1 + then + echo "[ERROR] operator-sdk could not be found, be sure to install it before running this script with INSTALL_OLM set to true." + exit 1 + fi + + echo "[INFO] INSTALL_OLM is set to 'true', going to setup OLM on the cluster." + operator-sdk olm install + + echo "[INFO] Checking if the OLM related Pods are app and running before proceeding" + if ! kubectl wait --for=condition=Ready pods -l app=olm-operator -n olm --timeout=120s && \ + kubectl wait --for=condition=Ready pods -l app=catalog-operator -n olm --timeout=120s; then + echo "[ERROR] OLM pods did not become ready in time. Current state:" + kubectl get pods -n olm + kubectl get events -n olm + exit 1 + fi + + echo "[INFO] OLM successfully configured on cluster." + fi +} + setup_kube_directory install_kubectl install_kubernetes_provisioner @@ -452,4 +486,5 @@ fi create_cluster_role_binding_admin label_node -run_cloud_provider_kind ${network_name} \ No newline at end of file +run_cloud_provider_kind ${network_name} +setup_olm_on_cluster \ No newline at end of file