longhorn: ensure engine image on oceanus
This commit is contained in:
parent
8fcc61cae9
commit
63c869bf42
@ -2,7 +2,7 @@
|
|||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: Job
|
kind: Job
|
||||||
metadata:
|
metadata:
|
||||||
name: longhorn-csi-toleration-ensure-3
|
name: longhorn-csi-toleration-ensure-4
|
||||||
namespace: longhorn-system
|
namespace: longhorn-system
|
||||||
spec:
|
spec:
|
||||||
backoffLimit: 0
|
backoffLimit: 0
|
||||||
@ -38,14 +38,18 @@ spec:
|
|||||||
value="true"
|
value="true"
|
||||||
effect="NoSchedule"
|
effect="NoSchedule"
|
||||||
|
|
||||||
current="$(kubectl -n "${ns}" get daemonset "${ds}" -o json)"
|
patch_daemonset() {
|
||||||
if echo "${current}" | jq -e \
|
target="$1"
|
||||||
--arg key "${key}" \
|
current="$(kubectl -n "${ns}" get daemonset "${target}" -o json)"
|
||||||
--arg value "${value}" \
|
if echo "${current}" | jq -e \
|
||||||
--arg effect "${effect}" \
|
--arg key "${key}" \
|
||||||
'.spec.template.spec.tolerations[]? | select(.key == $key and .value == $value and .effect == $effect)' >/dev/null; then
|
--arg value "${value}" \
|
||||||
echo "${ds} already tolerates ${key}=${value}:${effect}"
|
--arg effect "${effect}" \
|
||||||
else
|
'.spec.template.spec.tolerations[]? | select(.key == $key and .value == $value and .effect == $effect)' >/dev/null; then
|
||||||
|
echo "${target} already tolerates ${key}=${value}:${effect}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
patch="$(echo "${current}" | jq -c \
|
patch="$(echo "${current}" | jq -c \
|
||||||
--arg key "${key}" \
|
--arg key "${key}" \
|
||||||
--arg value "${value}" \
|
--arg value "${value}" \
|
||||||
@ -61,16 +65,42 @@ spec:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}')"
|
}')"
|
||||||
kubectl -n "${ns}" patch daemonset "${ds}" --type=merge -p "${patch}"
|
kubectl -n "${ns}" patch daemonset "${target}" --type=merge -p "${patch}"
|
||||||
fi
|
}
|
||||||
|
|
||||||
|
patch_daemonset "${ds}"
|
||||||
|
engine_daemonsets="$(kubectl -n "${ns}" get daemonset -l longhorn.io/component=engine-image -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}')"
|
||||||
|
for engine_ds in ${engine_daemonsets}; do
|
||||||
|
patch_daemonset "${engine_ds}"
|
||||||
|
done
|
||||||
|
|
||||||
|
csi_ready="false"
|
||||||
for attempt in $(seq 1 90); do
|
for attempt in $(seq 1 90); do
|
||||||
if kubectl get csinode titan-23 -o json | jq -e '.spec.drivers[]? | select(.name == "driver.longhorn.io")' >/dev/null; then
|
if kubectl get csinode titan-23 -o json | jq -e '.spec.drivers[]? | select(.name == "driver.longhorn.io")' >/dev/null; then
|
||||||
echo "driver.longhorn.io registered on titan-23"
|
echo "driver.longhorn.io registered on titan-23"
|
||||||
exit 0
|
csi_ready="true"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "driver.longhorn.io did not register on titan-23 before timeout" >&2
|
if [ "${csi_ready}" != "true" ]; then
|
||||||
exit 1
|
echo "driver.longhorn.io did not register on titan-23 before timeout" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for engine_ds in ${engine_daemonsets}; do
|
||||||
|
for attempt in $(seq 1 90); do
|
||||||
|
if kubectl -n "${ns}" get pods -o json | jq -e \
|
||||||
|
--arg engine_ds "${engine_ds}" \
|
||||||
|
'.items[] | select(.spec.nodeName == "titan-23") | select(.metadata.ownerReferences[]?.name == $engine_ds) | select([.status.containerStatuses[]?.ready] | all)' >/dev/null; then
|
||||||
|
echo "${engine_ds} ready on titan-23"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ "${attempt}" = "90" ]; then
|
||||||
|
echo "${engine_ds} did not become ready on titan-23 before timeout" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user