Skip to content

Commit

Permalink
Add operations cheatsheet.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlovett committed Oct 1, 2024
1 parent 9490a34 commit 08cbe10
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions docs/admins/howto/cheatsheet.qmd
Original file line number Diff line number Diff line change
@@ -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
```

0 comments on commit 08cbe10

Please sign in to comment.