cozystack/scripts/migrations/21
Andrei Kvapil acc6ed26bb
fix(platform): fix migrations for v0.40 release (#1846)
## What this PR does

Fixes migration scripts for v0.40 release to ensure smooth upgrade
process.

Changes:
- **Migration 20**: Replace `helm upgrade --install` with `cozyhr apply`
for cozystack-controller and lineage-controller-webhook
- **Migration 21**: Improve Flux instance removal process:
  - Disable reconciliation on FluxInstance before deletion
  - Delete Flux deployments before HelmReleases
  - Add `--wait=false` flags to prevent hanging
  - Fix CRD grep pattern to properly match `fluxcd.io` domains
- **Migration 22**: Add new migration tasks:
- Migrate Victoria Metrics Operator CRDs to prometheus-operator-crds
Helm release
  - Remove CozyStack Resource Definitions HelmRelease
- Add default version v17 to PostgreSQL HelmReleases without explicit
version

### Release note

```release-note
[platform] Fix migration scripts for v0.40 release: improve Flux removal, add VictoriaMetrics CRD migration, set default PostgreSQL version
```
2026-01-10 01:52:12 +01:00

30 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
# Migration 21 --> 22
set -euo pipefail
# Disable pruning on Flux CRDs
for crd in $(kubectl get crd -o name | grep 'fluxcd.io$'); do
kubectl annotate $crd fluxcd.controlplane.io/prune=disabled
done
# Remove flux instance
if kubectl get fluxinstance flux -n cozy-fluxcd >/dev/null 2>&1; then
kubectl annotate fluxinstance flux -n cozy-fluxcd fluxcd.controlplane.io/reconcile=disabled
kubectl delete fluxinstance flux -n cozy-fluxcd
fi
kubectl delete deploy -n cozy-fluxcd -l app.kubernetes.io/part-of=flux --ignore-not-found
kubectl delete hr -n cozy-fluxcd fluxcd --ignore-not-found --wait=false
# Remove fluxcd-operator
kubectl delete hr -n cozy-fluxcd fluxcd-operator --ignore-not-found --wait=false
kubectl delete deploy -n cozy-fluxcd flux-operator --ignore-not-found
# Remove labels from CRDs
for crd in $(kubectl get crd -o name | grep 'fluxcd\.io$'); do
kubectl label $crd fluxcd.controlplane.io/name- fluxcd.controlplane.io/namespace-
done
# Stamp version
kubectl create configmap -n cozy-system cozystack-version \
--from-literal=version=22 --dry-run=client -o yaml | kubectl apply -f-