Skip to content

Commit 46b82ed

Browse files
committed
mgr/dashboard: adapt kcli plan for multi-clusters
to start multiple clusters we can simply do ``` ./quick-bootstrap.sh -dir=/home/nia/projects/ceph -u -e -n=2 -c=2 -c = number of clusters -n = number of nodes per cluster ``` Signed-off-by: Nizamudeen A <[email protected]>
1 parent 6cc5292 commit 46b82ed

File tree

5 files changed

+67
-31
lines changed

5 files changed

+67
-31
lines changed

src/pybind/mgr/dashboard/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ coverage.xml
55
junit*xml
66
.cache
77
ceph.conf
8+
ceph_image.tar
89

910
# IDE
1011
.vscode

src/pybind/mgr/dashboard/ci/cephadm/bootstrap-cluster.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ quick_install_options=''
2828
quick_install_options="--image localhost:5000/ceph"
2929
{% endif %}
3030

31-
{% if nodes < 3 %}
31+
if [[ ${NODES} -lt 2 ]]; then
3232
bootstrap_extra_options+=" --config /root/initial-ceph.conf"
33+
fi
34+
35+
{% if prefix is not defined %}
36+
PREFIX="ceph"
37+
{% else %}
38+
PREFIX="{{ prefix }}"
3339
{% endif %}
3440

3541
{% if ceph_dev_folder is defined %}
@@ -41,13 +47,13 @@ $CEPHADM ${quick_install_options} bootstrap --mon-ip $mon_ip --initial-dashboard
4147
fsid=$(cat /etc/ceph/ceph.conf | grep fsid | awk '{ print $3}')
4248
cephadm_shell="$CEPHADM shell --fsid ${fsid} -c /etc/ceph/ceph.conf -k /etc/ceph/ceph.client.admin.keyring"
4349

44-
45-
{% for number in range(1, nodes) %}
46-
ssh-copy-id -f -i /etc/ceph/ceph.pub -o StrictHostKeyChecking=no [email protected].10{{ number }}
50+
for number in $(seq 1 $((NODES - 1))); do
51+
LAST_OCTET=$((NODE_IP_OFFSET + $number))
52+
ssh-copy-id -f -i /etc/ceph/ceph.pub -o StrictHostKeyChecking=no [email protected].${LAST_OCTET}
4753
{% if expanded_cluster is defined %}
48-
${cephadm_shell} ceph orch host add {{ prefix }}-node-0{{ number }} 192.168.100.10{{ number }}
54+
${cephadm_shell} ceph orch host add ${PREFIX}-node-0${number} 192.168.100.${LAST_OCTET}
4955
{% endif %}
50-
{% endfor %}
56+
done
5157

5258
{% if expanded_cluster is defined %}
5359
${cephadm_shell} ceph orch apply osd --all-available-devices

src/pybind/mgr/dashboard/ci/cephadm/ceph_cluster.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
parameters:
2-
nodes: 4
3-
node_ip_offset: 100
42
pool: ceph-dashboard
53
network: ceph-dashboard
64
gateway: 192.168.100.1
75
netmask: 255.255.255.0
8-
prefix: ceph
96
numcpus: 1
107
memory: 2048
118
image: fedora40
@@ -16,6 +13,10 @@ parameters:
1613
- 5
1714
- 5
1815

16+
{% set nodes = (nodes | default(4)) | int %}
17+
{% set node_ip_offset = node_ip_offset | default(100) %}
18+
{% set prefix = prefix | default('ceph') %}
19+
1920
{% for number in range(0, nodes) %}
2021
{{ prefix }}-node-0{{ number }}:
2122
image: {{ image }}
@@ -49,6 +50,7 @@ parameters:
4950
- sed -i "s/SELINUX=enforcing/SELINUX=permissive/" /etc/selinux/config
5051
- setenforce 0
5152
{% if number == 0 %}
53+
- export NODES={{nodes}} && export NODE_IP_OFFSET={{node_ip_offset}}
5254
- bash /root/bootstrap-cluster.sh
5355
{% endif %}
5456
{% endfor %}

src/pybind/mgr/dashboard/ci/cephadm/load-podman-image.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env bash
22

3+
PODMAN_IMG_LOC="/mnt/{{ ceph_dev_folder }}/src/pybind/mgr/dashboard/ci/cephadm/ceph_image.tar"
34
echo -e "[registries.insecure]\n\
45
registries = ['localhost:5000']" | sudo tee /etc/containers/registries.conf
56

67
podman run -d -p 5000:5000 --name my-registry registry:2
78
# Load the image and capture the output
8-
output=$(podman load -i /root/ceph_image.tar)
9+
output=$(podman load -i "${PODMAN_IMG_LOC}")
910

1011
# Extract image name from output
1112
image_name=$(echo "$output" | grep -oP '(?<=^Loaded image: ).*')
@@ -20,4 +21,3 @@ else
2021
fi
2122

2223
podman push localhost:5000/ceph
23-
rm -f /root/ceph_image.tar

src/pybind/mgr/dashboard/ci/cephadm/quick-bootstrap.sh

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ show_help() {
1111
echo " -u, --use-cached-image Uses the existing podman image in local. Only use this if there is such an image present."
1212
echo " -dir, --ceph-dir Use this to provide the local ceph directory. eg. --ceph-dir=/path/to/ceph"
1313
echo " -e, --expanded-cluster To add all the hosts and deploy OSDs on top of it."
14+
echo " -c, --clusters Number of clusters to be created. Default is 1."
15+
echo " -n, --nodes Number of nodes to be created per cluster. Default is 3."
1416
echo " -h, --help Display this help message."
1517
echo ""
1618
echo "Example:"
1719
echo " ./quick-bootstrap.sh --use-cached-image"
1820
}
1921

22+
GREEN='\033[0;32m'
23+
RESET='\033[0m'
24+
2025
use_cached_image=false
2126
extra_args="-P quick_install=True"
27+
CLUSTERS=1
28+
NODES=3
2229

2330
for arg in "$@"; do
2431
case "$arg" in
@@ -31,6 +38,12 @@ for arg in "$@"; do
3138
-e|--expanded-cluster)
3239
extra_args+=" -P expanded_cluster=True"
3340
;;
41+
-n=*|--nodes=*)
42+
NODES="${arg#*=}"
43+
;;
44+
-c=*|--clusters=*)
45+
CLUSTERS="${arg#*=}"
46+
;;
3447
-h|--help)
3548
show_help
3649
exit 0
@@ -44,8 +57,8 @@ for arg in "$@"; do
4457
done
4558

4659
image_name=$(echo "$CEPHADM_IMAGE")
47-
ceph_cluster_yml='ceph_cluster.yml'
48-
node_count=$(awk '/nodes:/ {print $2}' "${ceph_cluster_yml}")
60+
61+
extra_args+=" -P nodes=${NODES}"
4962

5063
if [[ ${use_cached_image} == false ]]; then
5164
printf "Pulling the image: %s\n" "$image_name"
@@ -57,30 +70,44 @@ rm -f ceph_image.tar
5770
printf "Saving the image: %s\n" "$image_name"
5871
podman save -o ceph_image.tar quay.ceph.io/ceph-ci/ceph:main
5972

60-
printf "Creating the plan\n"
61-
kcli create plan -f ceph_cluster.yml ${extra_args} ceph
73+
NODE_IP_OFFSET=100
74+
PREFIX="ceph"
75+
for cluster in $(seq 1 $CLUSTERS); do
76+
if [[ $cluster -gt 1 ]]; then
77+
PREFIX="ceph${cluster}"
78+
fi
79+
printf "\nCreating cluster: %s\n" "${PREFIX}"
80+
kcli create plan -f ceph_cluster.yml ${extra_args} -P node_ip_offset=${NODE_IP_OFFSET} \
81+
-P prefix=${PREFIX} ${PREFIX}
82+
NODE_IP_OFFSET=$((NODE_IP_OFFSET + 10))
83+
done
6284

6385
attempt=0
6486

6587
MAX_ATTEMPTS=10
6688
SLEEP_INTERVAL=5
6789

68-
printf "Waiting for the host to be reachable\n"
69-
while [[ ${attempt} -lt ${MAX_ATTEMPTS} ]]; do
70-
if ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=10 [email protected] exit; then
71-
break
72-
else
73-
echo "Waiting for ssh connection to be available..., attempt: ${attempt}"
74-
((attempt++))
75-
sleep ${SLEEP_INTERVAL}
76-
fi
90+
NODE_IP_OFFSET=100
91+
PREFIX="ceph"
92+
for cluster in $(seq 1 $CLUSTERS); do
93+
if [[ $cluster -gt 1 ]]; then
94+
PREFIX="ceph${cluster}"
95+
fi
96+
printf "\nWaiting for the host to be reachable on cluster ${PREFIX}...\n"
97+
98+
while [[ ${attempt} -lt ${MAX_ATTEMPTS} ]]; do
99+
if ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=10 [email protected]."${NODE_IP_OFFSET}" exit; then
100+
printf "\n${GREEN}Host is reachable on cluster %s\n${RESET}" "${PREFIX}"
101+
break
102+
else
103+
echo "Waiting for ssh connection to be available..., attempt: ${attempt}"
104+
((attempt++))
105+
sleep ${SLEEP_INTERVAL}
106+
fi
107+
done
108+
109+
NODE_IP_OFFSET=$((NODE_IP_OFFSET + 10))
77110
done
78111

79-
printf "Copying the image to the hosts\n"
80-
81-
for node in $(seq 0 $((node_count - 1))); do
82-
scp -o StrictHostKeyChecking=no ceph_image.tar [email protected]"${node}":/root/
83-
done
84-
85-
rm -f ceph_image.tar
112+
printf "\nOpening logs for first cluster"
86113
kcli ssh -u root -- ceph-node-00 'journalctl -n all -ft cloud-init'

0 commit comments

Comments
 (0)