KubeZero/admin/upgrade_cluster.sh

53 lines
1.9 KiB
Bash
Raw Normal View History

2023-06-23 17:00:26 +00:00
#!/bin/bash
set -eE
set -o pipefail
2022-04-13 16:02:14 +00:00
ARGO_APP=${1:-/tmp/new-kubezero-argoapp.yaml}
2022-09-15 09:37:21 +00:00
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
2022-11-09 16:08:22 +00:00
# shellcheck disable=SC1091
[ -n "$DEBUG" ] && set -x
2022-04-13 16:02:14 +00:00
2023-12-01 16:56:56 +00:00
. "$SCRIPT_DIR"/libhelm.sh
echo "Checking that all pods in kube-system are running ..."
waitSystemPodsRunning
argo_used && disable_argo
#all_nodes_upgrade ""
2022-09-15 09:37:21 +00:00
control_plane_upgrade kubeadm_upgrade
#echo "Adjust kubezero values as needed:"
2022-11-09 16:08:22 +00:00
# shellcheck disable=SC2015
#argo_used && kubectl edit app kubezero -n argocd || kubectl edit cm kubezero-values -n kube-system
2024-03-22 16:58:42 +00:00
# upgrade modules
control_plane_upgrade "apply_network apply_addons, apply_storage, apply_operators"
echo "Checking that all pods in kube-system are running ..."
waitSystemPodsRunning
echo "Applying remaining KubeZero modules..."
2022-09-28 15:41:30 +00:00
2023-11-22 11:55:34 +00:00
control_plane_upgrade "apply_cert-manager, apply_istio, apply_istio-ingress, apply_istio-private-ingress, apply_logging, apply_metrics, apply_telemetry, apply_argocd"
2023-05-03 17:33:04 +00:00
# Trigger backup of upgraded cluster state
kubectl create job --from=cronjob/kubezero-backup kubezero-backup-$VERSION -n kube-system
2023-05-04 08:41:45 +00:00
while true; do
kubectl wait --for=condition=complete job/kubezero-backup-$VERSION -n kube-system 2>/dev/null && kubectl delete job kubezero-backup-$VERSION -n kube-system && break
sleep 1
done
2022-09-15 11:05:38 +00:00
# Final step is to commit the new argocd kubezero app
kubectl get app kubezero -n argocd -o yaml | yq 'del(.status) | del(.metadata) | del(.operation) | .metadata.name="kubezero" | .metadata.namespace="argocd"' | yq 'sort_keys(..) | .spec.source.helm.values |= (from_yaml | to_yaml)' > $ARGO_APP
2022-09-15 11:05:38 +00:00
echo "Please commit $ARGO_APP as the updated kubezero/application.yaml for your cluster."
2022-09-15 11:05:38 +00:00
echo "Then head over to ArgoCD for this cluster and sync all KubeZero modules to apply remaining upgrades."
echo "<Return> to continue and re-enable ArgoCD:"
2022-11-09 16:08:22 +00:00
read -r
argo_used && enable_argo