Skip to content

Commit 53e2302

Browse files
committed
Allow passing multiple cluster-stack versions.
So we want to have several clusterstackreleases coexist, let's support registering several of them. Signed-off-by: Kurt Garloff <kurt@garloff.de>
1 parent ab0d630 commit 53e2302

4 files changed

Lines changed: 44 additions & 4 deletions

File tree

05-deploy-cstack.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Deploy the ClusterStack
33
set -e
44
# We need settings
5+
unset KUBECONFIG
56
if test -n "$1"; then
67
SET="$1"
78
else
@@ -30,8 +31,7 @@ spec:
3031
channel: custom
3132
autoSubscribe: false
3233
noProvider: true
33-
versions:
34-
- $CS_VERSION
34+
versions: $CS_VERSION
3535
EOF
3636
# Apply
3737
kubectl apply -f ~/tmp/clusterstack-$CS_MAINVER.yaml

06-wait-clusterclass.sh

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Do we need this?
44
set -e
55
# We need settings
6+
unset KUBECONFIG
67
if test -n "$1"; then
78
SET="$1"
89
else
@@ -12,7 +13,32 @@ else
1213
fi
1314
# Read settings -- make sure you can trust it
1415
source "$SET"
16+
# If we have an array, match what CS_VERSION we want to wait for
17+
if test "${CS_VERSION:0:1}" = "["; then
18+
VERSIONS="$(echo $CS_VERSION | sed -e 's/\[//' -e 's/\]//' -e 's/,/ /g')"
19+
for ver in $VERSIONS; do
20+
#echo "Wait for clusterstackrelease -n $CS_NAMESPACE openstack-scs-${CS_MAINVER/./-}-${ver/./-} readiness"
21+
echo "Wait for clusterstackrelease -n $CS_NAMESPACE openstack-scs-${CS_MAINVER/./-}-${ver/./-} creation"
22+
kubectl wait -n "$CS_NAMESPACE" clusterstackrelease openstack-scs-${CS_MAINVER/./-}-${ver/./-} --for create
23+
done
24+
VERSIONS=$(kubectl get clusterstackreleases -n $CS_NAMESPACE -o "custom-columns=NAME:.metadata.name,K8SVER:.status.kubernetesVersion")
25+
echo -e "# Table of registered clusterstackreleases:\n$VERSIONS"
26+
while read csnm k8sver; do
27+
if test "$csnm" = "NAME"; then continue; fi
28+
if test "$k8sver" = "v$CL_PATCHVER"; then
29+
CS_VERSION="v${csnm#openstack-scs-?-??-v}"
30+
CS_VERSION="${CS_VERSION%-*}.${CS_VERSION##*-}"
31+
break
32+
fi
33+
done < <(echo "$VERSIONS")
34+
if test "${CS_VERSION:0:1}" = "["; then
35+
echo "No clusterstackrelease with v$CL_PATCHVER found"
36+
fi
37+
else
38+
echo "Wait for clusterstackrelease -n $CS_NAMESPACE openstack-scs-${CS_MAINVER/./-}-${CS_VERSION/./-} readiness"
39+
kubectl wait -n "$CS_NAMESPACE" clusterstackrelease openstack-scs-${CS_MAINVER/./-}-${CS_VERSION/./-} --for condition=ready
40+
fi
41+
echo "# Wait for clusterclass -n $CS_NAMESPACE openstack-scs-${CS_MAINVER/./-}-${CS_VERSION} creation"
1542
kubectl wait -n "$CS_NAMESPACE" clusterclass openstack-scs-${CS_MAINVER/./-}-${CS_VERSION} --for create
1643
kubectl get clusterclasses -n "$CS_NAMESPACE"
1744
kubectl get images -n "$CS_NAMESPACE"
18-
kubectl wait -n "$CS_NAMESPACE" clusterstackrelease openstack-scs-${CS_MAINVER/./-}-${CS_VERSION/./-} --for condition=ready

07-create-cluster.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
set -e
33
# We need settings
4+
# unset KUBECONFIG
45
if test -n "$1"; then
56
SET="$1"
67
else
@@ -20,6 +21,19 @@ if test -z "$CL_SVCCIDR"; then echo "Configure CL_SVCCIDR"; exit 7; fi
2021
if test -z "$CL_CTRLNODES"; then echo "Configure CL_CTRLNODES"; exit 8; fi
2122
if test -z "$CL_WRKRNODES"; then echo "Configure CL_WRKRNODES"; exit 9; fi
2223
# Create Cluster yaml
24+
# If we have an array, match what CS_VERSION we want to wait for
25+
if test "${CS_VERSION:0:1}" = "["; then
26+
VERSIONS=$(kubectl get clusterstackreleases -n $CS_NAMESPACE -o "custom-columns=NAME:.metadata.name,K8SVER:.status.kubernetesVersion")
27+
while read csnm k8sver; do
28+
if test "$csnm" = "NAME"; then continue; fi
29+
if test "$k8sver" = "v$CL_PATCHVER"; then
30+
CS_VERSION="v${csnm#openstack-scs-?-??-v}"
31+
CS_VERSION="${CS_VERSION%-*}.${CS_VERSION##*-}"
32+
break
33+
fi
34+
done < <(echo "$VERSIONS")
35+
if test "${CS_VERSION:0:1}" = "["; then echo "No clusterstackrelease with v$CL_PATCHVER found"; exit 10; fi
36+
fi
2337
# TODO: There are a number of variables that allow us to set things like
2438
# flavors, disk sizes, loadbalancer types, etc.
2539
# We need to make them visible!

cluster-settings-template.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ OS_CLOUD=${OS_CLOUD:-openstack}
1414
### Per cluster stack settings
1515
# Kubernetes Maj.Min, e.g. 1.32 (without leading v), can be left empty (see last line)
1616
CS_MAINVER=
17-
# CS Template version that matches, e.g. v1 or v0-sha.XXXXXXX, see table
17+
# CS Template version that matches, e.g. v1 or v0-sha.XXXXXXX, see table, can also be an array [v1, v2]
1818
CS_VERSION=
1919
### Now the per workload cluster settings
2020
# Full K8s Version Maj.Min.Patch, without leading 'v', e.g. 1.32.3 (this is per cluster)

0 commit comments

Comments
 (0)