Skip to content

Commit 4526a49

Browse files
committed
N clusters creation
Signed-off-by: Pablo Iranzo Gómez <Pablo.Iranzo@gmail.com>
1 parent b8f1e48 commit 4526a49

3 files changed

Lines changed: 45 additions & 51 deletions

File tree

hack/deploy-hub-local/build.sh

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ set -m
77

88
# variables
99
# #########
10-
export CLUSTERS=$1
1110
export DEPLOY_OCP_DIR="./"
1211
export OC_AMORGANT_PULL_SECRET='"{"auths": ... }"'
1312
export OC_RELEASE="quay.io/openshift-release-dev/ocp-release:4.9.0-x86_64"
@@ -17,29 +16,34 @@ export OC_NET_CLASS="ipv4"
1716
export OC_TYPE_ENV="connected"
1817
export VERSION="ci"
1918

20-
if [ $# -ne 1 ] ; then
21-
echo "Usage: $0 <clusters>"
19+
if [ $1 != "" ]; then
20+
export CLUSTERS=$1
21+
else
22+
export CLUSTERS=0
23+
fi
24+
25+
# Only complain when there's less than one cluster
26+
if [ ${CLUSTERS} -lt 0 ]; then
27+
echo "Usage: $0 <# of clusters>"
2228
exit 1
2329
fi
2430

2531
echo ">>>> Set the Pull Secret"
2632
echo ">>>>>>>>>>>>>>>>>>>>>>>>"
2733

28-
echo $OC_AMORGANT_PULL_SECRET | tr -d [:space:] | sed -e 's/^.//' -e 's/.$//' > ./openshift_pull.json
29-
34+
echo $OC_AMORGANT_PULL_SECRET | tr -d [:space:] | sed -e 's/^.//' -e 's/.$//' >./openshift_pull.json
3035

3136
echo ">>>> kcli create plan"
3237
echo ">>>>>>>>>>>>>>>>>>>>>"
3338

34-
3539
if [ "$OC_DEPLOY_METAL" = "yes" ]; then
36-
if [ "$OC_NET_CLASS" = "ipv4" ]; then
37-
if [ "$OC_TYPE_ENV" = "connected" ] ; then
40+
if [ "$OC_NET_CLASS" = "ipv4" ]; then
41+
if [ "$OC_TYPE_ENV" = "connected" ]; then
3842
echo "Metal3 + Ipv4 + connected"
3943
t=$(echo "$OC_RELEASE" | awk -F: '{print $2}')
4044
kcli create network --nodhcp --domain kubeframe -c 192.168.7.0/24 kubeframe
4145
kcli create plan --force --paramfile=lab-metal3.yml -P disconnected="false" -P version="$VERSION" -P tag="$t" -P openshift_image="$OC_RELEASE" -P cluster="$OC_CLUSTER_NAME" "$OC_CLUSTER_NAME"
42-
kcli create plan -k -f create-vm.yml -P clusters="$CLUSTERS" "$OC_CLUSTER_NAME"
46+
kcli create plan -k -f create-vm.yml -P clusters="$CLUSTERS" "$OC_CLUSTER_NAME"
4347

4448
else
4549
echo "Metal3 + ipv4 + disconnected"
@@ -53,19 +57,41 @@ if [ "$OC_DEPLOY_METAL" = "yes" ]; then
5357

5458
fi
5559
else
56-
echo "Without Metal3 + ipv4 + connected"
57-
kcli create kube openshift --force --paramfile lab-withoutMetal3.yml -P tag="$OC_RELEASE" -P cluster="$OC_CLUSTER_NAME" "$OC_CLUSTER_NAME"
60+
echo "Without Metal3 + ipv4 + connected"
61+
kcli create kube openshift --force --paramfile lab-withoutMetal3.yml -P tag="$OC_RELEASE" -P cluster="$OC_CLUSTER_NAME" "$OC_CLUSTER_NAME"
5862
fi
5963

60-
IP=$(kcli info vm test-ci-installer|grep ip|awk '{print $2}')
61-
SPOKE1_0=$(kcli info vm spoke1-m0|grep id|awk '{print $2}')
62-
SPOKE1_1=$(kcli info vm spoke1-m1|grep id|awk '{print $2}')
63-
SPOKE1_2=$(kcli info vm spoke1-m2|grep id|awk '{print $2}')
64+
# Spokes.yaml file generation
65+
66+
#Empty file before we start
67+
68+
>spokes.yaml
69+
70+
CHANGE_IP=$(kcli info vm test-ci-installer | grep ip | awk '{print $2}')
71+
72+
for spoke in $(seq 0 $((CLUSTERS - 1))); do
73+
cat <<EOF >>spokes.yaml
74+
- spoke$spoke-cluster:
75+
EOF
76+
for master in 0 1 2; do
77+
# Stanza generation for each master
78+
MASTER=$(kcli info vm spoke${spoke}-m${master} | grep id | awk '{print $2}')
79+
cat <<EOF >>spokes.yaml
80+
master${master}:
81+
nic_ext_dhcp: enp1s0
82+
nic_int_static: enp2s0
83+
mac_ext_dhcp: "ee:ee:ee:ee:${master}${spoke}:${master}e"
84+
mac_int_static: "aa:aa:aa:aa:${master}${spoke}:${master}a"
85+
bmc_url: "redfish-virtualmedia+http://$CHANGE_IP:8000/redfish/v1/Systems/$MASTER"
86+
bmc_user: "amorgant"
87+
bmc_pass: "alknopfler"
88+
EOF
89+
done
6490

65-
sed -e "s/CHANGE_IP/$IP/g" -e "s/CHANGE_ID_0/$SPOKE1_0/g" -e "s/CHANGE_ID_1/$SPOKE1_1/g" -e "s/CHANGE_ID_2/$SPOKE1_2/g" ./spokes-orig.yaml > ./spokes.yaml
91+
done
6692

6793
kcli create dns -n bare-net httpd-server.apps.test-ci.alklabs.com -i 192.168.150.252
6894
kcli create dns -n bare-net kubeframe-registry-kubeframe-registry.apps.test-ci.alklabs.com -i 192.168.150.252
6995

7096
echo ">>>> EOF"
71-
echo ">>>>>>>>"
97+
echo ">>>>>>>>"

hack/deploy-hub-local/create-vm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ spoke{{ i }}-m{{ j }}:
1010
numcpus: 8
1111
nets:
1212
- name: bare-net
13-
mac: ee:ee:ee:ee:ee:{{ j }}e
13+
mac: ee:ee:ee:ee:{{ j }}{{ i }}:{{ j }}e
1414
- name: kubeframe
1515
nic: enp2s0
16-
mac: aa:aa:aa:aa:aa:{{ j }}a
16+
mac: aa:aa:aa:aa:{{ j }}{{ i }}:{{ j }}a
1717
disks:
1818
- size: 200
1919
- size: 200

hack/deploy-hub-local/spokes-orig.yaml

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)