Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds upgrade to online installer script #87

Merged
merged 6 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 66 additions & 1 deletion installer/karavi-observability-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export HELMLOG="${SCRIPTDIR}/helm-install.log"

HELMREPO="https://dell.github.io/helm-charts"

CRD="kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.5.3/cert-manager.crds.yaml"

# adds the Dell helm repository and refreshes it
function helm_repo_add() {
log step "Configure helm chart repository"
Expand Down Expand Up @@ -184,7 +186,7 @@ function install_certmanager_crds() {
log info "Certmanager CRDs are already installed"
else
log step "Installing CertManager CRDs" "small"
run_command "kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.5.3/cert-manager.crds.yaml > ${DEBUGLOG} 2>&1"
run_command "${CRD} > ${DEBUGLOG} 2>&1"
if [ $? -eq 1 ]; then
log step_failure
log error "Unable to create cert-manager CRDs to ${NAMESPACE}."
Expand All @@ -194,6 +196,21 @@ function install_certmanager_crds() {
fi
}

# upgrades CertManager CRDs
function upgrade_certmanager_crds() {
NUM=$(run_command kubectl get crd | grep -e '^certificates.cert-manager.io\s' | wc -l)
if [ "${NUM}" != "0" ]; then
log step "Upgrading CertManager CRDs" "small"
run_command "${CRD} > ${DEBUGLOG} 2>&1"
if [ $? -eq 1 ]; then
log step_failure
log error "Unable to upgrade cert-manager CRDs."
else
log step_success
fi
fi
}

# is_karavi_observability_installed returns 0 if Karavi Observability is already installed in the namespace
function is_karavi_observability_installed() {
NUM=$(run_command helm list --namespace "${NAMESPACE}" | grep "${RELEASE}" | wc -l)
Expand Down Expand Up @@ -258,6 +275,37 @@ function wait_on_pods() {
return 0
}

# upgrade the Karavi Observability helm chart
function upgrade_karavi_observability() {
log step "Updating helm repositories" "small"
run_command "helm repo update > ${DEBUGLOG} 2>&1"
if [ $? -eq 1 ]; then
log step_failure
log error "Unable to update the helm repository. View logs at ${DEBUGLOG}"
fi
log step_success

OPT_VALUES_ARG=""
if [ -n "$VERSION" ]; then
OPT_VALUES_ARG+="--version ${VERSION} "
fi
if [ -n "$VALUES" ]; then
OPT_VALUES_ARG+="--values ${VALUES} "
fi

log step "Upgrading Karavi Observability helm chart"
run_command "helm upgrade \
${OPT_VALUES_ARG} \
--namespace ${NAMESPACE} karavi-observability \
dell/karavi-observability > ${HELMLOG} 2>&1"

if [ $? -ne 0 ]; then
cat "${HELMLOG}"
log error "Unable to upgrade Karavi Observability. View logs at ${HELMLOG}."
fi
log step_success
}

# verify the k8s, openshift, and helm environment prior to installation
function verify_karavi_observability() {
if [ "${VERIFY}" == "0" ]; then
Expand Down Expand Up @@ -419,6 +467,7 @@ function usage() {
decho "Mode:"
decho " install Installs Karavi Observability and enables Karavi Authorization if already installed"
decho " enable-authorization Updates existing installation of Karavi Observability with Karavi Authorization"
decho " upgrade Upgrades existing installation of Karavi Observability to the latest release"
decho "Options:"
decho " Required"
decho " --namespace[=]<namespace> Namespace where Karavi Observability will be installed"
Expand Down Expand Up @@ -677,6 +726,22 @@ case $MODE in
log error "Karavi Authorization is not available to be used"
fi
;;
"upgrade")
validate_params
log section "Upgrading Karavi Observability in namespace ${NAMESPACE} on ${kMajorVersion}.${kMinorVersion}"
is_karavi_observability_installed
if [[ $? == "0" ]]; then
log step "Karavi Observability is installed. Upgrade can continue" "small"
log step_success
else
log error "Karavi Observability is not installed" "small"
fi
verify_karavi_observability
upgrade_certmanager_crds
upgrade_karavi_observability
wait_on_pods
display_helm_log
;;
*)
echo "Unknown mode ${MODE}"
usage
Expand Down
2 changes: 1 addition & 1 deletion installer/offline-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ create_bundle() {
run_command "helm dependency update ${DISTDIR}/${HELMBACKUPDIR}/${CHART}"

# add cert-manager crds file to bundle
run_command "curl -o ${DISTDIR}/${HELMBACKUPDIR}/cert-manager.crds.yaml https://github.com/jetstack/cert-manager/releases/download/v1.1.0/cert-manager.crds.yaml"
run_command "curl -o ${DISTDIR}/${HELMBACKUPDIR}/cert-manager.crds.yaml -L https://github.com/jetstack/cert-manager/releases/download/v1.5.3/cert-manager.crds.yaml"

# copy this script into the distribution directory
cp $0 ${DISTDIR}
Expand Down