mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
Post upgrade fixes for v1.0 migration script (#1935)
## What this PR does
Fixes v1.0 migration script
### Release note
```release-note
V1.0 migration script fixed after an upgrade was performed.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Chores**
* Updated bundle naming convention (paas → isp).
* Restructured configuration schema: flattened branding, renamed
scheduling field, and moved authentication redirect setting.
* Minor output text and prompt wording adjustments.
* **New Features**
* Added support for external IPs in generated configuration with safe
empty fallback.
* Consolidated branding and scheduling entries for simpler output.
* **Bug Fixes**
* Migration script now validates prerequisites and produces improved,
YAML-friendly output.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
1 parent
923c321137
commit
b09a2cd5c3
3 files changed
+42
-17
No files matched your search
@@ -7,8 +7,9 @@ set -e
|
||||
|
||||
NAMESPACE="cozy-system"
|
||||
|
||||
echo "Cozystack Migration to v1.0"
|
||||
echo "==========================="
|
||||
echo "============================="
|
||||
echo " Cozystack Migration to v1.0 "
|
||||
echo "============================="
|
||||
echo ""
|
||||
echo "This script will convert existing ConfigMaps to a Package resource."
|
||||
echo ""
|
||||
@@ -19,6 +20,12 @@ if ! command -v kubectl &> /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if jq is available
|
||||
if ! command -v jq &> /dev/null; then
|
||||
echo "Error: jq is not installed or not in PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if we can access the cluster
|
||||
if ! kubectl get namespace "$NAMESPACE" &> /dev/null; then
|
||||
echo "Error: Cannot access namespace $NAMESPACE"
|
||||
@@ -42,6 +49,7 @@ CLUSTER_DOMAIN=$(echo "$COZYSTACK_CM" | jq -r '.data["cluster-domain"] // "cozy.
|
||||
ROOT_HOST=$(echo "$COZYSTACK_CM" | jq -r '.data["root-host"] // "example.org"')
|
||||
API_SERVER_ENDPOINT=$(echo "$COZYSTACK_CM" | jq -r '.data["api-server-endpoint"] // ""')
|
||||
OIDC_ENABLED=$(echo "$COZYSTACK_CM" | jq -r '.data["oidc-enabled"] // "false"')
|
||||
KEYCLOAK_REDIRECTS=$(echo "$COZYSTACK_CM" | jq -r '.data["extra-keycloak-redirect-uri-for-dashboard"] // ""' )
|
||||
TELEMETRY_ENABLED=$(echo "$COZYSTACK_CM" | jq -r '.data["telemetry-enabled"] // "true"')
|
||||
BUNDLE_NAME=$(echo "$COZYSTACK_CM" | jq -r '.data["bundle-name"] // "paas-full"')
|
||||
|
||||
@@ -51,6 +59,13 @@ POD_GATEWAY=$(echo "$COZYSTACK_CM" | jq -r '.data["ipv4-pod-gateway"] // "10.244
|
||||
SVC_CIDR=$(echo "$COZYSTACK_CM" | jq -r '.data["ipv4-svc-cidr"] // "10.96.0.0/16"')
|
||||
JOIN_CIDR=$(echo "$COZYSTACK_CM" | jq -r '.data["ipv4-join-cidr"] // "100.64.0.0/16"')
|
||||
|
||||
EXTERNAL_IPS=$(echo "$COZYSTACK_CM" | jq -r '.data["expose-external-ips"] // ""')
|
||||
if [ -z "$EXTERNAL_IPS" ]; then
|
||||
EXTERNAL_IPS="[]"
|
||||
else
|
||||
EXTERNAL_IPS=$(echo "$EXTERNAL_IPS" | sed 's/,/\n/g' | awk 'BEGIN{print}{print " - "$0}')
|
||||
fi
|
||||
|
||||
# Determine bundle type
|
||||
case "$BUNDLE_NAME" in
|
||||
paas-full|distro-full)
|
||||
@@ -67,12 +82,24 @@ case "$BUNDLE_NAME" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# Update bundle naming
|
||||
BUNDLE_NAME=$(echo "$BUNDLE_NAME" | sed 's/paas/isp/')
|
||||
|
||||
# Extract branding if available
|
||||
DASHBOARD_BRANDING=$(echo "$BRANDING_CM" | jq -r '.data["dashboard"] // "{}"')
|
||||
KEYCLOAK_BRANDING=$(echo "$BRANDING_CM" | jq -r '.data["keycloak"] // "{}"')
|
||||
BRANDING=$(echo "$BRANDING_CM" | jq -r '.data // {} | to_entries[] | "\(.key): \"\(.value)\""')
|
||||
if [ -z "$BRANDING" ]; then
|
||||
BRANDING="{}"
|
||||
else
|
||||
BRANDING=$(echo "$BRANDING" | awk 'BEGIN{print}{print " " $0}')
|
||||
fi
|
||||
|
||||
# Extract scheduling if available
|
||||
SCHEDULING_CONSTRAINTS=$(echo "$SCHEDULING_CM" | jq -r '.data["topologySpreadConstraints"] // "[]"')
|
||||
SCHEDULING_CONSTRAINTS=$(echo "$SCHEDULING_CM" | jq -r '.data.["globalAppTopologySpreadConstraints"] // ""')
|
||||
if [ -z "$SCHEDULING_CONSTRAINTS" ]; then
|
||||
SCHEDULING_CONSTRAINTS='""'
|
||||
else
|
||||
SCHEDULING_CONSTRAINTS=$(echo "$SCHEDULING_CONSTRAINTS" | awk 'BEGIN{print}{print " " $0}')
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Extracted configuration:"
|
||||
@@ -116,21 +143,21 @@ spec:
|
||||
publishing:
|
||||
host: "$ROOT_HOST"
|
||||
apiServerEndpoint: "$API_SERVER_ENDPOINT"
|
||||
externalIPs: $EXTERNAL_IPS
|
||||
authentication:
|
||||
oidc:
|
||||
enabled: $OIDC_ENABLED
|
||||
keycloakExtraRedirectUri: "$KEYCLOAK_REDIRECTS"
|
||||
scheduling:
|
||||
topologySpreadConstraints: $SCHEDULING_CONSTRAINTS
|
||||
branding:
|
||||
dashboard: $DASHBOARD_BRANDING
|
||||
keycloak: $KEYCLOAK_BRANDING
|
||||
globalAppTopologySpreadConstraints: $SCHEDULING_CONSTRAINTS
|
||||
branding: $BRANDING
|
||||
EOF
|
||||
)
|
||||
|
||||
echo "Generated Package resource:"
|
||||
echo "---"
|
||||
echo "$PACKAGE_YAML"
|
||||
echo "---"
|
||||
echo "..."
|
||||
echo ""
|
||||
|
||||
read -p "Do you want to apply this Package? (y/N) " -n 1 -r
|
||||
@@ -149,4 +176,4 @@ else
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Migration complete!"
|
||||
echo "All done!"
|
||||
@@ -17,6 +17,7 @@ stringData:
|
||||
bundle-name: {{ .Values.bundles.system.variant | quote }}
|
||||
clusterissuer: {{ .Values.publishing.certificates.issuerType | quote }}
|
||||
oidc-enabled: {{ .Values.authentication.oidc.enabled | quote }}
|
||||
extra-keycloak-redirect-uri-for-dashboard: {{ index .Values.authentication.oidc.keycloakExtraRedirectUri | quote }}
|
||||
expose-services: {{ .Values.publishing.exposedServices | join "," | quote }}
|
||||
expose-ingress: {{ .Values.publishing.ingressName | quote }}
|
||||
expose-external-ips: {{ .Values.publishing.externalIPs | join "," | quote }}
|
||||
|
||||
@@ -44,15 +44,12 @@ publishing:
|
||||
authentication:
|
||||
oidc:
|
||||
enabled: false
|
||||
dashboard:
|
||||
extraRedirectUris: []
|
||||
keycloakExtraRedirectUri: ""
|
||||
# Pod scheduling configuration
|
||||
scheduling:
|
||||
topologySpreadConstraints: []
|
||||
globalAppTopologySpreadConstraints: ""
|
||||
# UI branding configuration
|
||||
branding:
|
||||
dashboard: {}
|
||||
keycloak: {}
|
||||
branding: {}
|
||||
# Container registry mirrors configuration
|
||||
#
|
||||
# Example:
|
||||
|
||||
Reference in new issue
Block a user