Skip to content

Commit

Permalink
Merge pull request #6319 from ryanlovett/docs-cheatsheet
Browse files Browse the repository at this point in the history
Add operations cheatsheet.
  • Loading branch information
felder authored Oct 1, 2024
2 parents cede817 + d388344 commit e1ada1d
Show file tree
Hide file tree
Showing 2 changed files with 30 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
29 changes: 29 additions & 0 deletions docs/admins/howto/cheatsheet.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
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

It can be useful to run commands as root in a user's pod to quickly install or reconfigure software. This could be done during the development of a PR to change a user image.

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 and 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, substituting `NODE_NAME`
local$ kubectl -n $ns get pod $pod -o wide
local$ gcloud compute ssh --zone us-central1-b --project ucb-datahub-2018 NODE_NAME

# Exec into the user's container as root, where `CID_FROM_ABOVE` is the
# value of $cid from above
node$ sudo -i
node# runc --root /run/containerd/runc/k8s.io/ exec -t -u 0 CID_FROM_ABOVE bash
```

0 comments on commit e1ada1d

Please sign in to comment.