mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-01-27 18:18:41 +00:00
Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
68 lines
3.1 KiB
Bash
Executable File
68 lines
3.1 KiB
Bash
Executable File
#!/bin/sh
|
|
# Migration 20 --> 21
|
|
|
|
set -euo pipefail
|
|
|
|
kubectl -n cozy-system delete helmrelease cozystack-api \
|
|
|| kubectl -n cozy-system delete deployment cozystack-api --ignore-not-found # fallback to help migration progress if it failed first time
|
|
while [ $( kubectl -n cozy-system get po -l app=cozystack-api --no-headers | wc -l ) != 0 ] ;
|
|
do
|
|
echo "Waiting for Cozystack API pods to be deleted";
|
|
sleep 1
|
|
done
|
|
|
|
kubectl -n cozy-system delete helmrelease cozystack-controller \
|
|
|| kubectl -n cozy-system delete deployment cozystack-controller --ignore-not-found # same fallback
|
|
kubectl delete customresourcedefinitions.apiextensions.k8s.io cozystackresourcedefinitions.cozystack.io --ignore-not-found
|
|
while [ $( kubectl -n cozy-system get po -l app=cozystack-controller --no-headers | wc -l ) != 0 ] ;
|
|
do
|
|
echo "Waiting for Cozystack controller pods to be deleted";
|
|
sleep 1
|
|
done
|
|
|
|
kubectl delete helmrelease -n cozy-dashboard dashboard --ignore-not-found
|
|
sleep 5
|
|
cozypkg -n cozy-system -C packages/system/cozystack-resource-definition-crd apply cozystack-resource-definition-crd --plain
|
|
cozypkg -n cozy-system -C packages/system/cozystack-resource-definitions apply cozystack-resource-definitions --plain
|
|
cozypkg -n cozy-system -C packages/system/cozystack-api apply cozystack-api --plain
|
|
if kubectl get ds cozystack-api -n cozy-system >/dev/null 2>&1; then
|
|
echo "Waiting for cozystack-api daemonset"
|
|
kubectl rollout status ds/cozystack-api -n cozy-system --timeout=5m || exit 1
|
|
else
|
|
echo "Waiting for cozystack-api deployment"
|
|
kubectl rollout status deploy/cozystack-api -n cozy-system --timeout=5m || exit 1
|
|
fi
|
|
|
|
helm upgrade --install -n cozy-system cozystack-controller ./packages/system/cozystack-controller/ --take-ownership
|
|
echo "Waiting for cozystack-controller"
|
|
kubectl rollout status deploy/cozystack-controller -n cozy-system --timeout=5m || exit 1
|
|
|
|
helm upgrade --install -n cozy-system lineage-controller-webhook ./packages/system/lineage-controller-webhook/ --take-ownership
|
|
echo "Waiting for lineage-webhook"
|
|
kubectl rollout status ds/lineage-controller-webhook -n cozy-system --timeout=5m || exit 1
|
|
|
|
sleep 5
|
|
echo "Running lineage-webhook test"
|
|
kubectl delete ns cozy-lineage-webhook-test --ignore-not-found && kubectl create ns cozy-lineage-webhook-test
|
|
cleanup_test_ns() {
|
|
kubectl delete ns cozy-lineage-webhook-test --ignore-not-found
|
|
}
|
|
trap cleanup_test_ns ERR
|
|
timeout 60 sh -c 'until kubectl -n cozy-lineage-webhook-test create service clusterip lineage-webhook-test --clusterip="None" --dry-run=server; do sleep 1; done'
|
|
cleanup_test_ns
|
|
|
|
timestamp=$(date --rfc-3339=ns || date)
|
|
kubectl get namespace -o custom-columns=NAME:.metadata.name --no-headers |
|
|
grep '^tenant-' |
|
|
while read namespace ; do
|
|
(set -x; \
|
|
kubectl annotate \
|
|
pods,services,pvc,secrets,ingresses.networking.k8s.io,workloadmonitors.cozystack.io \
|
|
-n "$namespace" --all \
|
|
migration.cozystack.io="$timestamp" --overwrite || true)
|
|
done
|
|
|
|
# Stamp version
|
|
kubectl create configmap -n cozy-system cozystack-version \
|
|
--from-literal=version=21 --dry-run=client -o yaml | kubectl apply -f-
|