Last active
August 23, 2023 12:58
-
-
Save SoMuchForSubtlety/f0ea010e05dbb814fae39a3c0d407f12 to your computer and use it in GitHub Desktop.
upgrade script for olm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # This script is for upgrading OLM from a GitHub release | |
| set -e | |
| default_base_url=https://github.com/operator-framework/operator-lifecycle-manager/releases/download | |
| if [[ ${#@} -lt 1 || ${#@} -gt 2 ]]; then | |
| echo "Usage: $0 version [base_url]" | |
| echo "* version: the github release version" | |
| echo "* base_url: the github base URL (Default: $default_base_url)" | |
| exit 1 | |
| fi | |
| release="$1" | |
| base_url="${2:-${default_base_url}}" | |
| url="${base_url}/${release}" | |
| namespace=olm | |
| if kubectl get deployment olm-operator -n ${namespace} > /dev/null 2>&1; then | |
| echo "Detected OLM in ${namespace} namespace. continuing..." | |
| else | |
| echo "OLM not installed in ${namespace} namespace. Exiting..." | |
| exit 1 | |
| fi | |
| kubectl replace -f "${url}/crds.yaml" | |
| kubectl wait --for=condition=Established -f "${url}/crds.yaml" | |
| kubectl apply -f "${url}/olm.yaml" | |
| # wait for deployments to be ready | |
| kubectl rollout status -w deployment/olm-operator --namespace="${namespace}" | |
| kubectl rollout status -w deployment/catalog-operator --namespace="${namespace}" | |
| retries=30 | |
| until [[ $retries == 0 ]]; do | |
| new_csv_phase=$(kubectl get csv -n "${namespace}" packageserver -o jsonpath='{.status.phase}' 2>/dev/null || echo "Waiting for CSV to appear") | |
| if [[ $new_csv_phase != "$csv_phase" ]]; then | |
| csv_phase=$new_csv_phase | |
| echo "Package server phase: $csv_phase" | |
| fi | |
| if [[ "$new_csv_phase" == "Succeeded" ]]; then | |
| break | |
| fi | |
| sleep 10 | |
| retries=$((retries - 1)) | |
| done | |
| if [ $retries == 0 ]; then | |
| echo "CSV \"packageserver\" failed to reach phase succeeded" | |
| exit 1 | |
| fi | |
| kubectl rollout status -w deployment/packageserver --namespace="${namespace}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment