79273757

Date: 2024-12-12 03:37:07
Score: 0.5
Natty:
Report link

This is doable with the ctr tool instead of kubectl on a modern kubernetes cluster (2024+) that uses containerd. You will need to install ctr with apt/yum etc.

First locate the container ID in the list of containers:

ctr c ls

Then once you have the ID, login as root:

ctr -n k8s.io task exec --user 0 --exec-id 0 -t <container id> /bin/sh

Source: https://stackoverflow.com/a/78968332

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Has code block (-0.5):
Posted by: degenerate