Skip to content

Commit 2cd3990

Browse files
committed
Add possibility to install OLM related deps on Kind cluster
Signed-off-by: Lukas Kral <[email protected]>
1 parent e39417a commit 2cd3990

4 files changed

Lines changed: 75 additions & 1 deletion

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Setup OperatorSDK"
2+
description: "Setup OperatorSDK"
3+
4+
inputs:
5+
operatorSdkVersion:
6+
description: "OperatorSDK version to be installed"
7+
required: false
8+
default: "1.42.2"
9+
architecture:
10+
description: "Architecture"
11+
required: false
12+
default: "amd64"
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Setup OperatorSDK
18+
shell: bash
19+
run: |
20+
${{ github.action_path }}/setup_operator_sdk.sh "${{ inputs.architecture }}"
21+
env:
22+
OPERATOR_SDK_VERSION: ${{ inputs.operatorSdkVersion }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
OPERATOR_SDK_VERSION=${OPERATOR_SDK_VERSION:-1.42.2}
2+
OS=$(uname | awk '{print tolower($0)}')
3+
4+
ARCH=$1
5+
if [ -z "$ARCH" ]; then
6+
ARCH="amd64"
7+
fi
8+
9+
OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v${OPERATOR_SDK_VERSION}
10+
11+
curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
12+
13+
chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk

.github/actions/dependencies/setup-kind/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ inputs:
2626
description: "Version of kind cloud-provider image"
2727
required: false
2828
default: 0.6.0
29+
installOlm:
30+
description: "Determines if OLM should be installed on Kind"
31+
required: false
32+
default: "false"
2933

3034
runs:
3135
using: "composite"
@@ -80,6 +84,7 @@ runs:
8084
WORKER_NODES: ${{ inputs.workerNodes }}
8185
KIND_CLOUD_PROVIDER_VERSION: v${{ inputs.cloudProviderVersion }}
8286
KIND_VERSION: v${{ inputs.kindVersion }}
87+
INSTALL_OLM: ${{ inputs.installOlm }}
8388

8489
- name: Set DOCKER_REGISTRY
8590
shell: bash

.github/actions/dependencies/setup-kind/setup-kind.sh

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ function is_podman() {
4141
[[ "$DOCKER_CMD" == "podman" ]]
4242
}
4343

44+
function should_install_olm() {
45+
[[ "$INSTALL_OLM" == "true" ]]
46+
}
47+
4448
function 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+
366399
setup_kube_directory
367400
install_kubectl
368401
install_kubernetes_provisioner
@@ -452,4 +485,5 @@ fi
452485

453486
create_cluster_role_binding_admin
454487
label_node
455-
run_cloud_provider_kind ${network_name}
488+
run_cloud_provider_kind ${network_name}
489+
setup_olm_on_cluster

0 commit comments

Comments
 (0)