mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-01-27 18:18:41 +00:00
image to test:
```
ghcr.io/aenix-io/cozystack/cozystack:v0.8.0@sha256:48e9f676f4eca5f7036648a56767c31beb0aca8fdc6d6798bd65de74886ed1ef
```
this PR should fix a problem of upgrading from older cozystack version
```
make: Leaving directory '/cozystack/packages/core/platform'
deployment.apps/source-controller condition met
deployment.apps/helm-controller condition met
Error from server (NotFound): helmreleases.helm.toolkit.fluxcd.io "fluxcd" not found
NAME CREATED AT
helmreleases.helm.toolkit.fluxcd.io 2024-05-29T11:00:16Z
helmrepositories.source.toolkit.fluxcd.io 2024-05-29T11:00:17Z
make: Entering directory '/cozystack/packages/system/fluxcd-operator'
kubectl patch hr -n cozy-fluxcd fluxcd-operator -p '{"spec": {"suspend": true}}' --type=merge --field-manager=flux-client-side-apply
Error from server (NotFound): helmreleases.helm.toolkit.fluxcd.io "fluxcd-operator" not found
make: *** [../../../scripts/package-system.mk:20: suspend] Error 1
make: Leaving directory '/cozystack/packages/system/fluxcd-operator'
time="2024-07-04T12:50:05Z" level=fatal msg="failed to run" err="exit status 2"
```
88 lines
2.6 KiB
Bash
Executable File
88 lines
2.6 KiB
Bash
Executable File
#!/bin/sh
|
|
set -o pipefail
|
|
set -e
|
|
|
|
BUNDLE=$(set -x; kubectl get configmap -n cozy-system cozystack -o 'go-template={{index .data "bundle-name"}}')
|
|
VERSION=4
|
|
|
|
run_migrations() {
|
|
if ! kubectl get configmap -n cozy-system cozystack-version; then
|
|
kubectl create configmap -n cozy-system cozystack-version --from-literal=version="$VERSION" --dry-run=client -o yaml | kubectl create -f-
|
|
return
|
|
fi
|
|
current_version=$(kubectl get configmap -n cozy-system cozystack-version -o jsonpath='{.data.version}') || true
|
|
until [ "$current_version" = "$VERSION" ]; do
|
|
echo "run migration: $current_version --> $VERSION"
|
|
scripts/migrations/$current_version
|
|
current_version=$(kubectl get configmap -n cozy-system cozystack-version -o jsonpath='{.data.version}')
|
|
done
|
|
}
|
|
|
|
flux_is_ok() {
|
|
kubectl wait --for=condition=available -n cozy-fluxcd deploy/source-controller deploy/helm-controller --timeout=1s
|
|
kubectl wait --for=condition=ready -n cozy-fluxcd helmrelease/fluxcd --timeout=1s # to call "apply resume" below
|
|
}
|
|
|
|
ensure_fluxcd() {
|
|
if flux_is_ok; then
|
|
return
|
|
fi
|
|
# Install fluxcd-operator
|
|
if kubectl get helmreleases.helm.toolkit.fluxcd.io -n cozy-fluxcd fluxcd-operator; then
|
|
make -C packages/system/fluxcd-operator apply resume
|
|
else
|
|
make -C packages/system/fluxcd-operator apply-locally
|
|
fi
|
|
wait_for_crds fluxinstances.fluxcd.controlplane.io
|
|
|
|
# Install fluxcd
|
|
if kubectl get helmreleases.helm.toolkit.fluxcd.io -n cozy-fluxcd fluxcd; then
|
|
make -C packages/system/fluxcd apply resume
|
|
else
|
|
make -C packages/system/fluxcd apply-locally
|
|
fi
|
|
wait_for_crds helmreleases.helm.toolkit.fluxcd.io helmrepositories.source.toolkit.fluxcd.io
|
|
}
|
|
|
|
wait_for_crds() {
|
|
timeout 60 sh -c "until kubectl get crd $*; do sleep 1; done"
|
|
}
|
|
|
|
install_basic_charts() {
|
|
if [ "$BUNDLE" = "paas-full" ] || [ "$BUNDLE" = "distro-full" ]; then
|
|
make -C packages/system/cilium apply resume
|
|
fi
|
|
if [ "$BUNDLE" = "paas-full" ]; then
|
|
make -C packages/system/kubeovn apply resume
|
|
fi
|
|
}
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
# Run migrations
|
|
run_migrations
|
|
|
|
# Install namespaces
|
|
make -C packages/core/platform namespaces-apply
|
|
|
|
# Install fluxcd
|
|
ensure_fluxcd
|
|
|
|
# Install platform chart
|
|
make -C packages/core/platform apply
|
|
|
|
# Install basic charts
|
|
if ! flux_is_ok; then
|
|
install_basic_charts
|
|
fi
|
|
|
|
# Reconcile Helm repositories
|
|
kubectl annotate helmrepositories.source.toolkit.fluxcd.io -A -l cozystack.io/repository reconcile.fluxcd.io/requestedAt=$(date +"%Y-%m-%dT%H:%M:%SZ") --overwrite
|
|
|
|
# Reconcile platform chart
|
|
trap 'exit' INT TERM
|
|
while true; do
|
|
sleep 60 & wait
|
|
make -C packages/core/platform apply
|
|
done
|