Skip to content

Commit 6f5612a

Browse files
committed
mgr/dashboard: improve the kcli bootstrap process
I have a new script added for starting the kcli cluster called quick-bootstrap.sh The goal is to use that script to download the ceph image on local (rather than inside vm) and then copy them over to all the vms that is being spawned by the kcli. This way all the hosts will get the ceph image which will make the deployment loads faster. Another thing I added is to add some dnf.conf to improve parallel_downlaods and get the fastest server to install deps eg: ``` ╰─$ ./quick-bootstrap.sh -h 255 ↵ + set +x Usage: ./quick-bootstrap.sh [OPTIONS] Options: -u, --use-cached-image Uses the existing podman image in local. Only use this if there is such an image present. -dir, --ceph-dir Use this to provide the local ceph directory. eg. --ceph-dir=/path/to/ceph -e, --expanded-cluster To add all the hosts and deploy OSDs on top of it. -h, --help Display this help message. Example: ./quick-bootstrap.sh --use-cached-image ``` ``` ./quick-bootstrap.sh -u --ceph-dir=/home/nia/projects/ceph ``` Signed-off-by: Nizamudeen A <[email protected]>
1 parent 624f695 commit 6f5612a

File tree

7 files changed

+154
-4
lines changed

7 files changed

+154
-4
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,25 @@ bootstrap_extra_options='--allow-fqdn-hostname --dashboard-password-noupdate'
2323
# {% if expanded_cluster is not defined %}
2424
# bootstrap_extra_options+=" ${bootstrap_extra_options_not_expanded}"
2525
# {% endif %}
26+
quick_install_options=''
27+
{% if quick_install is defined %}
28+
quick_install_options="--image localhost:5000/ceph"
29+
{% endif %}
30+
31+
{% if nodes < 3 %}
32+
bootstrap_extra_options+=" --config /root/initial-ceph.conf"
33+
{% endif %}
2634

27-
$CEPHADM bootstrap --mon-ip $mon_ip --initial-dashboard-password {{ admin_password }} --shared_ceph_folder /mnt/{{ ceph_dev_folder }} ${bootstrap_extra_options}
35+
{% if ceph_dev_folder is defined %}
36+
bootstrap_extra_options+=" --shared_ceph_folder /mnt/{{ ceph_dev_folder }}"
37+
{% endif %}
38+
39+
$CEPHADM ${quick_install_options} bootstrap --mon-ip $mon_ip --initial-dashboard-password {{ admin_password }} ${bootstrap_extra_options}
2840

2941
fsid=$(cat /etc/ceph/ceph.conf | grep fsid | awk '{ print $3}')
3042
cephadm_shell="$CEPHADM shell --fsid ${fsid} -c /etc/ceph/ceph.conf -k /etc/ceph/ceph.client.admin.keyring"
3143

44+
3245
{% for number in range(1, nodes) %}
3346
ssh-copy-id -f -i /etc/ceph/ceph.pub -o StrictHostKeyChecking=no [email protected]{{ number }}
3447
{% if expanded_cluster is defined %}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ parameters:
88
prefix: ceph
99
numcpus: 1
1010
memory: 2048
11-
image: fedora36
11+
image: fedora40
1212
notify: false
1313
admin_password: password
1414
disks:
@@ -35,8 +35,17 @@ parameters:
3535
sharedfolders: [{{ ceph_dev_folder }}]
3636
files:
3737
- bootstrap-cluster.sh
38+
- dnf.conf.tpl
39+
- load-podman-image.sh
40+
- initial-ceph.conf
3841
cmds:
42+
# updating the dnf.conf to make the dnf faster
43+
- cp /root/dnf.conf.tpl /etc/dnf/dnf.conf
3944
- dnf -y install python3 chrony lvm2 podman
45+
# setting up an insecure podman registry and then loading the ceph image to all hosts
46+
{% if quick_install is defined %}
47+
- /root/load-podman-image.sh
48+
{% endif %}
4049
- sed -i "s/SELINUX=enforcing/SELINUX=permissive/" /etc/selinux/config
4150
- setenforce 0
4251
{% if number == 0 %}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[main]
2+
fastestmirror=true
3+
max_parallel_downloads=10
4+
metadata_expire=1h
5+
clean_requirements_on_remove=true
6+
assumeyes=true
7+
gpgcheck=1
8+
keepcache=0
9+
plugins=1
10+
installonly_limit=3
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[global]
2+
osd_pool_default_min_size=1
3+
osd_pool_default_size=1
4+
5+
[mon]
6+
mon_allow_pool_size_one=true
7+
mon_allow_pool_delete=true
8+
mon_data_avail_crit=1
9+
mon_data_avail_warn=1
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
echo -e "[registries.insecure]\n\
4+
registries = ['localhost:5000']" | sudo tee /etc/containers/registries.conf
5+
6+
podman run -d -p 5000:5000 --name my-registry registry:2
7+
# Load the image and capture the output
8+
output=$(podman load -i /root/ceph_image.tar)
9+
10+
# Extract image name from output
11+
image_name=$(echo "$output" | grep -oP '(?<=^Loaded image: ).*')
12+
13+
if [[ -n "$image_name" ]]; then
14+
echo "Image loaded: $image_name"
15+
podman tag "$image_name" localhost:5000/ceph
16+
echo "Tagged image as localhost:5000/ceph"
17+
else
18+
echo "Failed to load image or extract image name."
19+
exit 1
20+
fi
21+
22+
podman push localhost:5000/ceph
23+
rm -f /root/ceph_image.tar
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
3+
source bootstrap-cluster.sh > /dev/null 2>&1
4+
5+
set +x
6+
7+
show_help() {
8+
echo "Usage: ./quick-bootstrap.sh [OPTIONS]"
9+
echo ""
10+
echo "Options:"
11+
echo " -u, --use-cached-image Uses the existing podman image in local. Only use this if there is such an image present."
12+
echo " -dir, --ceph-dir Use this to provide the local ceph directory. eg. --ceph-dir=/path/to/ceph"
13+
echo " -e, --expanded-cluster To add all the hosts and deploy OSDs on top of it."
14+
echo " -h, --help Display this help message."
15+
echo ""
16+
echo "Example:"
17+
echo " ./quick-bootstrap.sh --use-cached-image"
18+
}
19+
20+
use_cached_image=false
21+
extra_args="-P quick_install=True"
22+
23+
for arg in "$@"; do
24+
case "$arg" in
25+
-u|--use-cached-image)
26+
use_cached_image=true
27+
;;
28+
-dir=*|--ceph-dir=*)
29+
extra_args+=" -P ceph_dev_folder=${arg#*=}"
30+
;;
31+
-e|--expanded-cluster)
32+
extra_args+=" -P expanded_cluster=True"
33+
;;
34+
-h|--help)
35+
show_help
36+
exit 0
37+
;;
38+
*)
39+
echo "Unknown option: $arg"
40+
show_help
41+
exit 1
42+
;;
43+
esac
44+
done
45+
46+
image_name=$(echo "$CEPHADM_IMAGE")
47+
ceph_cluster_yml='ceph_cluster.yml'
48+
node_count=$(awk '/nodes:/ {print $2}' "${ceph_cluster_yml}")
49+
50+
if [[ ${use_cached_image} == false ]]; then
51+
printf "Pulling the image: %s\n" "$image_name"
52+
podman pull "${image_name}"
53+
fi
54+
55+
rm -f ceph_image.tar
56+
57+
printf "Saving the image: %s\n" "$image_name"
58+
podman save -o ceph_image.tar quay.ceph.io/ceph-ci/ceph:main
59+
60+
printf "Creating the plan\n"
61+
kcli create plan -f ceph_cluster.yml ${extra_args} ceph
62+
63+
attempt=0
64+
65+
MAX_ATTEMPTS=10
66+
SLEEP_INTERVAL=5
67+
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
77+
done
78+
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
86+
kcli ssh -u root -- ceph-node-00 'journalctl -n all -ft cloud-init'

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ fi
5959
npm run build ${FRONTEND_BUILD_OPTS} &
6060

6161
cd ${CEPH_DEV_FOLDER}
62-
: ${VM_IMAGE:='fedora36'}
63-
: ${VM_IMAGE_URL:='https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/36/Cloud/x86_64/images/Fedora-Cloud-Base-36-1.5.x86_64.qcow2'}
62+
: ${VM_IMAGE:='fedora40'}
63+
: ${VM_IMAGE_URL:='https://download.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/x86_64/images/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2'}
6464
kcli download image -p ceph-dashboard -u ${VM_IMAGE_URL} ${VM_IMAGE}
6565
kcli delete plan -y ceph || true
6666
# Compile cephadm locally for the shared_ceph_folder to pick it up

0 commit comments

Comments
 (0)