Skip to content

Commit e9c463c

Browse files
committed
[platform] Add migration for expose-* options
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 798ca12 commit e9c463c

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

  • scripts/migrations

‎scripts/migrations/11‎

100644100755
File mode changed.

‎scripts/migrations/12‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
)
9+
expose_services=$(echo "$expose_services" | awk '{sub(/,$/,""); print}')
10+
11+
expose_external_ips=$(
12+
kubectl get hr -n tenant-root ingress -o go-template='{{ with .spec }}{{ with .values }}{{ if .externalIPs }}{{ range .externalIPs }}{{ . }},{{ end }}{{ end }}{{ end }}{{ end }}'
13+
)
14+
expose_external_ips=$(echo "$expose_external_ips" | awk '{sub(/,$/,""); print}')
15+
16+
existing_expose_external_ips=$(kubectl get cm -n cozy-system cozystack -o go-template='{{ index .data "expose-external-ips" }}')
17+
existing_expose_services=$(kubectl get cm -n cozy-system cozystack -o go-template='{{ index .data "expose-services" }}')
18+
19+
if [ "$existing_expose_external_ips" == "<no value>" ]; then
20+
kubectl patch cm -n cozy-system cozystack --type merge -p="{\"data\":{\"expose-external-ips\":\"$expose_external_ips\"}}"
21+
fi
22+
23+
if [ "$existing_expose_services" == "<no value>" ]; then
24+
kubectl patch cm -n cozy-system cozystack --type merge -p="{\"data\":{\"expose-services\":\"$expose_services\"}}"
25+
fi
26+
27+
kubectl patch hr -n tenant-root ingress --type json -p='[{"op": "remove", "path": "/spec/values/dashboard"}]' || true
28+
kubectl patch hr -n tenant-root ingress --type json -p='[{"op": "remove", "path": "/spec/values/cdiUploadProxy"}]' || true
29+
kubectl patch hr -n tenant-root ingress --type json -p='[{"op": "remove", "path": "/spec/values/virtExportProxy"}]' || true
30+
kubectl patch hr -n tenant-root ingress --type json -p='[{"op": "remove", "path": "/spec/values/externalIPs"}]' || true
31+
kubectl patch hr -n tenant-root ingress --type merge -p='{"spec":{"chart":{"spec":{"version":"1.6.0"}}}}'
32+
fi
33+
34+
# Write version to cozystack-version config
35+
kubectl create configmap -n cozy-system cozystack-version --from-literal=version=13 --dry-run=client -o yaml | kubectl apply -f-

0 commit comments

Comments
 (0)