Skip to content

Commit 5f386ab

Browse files
authored
Merge pull request #17 from SovereignCloudStack/feat/support-multi-csrelease
Feat/support multi csrelease
2 parents ab0d630 + c7ba9b5 commit 5f386ab

9 files changed

Lines changed: 85 additions & 11 deletions

02-deploy-capi.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
#!/bin/bash
22
# Rollout ORC, CAPI, CAPO
33
set -e
4+
# We need settings (not really yet)
5+
unset KUBECONFIG
6+
if test -n "$1"; then
7+
SET="$1"
8+
else
9+
if test -e cluster-settings.env; then SET=cluster-settings.env;
10+
else echo "You need to pass a cluster-settings.env file as parameter"; exit 1
11+
fi
12+
fi
13+
# Read settings -- make sure you can trust it
14+
source "$SET"
415
# Set feature flags
516
export CLUSTER_TOPOLOGY=true
617
export EXP_CLUSTER_RESOURCE_SET=true
718
export EXP_RUNTIME_SDK=true
19+
# We must have the management cluster creds in ~/.kub/config
20+
KUBECONFIG=${KUBECONFIG:-~/.kube/config}
21+
if test ! -r $KUBECONFIG; then
22+
echo "ERROR: Must have KUBECONFIG for mgmt cluster in $KUBECONFIG"
23+
echo " You can create a management cluster with 01-kind-cluster.sh"
24+
exit 1
25+
fi
826
# We need ORC these days and clusterctl has chosen to ignore that
927
kubectl apply -f https://github.com/k-orc/openstack-resource-controller/releases/latest/download/install.yaml
1028
# Rollout capi and capo (assuming that orc gets deployed independently)
1129
clusterctl init --infrastructure openstack
1230
# Wait for completion
1331
kubectl -n capi-system rollout status deployment
1432
kubectl -n capo-system rollout status deployment
15-

03-deploy-cso.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
#!/bin/bash
22
# Deploy CSO
33
set -e
4-
mkdir ~/tmp || true
5-
4+
mkdir -p ~/tmp
5+
# We need settings (not really yet)
6+
unset KUBECONFIG
7+
if test -n "$1"; then
8+
SET="$1"
9+
else
10+
if test -e cluster-settings.env; then SET=cluster-settings.env;
11+
else echo "You need to pass a cluster-settings.env file as parameter"; exit 1
12+
fi
13+
fi
14+
# Deploy CSO
615
cat > ~/tmp/cso-rbac.yaml <<EOF
716
clusterStackVariables:
817
ociRepository: registry.scs.community/kaas/cluster-stacks

04-cloud-secret.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Create cloud secret
33
set -e
44
# We need settings
5+
unset KUBECONFIG
56
if test -n "$1"; then
67
SET="$1"
78
else

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!

08-wait-cluster.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Wait for cluster
33
set -e
44
# We need settings
5+
unset KUBECONFIG
56
if test -n "$1"; then
67
SET="$1"
78
else
@@ -11,10 +12,12 @@ else
1112
fi
1213
# Read settings -- make sure you can trust it
1314
source "$SET"
14-
kubectl get cluster -A
15+
#kubectl get cluster -A
1516
#set -x
16-
kubectl wait --timeout=14m --for=condition=certificatesavailable -n "$CS_NAMESPACE" kubeadmcontrolplanes -l cluster.x-k8s.io/cluster-name=$CL_NAME
17+
echo "# Wait for certificates for cluster -n $CS_NAMESPACE $CL_NAME"
18+
kubectl wait --timeout=12m --for=condition=certificatesavailable -n "$CS_NAMESPACE" kubeadmcontrolplanes -l cluster.x-k8s.io/cluster-name=$CL_NAME
1719
kubectl get -n "$CS_NAMESPACE" cluster $CL_NAME
20+
kubectl wait --timeout=8m --for=condition=Ready -n "$CS_NAMESPACE" machine -l cluster.x-k8s.io/control-plane,cluster.x-k8s.io/cluster-name=${CL_NAME}
1821
clusterctl describe cluster -n "$CS_NAMESPACE" $CL_NAME --grouping=false
1922
KCFG=~/.kube/$CS_NAMESPACE.$CL_NAME
2023
OLDUMASK=$(umask)

09-fixup-cinder.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
set -e
1313
THISDIR=$(dirname 0)
1414
# We need settings
15+
#unset KUBECONFIG
1516
if test -n "$1"; then
1617
SET="$1"
1718
else
@@ -22,8 +23,8 @@ fi
2223
# Read settings -- make sure you can trust it
2324
source "$SET"
2425
# Do this on the workload cluster, ensure we have a config
25-
clusterctl get kubeconfig -n $CS_NAMESPACE $CL_NAME > ~/.kube/config-$CS_NAMESPACE.$CL_NAME
26-
export KUBECONFIG=~/.kube/config-$CS_NAMESPACE.$CL_NAME
26+
#clusterctl get kubeconfig -n $CS_NAMESPACE $CL_NAME > ~/.kube/$CS_NAMESPACE.$CL_NAME
27+
export KUBECONFIG=~/.kube/$CS_NAMESPACE.$CL_NAME
2728
# Get cinder-csi-controllerplugin deployment and patch it
2829
kubectl get -n kube-system deployment openstack-cinder-csi-controllerplugin -o yaml > ~/tmp/cinder-csi-controllerplugin.yaml
2930
patch ~/tmp/cinder-csi-controllerplugin.yaml <$THISDIR/csi-cinder-controller-deployment.diff

cluster-settings-template.env

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#
55
# TODO: Check whether we can make this more compatible with v1 KaaS
66
#
7+
### Management cluster
8+
# You do not normally override it
9+
#KUBECONFIG=~/.kube/config
710
### Per namespace: secrets
811
# The namespace to keep your CS objects for a set of clusters (use e.g. cloud project name)
912
CS_NAMESPACE=clusterns
@@ -14,7 +17,7 @@ OS_CLOUD=${OS_CLOUD:-openstack}
1417
### Per cluster stack settings
1518
# Kubernetes Maj.Min, e.g. 1.32 (without leading v), can be left empty (see last line)
1619
CS_MAINVER=
17-
# CS Template version that matches, e.g. v1 or v0-sha.XXXXXXX, see table
20+
# CS Template version that matches, e.g. v1 or v0-sha.XXXXXXX, see table, can also be an array [v1, v2]
1821
CS_VERSION=
1922
### Now the per workload cluster settings
2023
# Full K8s Version Maj.Min.Patch, without leading 'v', e.g. 1.32.3 (this is per cluster)

0 commit comments

Comments
 (0)