2023-06-23 17:00:26 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -eE
|
|
|
|
set -o pipefail
|
2022-04-13 16:02:14 +00:00
|
|
|
|
2024-10-16 11:20:20 +00:00
|
|
|
KUBE_VERSION=v1.30
|
2024-06-21 17:28:45 +00:00
|
|
|
|
2022-09-15 12:58:08 +00:00
|
|
|
ARGO_APP=${1:-/tmp/new-kubezero-argoapp.yaml}
|
2022-09-15 09:37:21 +00:00
|
|
|
|
2022-09-14 17:08:14 +00:00
|
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
2022-11-09 16:08:22 +00:00
|
|
|
# shellcheck disable=SC1091
|
2022-04-29 18:22:20 +00:00
|
|
|
[ -n "$DEBUG" ] && set -x
|
2022-04-13 16:02:14 +00:00
|
|
|
|
2023-12-01 16:56:56 +00:00
|
|
|
. "$SCRIPT_DIR"/libhelm.sh
|
2022-09-23 10:54:27 +00:00
|
|
|
|
2024-10-22 12:54:19 +00:00
|
|
|
ARGOCD=$(argo_used)
|
|
|
|
|
2022-09-23 10:54:27 +00:00
|
|
|
echo "Checking that all pods in kube-system are running ..."
|
2024-10-22 12:54:19 +00:00
|
|
|
#waitSystemPodsRunning
|
2022-09-23 10:54:27 +00:00
|
|
|
|
2024-10-22 12:54:19 +00:00
|
|
|
[ "$ARGOCD" == "True" ] && disable_argo
|
2022-09-14 17:08:14 +00:00
|
|
|
|
2024-11-13 14:35:50 +00:00
|
|
|
# 1.30 fix for the missing kubeadm socket annotations
|
|
|
|
for c in $(kubectl get nodes -l "node-role.kubernetes.io/control-plane=" | grep v1.29 | awk {'print $1}'); do
|
|
|
|
kubectl annotate node $c 'kubeadm.alpha.kubernetes.io/cri-socket=unix:///var/run/crio/crio.sock'
|
|
|
|
done
|
|
|
|
|
2022-09-15 09:37:21 +00:00
|
|
|
control_plane_upgrade kubeadm_upgrade
|
2022-09-11 11:54:56 +00:00
|
|
|
|
2024-08-24 09:52:18 +00:00
|
|
|
echo "Control plane upgraded, <Return> to continue"
|
|
|
|
read -r
|
|
|
|
|
2023-11-30 20:04:13 +00:00
|
|
|
#echo "Adjust kubezero values as needed:"
|
2022-11-09 16:08:22 +00:00
|
|
|
# shellcheck disable=SC2015
|
2024-10-22 12:54:19 +00:00
|
|
|
#[ "$ARGOCD" == "True" ] && kubectl edit app kubezero -n argocd || kubectl edit cm kubezero-values -n kubezero
|
2022-09-11 11:54:56 +00:00
|
|
|
|
2024-10-16 11:20:20 +00:00
|
|
|
### v1.30
|
2024-11-08 16:45:10 +00:00
|
|
|
kubectl delete runtimeclass crio || true
|
2024-04-11 13:42:15 +00:00
|
|
|
|
2024-03-22 16:58:42 +00:00
|
|
|
# upgrade modules
|
2024-10-28 14:21:11 +00:00
|
|
|
#
|
2024-11-13 14:35:50 +00:00
|
|
|
# Preload cilium images to running nodes, disabled till 1.31
|
|
|
|
# all_nodes_upgrade "chroot /host crictl pull quay.io/cilium/cilium:v1.16.3; chroot /host crictl pull ghcr.io/k8snetworkplumbingwg/multus-cni:v3.9.3"
|
2024-10-28 14:21:11 +00:00
|
|
|
|
2024-04-08 18:08:45 +00:00
|
|
|
control_plane_upgrade "apply_network, apply_addons, apply_storage, apply_operators"
|
2022-09-11 11:54:56 +00:00
|
|
|
|
2024-11-13 14:35:50 +00:00
|
|
|
# Disabled during 1.30 due to nvidia runtime deadlock
|
|
|
|
#echo "Checking that all pods in kube-system are running ..."
|
|
|
|
#waitSystemPodsRunning
|
2022-09-23 10:54:27 +00:00
|
|
|
|
|
|
|
echo "Applying remaining KubeZero modules..."
|
2022-09-28 15:41:30 +00:00
|
|
|
|
2024-03-27 22:48:02 +00:00
|
|
|
control_plane_upgrade "apply_cert-manager, apply_istio, apply_istio-ingress, apply_istio-private-ingress, apply_logging, apply_metrics, apply_telemetry, apply_argo"
|
2023-05-03 17:33:04 +00:00
|
|
|
|
2024-07-25 13:39:16 +00:00
|
|
|
# Final step is to commit the new argocd kubezero app
|
2024-10-23 10:55:38 +00:00
|
|
|
# remove the del(.spec.source.helm.values) with 1.31
|
|
|
|
kubectl get app kubezero -n argocd -o yaml | yq 'del(.spec.source.helm.values) | del(.status) | del(.metadata) | del(.operation) | .metadata.name="kubezero" | .metadata.namespace="argocd"' | yq 'sort_keys(..)' > $ARGO_APP
|
2024-07-25 13:39:16 +00:00
|
|
|
|
2023-05-03 17:33:04 +00:00
|
|
|
# Trigger backup of upgraded cluster state
|
2024-07-19 14:14:43 +00:00
|
|
|
kubectl create job --from=cronjob/kubezero-backup kubezero-backup-$KUBE_VERSION -n kube-system
|
2023-05-04 08:41:45 +00:00
|
|
|
while true; do
|
2024-07-19 14:14:43 +00:00
|
|
|
kubectl wait --for=condition=complete job/kubezero-backup-$KUBE_VERSION -n kube-system 2>/dev/null && kubectl delete job kubezero-backup-$KUBE_VERSION -n kube-system && break
|
2023-05-04 08:41:45 +00:00
|
|
|
sleep 1
|
|
|
|
done
|
2022-09-15 11:05:38 +00:00
|
|
|
|
2022-09-15 12:58:08 +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."
|
2022-09-23 10:54:27 +00:00
|
|
|
|
|
|
|
echo "<Return> to continue and re-enable ArgoCD:"
|
2022-11-09 16:08:22 +00:00
|
|
|
read -r
|
2022-09-23 10:54:27 +00:00
|
|
|
|
2024-10-22 12:54:19 +00:00
|
|
|
[ "$ARGOCD" == "True" ] && enable_argo
|