I am using Docker for Mac but currently only using it for its Kubernetes cluster. The Kubernetes cluster's single node is named docker-for-desktop.
I'm currently going through a Kubernetes tutorial on Persistent Volumes (https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/) and as part of that, I'm setting up a hostPath persistent volume. It seems like the way this works is, you create a path on the Kubernetes Node itself and you can use that as your persistent volume for development and testing purposes.
To do that, the tutorial instructs you to SSH into your Kubernetes node itself and create a path which can then be turned into a persistent volume. The only problem is, I have no idea how to SSH directly into the Kubernetes node itself (not a container). The equivalent for minikube would just be minikube ssh
. I can kubectl describe
the node, but I only get an internal IP address, not an external one. So I have no idea how to address it in an ssh
command.
Any ideas?
Comment in the OP should get credit for this but i'll add again so i find it easier in a few months:
docker run -it --rm --privileged --pid=host justincormack/nsenter1
From https://github.com/justincormack/nsenter1/blob/master/README.md
... this is useful when you are running a lightweight, container-optimized Linux distribution such as LinuxKit... you are demonstrating with Docker for Mac, for example, your containers are not running on your host directly, but are running instead inside of a minimal Linux OS virtual machine specially built for running containers, i.e., LinuxKit. But being a lightweight environment, LinuxKit isn't running sshd, so how do you get access to a shell so you can run nsenter to inspect the namespaces for the process running as pid 1?
I was looking for an answer when running k8s on Docker Desktop, then I tried docker ps
and to my surprise, the containers of my pod was there.
So I just ssh like you would with any docker container
$ docker exec -it 0b83055dac1b /bin/bash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With