Skip to content

Commit

Permalink
add migration for dv (#455)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Updated versioning logic to support migration from version 5 to
version 6.
- Introduced a migration script for managing Persistent Volume Claims
(PVCs) and updating configurations.

- **Bug Fixes**
- Ensured error handling and waiting mechanisms for Kubernetes resources
are preserved during migrations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
klinch0 authored Oct 24, 2024
1 parent b894930 commit 0ae7db6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -o pipefail
set -e

BUNDLE=$(set -x; kubectl get configmap -n cozy-system cozystack -o 'go-template={{index .data "bundle-name"}}')
VERSION=5
VERSION=6

run_migrations() {
if ! kubectl get configmap -n cozy-system cozystack-version; then
Expand Down
15 changes: 15 additions & 0 deletions scripts/migrations/5
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
# Migration 5 --> 6

# Fix tenant-kubernetes PVCs
kubectl get secret -l kamaji.clastix.io/project=kamaji,kamaji.clastix.io/component=admin-kubeconfig -A --output=go-template='{{ range .items }}{{ printf "%s %s %s %s\n" .metadata.namespace .metadata.name (index .metadata.labels "kamaji.clastix.io/name") (index .data "super-admin.conf") }}{{ end }}' | while read NAMESPACE NAME CLUSTER CONFIGB64; do
config=$(mktemp)
echo "$CONFIGB64" | base64 -d > "$config"
kubectl get pv --kubeconfig="$config" --output=go-template='{{ range .items }}{{ printf "%s\n" .metadata.name }}{{ end }}' | while read PVC; do
(set -x; kubectl label pvc --overwrite -n "$NAMESPACE" "$PVC" "cluster.x-k8s.io/cluster-name=$CLUSTER")
(set -x; kubectl label dv --overwrite -n "$NAMESPACE" "$PVC" "cluster.x-k8s.io/cluster-name=$CLUSTER")
done
rm -f "$config"
done

kubectl create configmap -n cozy-system cozystack-version --from-literal=version=6 --dry-run=client -o yaml | kubectl apply -f-

0 comments on commit 0ae7db6

Please sign in to comment.