Skip to content

Instantly share code, notes, and snippets.

@dlbewley
Last active April 6, 2023 22:32
Show Gist options
  • Save dlbewley/ba5686b47e915d5ac7ebd37f400759b0 to your computer and use it in GitHub Desktop.
Save dlbewley/ba5686b47e915d5ac7ebd37f400759b0 to your computer and use it in GitHub Desktop.
How to run Ceph commands in OpenShift Container Storage OCS / ODF
#!/bin/bash
if [ "$1" == "off" ]; then
oc patch OCSInitialization/ocsinit -n openshift-storage \
--type=merge -p='{"spec":{ "enableCephTools": false}}'
sleep 3
echo "removing any existing toolbox pod"
oc delete pods -n openshift-storage -l app=rook-ceph-tools
else
oc patch OCSInitialization/ocsinit -n openshift-storage \
--type=merge -p='{"spec":{ "enableCephTools": true}}'
TOOLS_POD=""
echo -n "waiting for ceph tools pod to schedule "
until [ -n "$TOOLS_POD" ]; do
echo -n "."
sleep 5
TOOLS_POD=$(oc get pod -n openshift-storage -l app=rook-ceph-tools -o name)
done
echo "$TOOLS_POD"
echo "waiting for ceph tools pod to startup"
oc wait $TOOLS_POD --for=condition=Ready --timeout=300s -n openshift-storage
echo "connecting to ceph toolbox"
oc rsh -n openshift-storage $TOOLS_POD
fi

Ceph Toolbox is not recommended or supported for use with OpenShift Data Foundation, but never the less, sometimes you need a client to troubleshoot with.

$ ./ceph-toolbox.sh
ocsinitialization.ocs.openshift.io/ocsinit patched
waiting for ceph tools pod to schedule .........pod/rook-ceph-tools-565ffdb78c-sf2bf
waiting for ceph tools pod to startup
pod/rook-ceph-tools-565ffdb78c-sf2bf condition met
sh-4.4$
sh-4.4$ ceph osd status
ID  HOST                      USED  AVAIL  WR OPS  WR DATA  RD OPS  RD DATA  STATE
 0  hub-q4jtr-store-1-5nlkv   299G   724G      1      135k      1        0   exists,up
 1  hub-q4jtr-store-2-652pc   299G   724G      0     18.3k      3      105   exists,up
 2  hub-q4jtr-store-3-mtddc   299G   724G      2     18.4k      2      241   exists,up

Here are a couple of troubleshooting commands to get you started.

ceph status
ceph osd status
ceph osd pool ls
ceph df
rados df

Afterwards turn off the toolbox by running ./ceph-toolbox off and deleting the pod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment