Update snap-upgrade.sh
This commit is contained in:
parent
3963e1c763
commit
634a3a9506
|
|
@ -1,5 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
command -v jq >/dev/null 2>&1 || { echo "jq is required but not installed. Exiting."; exit 1; }
|
||||||
|
command -v snap >/dev/null 2>&1 || { echo "snap is required but not installed. Exiting."; exit 1; }
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
ALL_SNAPS="kube-apiserver kube-scheduler kube-controller-manager kube-proxy kubectl kubelet cdk-addons"
|
ALL_SNAPS="kube-apiserver kube-scheduler kube-controller-manager kube-proxy kubectl kubelet cdk-addons"
|
||||||
MASTER_SNAPS="kube-apiserver kube-scheduler kube-controller-manager kube-proxy kubectl cdk-addons"
|
MASTER_SNAPS="kube-apiserver kube-scheduler kube-controller-manager kube-proxy kubectl cdk-addons"
|
||||||
|
|
@ -28,7 +31,7 @@ attach_snaps_to_units() {
|
||||||
snap_file=$(ls "${snap}"_*.snap | head -n 1)
|
snap_file=$(ls "${snap}"_*.snap | head -n 1)
|
||||||
if [[ -f "$snap_file" ]]; then
|
if [[ -f "$snap_file" ]]; then
|
||||||
echo "Attaching $snap_file to $service..."
|
echo "Attaching $snap_file to $service..."
|
||||||
# juju attach "$service" "$snap"="$snap_file" || exit 1
|
juju attach "$service" "$snap"="$snap_file" || exit 1
|
||||||
else
|
else
|
||||||
echo "Error: $snap_file not found."
|
echo "Error: $snap_file not found."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -43,7 +46,7 @@ upgrade_service_units() {
|
||||||
unit_names=$(juju status --format json | jq -r ".applications|.[\"$service\"].units | keys[]")
|
unit_names=$(juju status --format json | jq -r ".applications|.[\"$service\"].units | keys[]")
|
||||||
for unit in $unit_names; do
|
for unit in $unit_names; do
|
||||||
echo "Upgrading $unit..."
|
echo "Upgrading $unit..."
|
||||||
# juju run-action "$unit" upgrade --wait || exit 1
|
juju run-action "$unit" upgrade --wait || exit 1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,12 +57,6 @@ snap download --channel="$JUJU_CHANNEL" juju || exit 1
|
||||||
# Download Kubernetes snaps
|
# Download Kubernetes snaps
|
||||||
download_snaps "$ALL_SNAPS" "$SNAP_CHANNEL"
|
download_snaps "$ALL_SNAPS" "$SNAP_CHANNEL"
|
||||||
|
|
||||||
echo "Downloading Juju from channel $JUJU_CHANNEL..."
|
|
||||||
snap download --channel="$JUJU_CHANNEL" juju || exit 1
|
|
||||||
|
|
||||||
# Download Kubernetes snaps
|
|
||||||
download_snaps "$ALL_SNAPS" "$SNAP_CHANNEL"
|
|
||||||
|
|
||||||
# Attach new snaps to Kubernetes master and worker units
|
# Attach new snaps to Kubernetes master and worker units
|
||||||
attach_snaps_to_units "$MASTER_SNAPS" "kubernetes-master"
|
attach_snaps_to_units "$MASTER_SNAPS" "kubernetes-master"
|
||||||
attach_snaps_to_units "$WORKER_SNAPS" "kubernetes-worker"
|
attach_snaps_to_units "$WORKER_SNAPS" "kubernetes-worker"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue