|
| 1 | +#!/bin/sh |
| 2 | +# Migration 12 --> 13 |
| 3 | + |
| 4 | +# Copy configuration from ingress to cozystack configmap |
| 5 | +if kubectl get hr -n tenant-root tenant-root > /dev/null; then |
| 6 | + expose_services=$( |
| 7 | + kubectl get hr -n tenant-root ingress -o go-template='{{ with .spec }}{{ with .values }}{{ if .dashboard }}dashboard,{{ end }}{{ if .cdiUploadProxy }}cdi-uploadproxy,{{ end }}{{ if .virtExportProxy }}vm-exportproxy,{{ end }}{{ end }}{{ end }}' |
| 8 | + kubectl get cm -n cozy-system cozystack -o go-template='{{ if eq (index .data "oidc-enabled") "true" }}keycloak,{{ end }}' |
| 9 | + ) |
| 10 | + expose_services=$(echo "$expose_services" | awk '{sub(/,$/,""); print}') |
| 11 | + |
| 12 | + expose_external_ips=$( |
| 13 | + kubectl get hr -n tenant-root ingress -o go-template='{{ with .spec }}{{ with .values }}{{ if .externalIPs }}{{ range .externalIPs }}{{ . }},{{ end }}{{ end }}{{ end }}{{ end }}' |
| 14 | + ) |
| 15 | + expose_external_ips=$(echo "$expose_external_ips" | awk '{sub(/,$/,""); print}') |
| 16 | + |
| 17 | + existing_expose_external_ips=$(kubectl get cm -n cozy-system cozystack -o go-template='{{ index .data "external-ips" }}') |
| 18 | + existing_expose_services=$(kubectl get cm -n cozy-system cozystack -o go-template='{{ index .data "external-ips" }}') |
| 19 | + |
| 20 | + if [ "$existing_expose_external_ips" == "<no value>" ]; then |
| 21 | + kubectl patch cm -n cozy-system cozystack --type merge -p="{\"data\":{\"external-ips\":\"$expose_external_ips\"}}" |
| 22 | + fi |
| 23 | + |
| 24 | + if [ "$existing_expose_services" == "<no value>" ]; then |
| 25 | + kubectl patch cm -n cozy-system cozystack --type merge -p="{\"data\":{\"external-services\":\"$expose_services\"}}" |
| 26 | + fi |
| 27 | + |
| 28 | + kubectl patch hr -n tenant-root ingress --type json -p='[{"op": "remove", "path": "/spec/values/dashboard"}]' || true |
| 29 | + kubectl patch hr -n tenant-root ingress --type json -p='[{"op": "remove", "path": "/spec/values/cdiUploadProxy"}]' || true |
| 30 | + kubectl patch hr -n tenant-root ingress --type json -p='[{"op": "remove", "path": "/spec/values/virtExportProxy"}]' || true |
| 31 | + kubectl patch hr -n tenant-root ingress --type json -p='[{"op": "remove", "path": "/spec/values/externalIPs"}]' || true |
| 32 | + kubectl patch hr -n tenant-root ingress --type merge -p='{"spec":{"chart":{"spec":{"version":"1.6.0"}}}}' |
| 33 | +fi |
| 34 | + |
| 35 | +# Write version to cozystack-version config |
| 36 | +kubectl create configmap -n cozy-system cozystack-version --from-literal=version=13 --dry-run=client -o yaml | kubectl apply -f- |
0 commit comments