From febce342b734b48a4419a201ab44232e0287ed28 Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Mon, 27 Jun 2022 16:55:44 -0600 Subject: [PATCH] manifest: inline toolbox script for direct use of ceph image The toolbox is really only used for ceph commands. The main reason the rook image was being used in the toolbox pod was for the script that generates the ceph.conf and updates it whenever the mons are updated during mon failover. Now the ceph image can be specified directly by moving the script inline with the container definition instead of being required in the image. The rook image will still contain the script for backward compatibility and for scenarios where the rook binary may still be needed Signed-off-by: Travis Nielsen --- .commitlintrc.json | 1 + PendingReleaseNotes.md | 2 ++ deploy/examples/toolbox.yaml | 64 ++++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/.commitlintrc.json b/.commitlintrc.json index c1051439d..572f86773 100644 --- a/.commitlintrc.json +++ b/.commitlintrc.json @@ -18,6 +18,7 @@ "external", "file", "helm", + "manifest", "mds", "mgr", "mon", diff --git a/PendingReleaseNotes.md b/PendingReleaseNotes.md index c49e3b660..6819c0a8b 100644 --- a/PendingReleaseNotes.md +++ b/PendingReleaseNotes.md @@ -4,3 +4,5 @@ ## Features + +- The toolbox pod now uses the Ceph image directly instead of the Rook image diff --git a/deploy/examples/toolbox.yaml b/deploy/examples/toolbox.yaml index 2fc71853f..6d4f2cf26 100644 --- a/deploy/examples/toolbox.yaml +++ b/deploy/examples/toolbox.yaml @@ -18,9 +18,67 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: rook-ceph-tools - image: rook/ceph:master - command: ["/bin/bash"] - args: ["-m", "-c", "/usr/local/bin/toolbox.sh"] + image: quay.io/ceph/ceph:v17.2.1 + command: + - /bin/bash + - -c + - | + # Replicate the script from toolbox.sh inline so the ceph image + # can be run directly, instead of requiring the rook toolbox + CEPH_CONFIG="/etc/ceph/ceph.conf" + MON_CONFIG="/etc/rook/mon-endpoints" + KEYRING_FILE="/etc/ceph/keyring" + + # create a ceph config file in its default location so ceph/rados tools can be used + # without specifying any arguments + write_endpoints() { + endpoints=$(cat ${MON_CONFIG}) + + # filter out the mon names + # external cluster can have numbers or hyphens in mon names, handling them in regex + # shellcheck disable=SC2001 + mon_endpoints=$(echo "${endpoints}"| sed 's/[a-z0-9_-]\+=//g') + + DATE=$(date) + echo "$DATE writing mon endpoints to ${CEPH_CONFIG}: ${endpoints}" + cat < ${CEPH_CONFIG} + [global] + mon_host = ${mon_endpoints} + + [client.admin] + keyring = ${KEYRING_FILE} + EOF + } + + # watch the endpoints config file and update if the mon endpoints ever change + watch_endpoints() { + # get the timestamp for the target of the soft link + real_path=$(realpath ${MON_CONFIG}) + initial_time=$(stat -c %Z "${real_path}") + while true; do + real_path=$(realpath ${MON_CONFIG}) + latest_time=$(stat -c %Z "${real_path}") + + if [[ "${latest_time}" != "${initial_time}" ]]; then + write_endpoints + initial_time=${latest_time} + fi + + sleep 10 + done + } + + # create the keyring file + cat < ${KEYRING_FILE} + [${ROOK_CEPH_USERNAME}] + key = ${ROOK_CEPH_SECRET} + EOF + + # write the initial config file + write_endpoints + + # continuously update the mon endpoints if they fail over + watch_endpoints imagePullPolicy: IfNotPresent tty: true securityContext: