From 08cbe10d454421e6e77c6dc807a64af9b10d7b39 Mon Sep 17 00:00:00 2001 From: Ryan Lovett Date: Tue, 1 Oct 2024 16:16:23 -0700 Subject: [PATCH] Add operations cheatsheet. --- docs/_quarto.yml | 1 + docs/admins/howto/cheatsheet.qmd | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 docs/admins/howto/cheatsheet.qmd diff --git a/docs/_quarto.yml b/docs/_quarto.yml index b950a8b95..04930cc37 100644 --- a/docs/_quarto.yml +++ b/docs/_quarto.yml @@ -61,6 +61,7 @@ website: - admins/howto/clusterswitch.qmd - admins/howto/github-token.qmd - admins/howto/google-sheets.qmd + - admins/howto/cheatsheet.qmd - section: "Policy" contents: - policy/create_policy.qmd diff --git a/docs/admins/howto/cheatsheet.qmd b/docs/admins/howto/cheatsheet.qmd new file mode 100644 index 000000000..551a2d310 --- /dev/null +++ b/docs/admins/howto/cheatsheet.qmd @@ -0,0 +1,27 @@ +--- +title: Operations Cheatsheet +--- + +We periodically need to perform various tasks that can be quickly described by short shell fragments. This page is meant to be a dumping ground for them. It may be useful on occasion to move such fragments into more relevant pages. + +## Get Root Access in a User Pod + +In this fragment, `local$` conveys operations performed on your own device and `node$` shows operations performed on the cloud node. + +```bash +local$ pod=jupyter-username +local$ ns=datahub-prod + +# obtain a display the user's container ID +local$ cid=$(kubectl -n $ns get pod $pod -o jsonpath="{.status.containerStatuses[].containerID}" | sed 's,.*//,,') +local$ echo $cid + +# ssh into the node hosting the user's pod +local$ kubectl -n $ns get pod $pod -o wide +local$ gcloud compute ssh --zone us-central1-b --project ucb-datahub-2018 node_name + +# become root, and exec into the user's container, where `CID_FROM_ABOVE` the +# value of $cid above +node$ sudo -i +node# runc --root /run/containerd/runc/k8s.io/ exec -t -u 0 CID_FROM_ABOVE bash +```