equivalent of "minikube ssh" with docker-for-desktop Kubernetes node

3/27/2019

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?

-- Stephen
docker
kubernetes

1 Answer

3/27/2019

Update:

If the node were created by docker-machine using VirtualBox, would be similar to minikube, with the command:

docker-machine ssh default

If you are using the default HyperKit driver for MAC, there isn't an VM like VirtualBox, but you should be able to open the shell with following command:

screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty

Original:

If you have direct access to the node and the certificate, it is as simple as a command like this:

ssh -i certificatename 10.0.0.1

or

ssh -i certificatename docker@10.0.0.1

take a look into this post.

If you are running Kubernetes in a cloud provider, you should use the provider tools to do that.

An example is the Google Cloud you would use:

gcloud compute ssh <NODE_NAME> --zone <ZONE>

Azure and Aws also have similar options, you can also use their portal for it.

Other alternative, is using a bastian\helper container in the cluster to connect to the nodes without setting up network permissions, it works on cloud or on premises clusters.

Something like:

kubectl run -it --rm aks-ssh --image=debian

This will run a container with bash, then you have to install the ssh client apt-get update && apt-get install openssh-client -y copy the client certificate to the container and ssh into the node like ssh -i id_rsa azureuser@10.240.0.4.

There is a nice example in the AKS docs

-- Diego Mendes
Source: StackOverflow