How to share Minikube instance on both Docker for Windows and WSL2? - docker

How to share a Minikube instance amongst Windows/Windows WSL?
In Windows WSL minikube start fails:
πŸ˜„ minikube v1.22.0 on Ubuntu 20.04
✨ Using the docker driver based on existing profile
πŸ‘ Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
πŸƒ Updating the running docker "minikube" container ...
🀦 StartHost failed, but will try again: provision: Temporary Error: NewSession: new client: new client: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
πŸƒ Updating the running docker "minikube" container ...
😿 Failed to start docker container. Running "minikube delete" may fix it: provision: Temporary Error: NewSession: new client: new client: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
❌ Exiting due to IF_SSH_AUTH: Failed to start host: provision: Temporary Error: NewSession: new client: new client: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
πŸ’‘ Suggestion: Your host is failing to route packets to the minikube VM. If you have VPN software, try turning it off or configuring it so that it does not re-route traffic to the VM IP. If not, check your VM environment routing options.
πŸ“˜ Documentation: https://minikube.sigs.k8s.io/docs/handbook/vpn_and_proxy/
🍿 Related issue: https://github.com/kubernetes/minikube/issues/3930
The above works in Windows:
πŸ˜„ minikube v1.17.1 on Microsoft Windows 10 Pro 10.0.19042 Build 19042
πŸŽ‰ minikube 1.22.0 is available! Download it: https://github.com/kubernetes/minikube/releases/tag/v1.22.0
πŸ’‘ To disable this notice, run: 'minikube config set WantUpdateNotification false'
✨ Using the docker driver based on existing profile
πŸ‘ Starting control plane node minikube in cluster minikube
πŸƒ Updating the running docker "minikube" container ...
🐳 Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...
πŸ”Ž Verifying Kubernetes components...
🌟 Enabled addons: storage-provisioner, dashboard, default-storageclass
πŸ„ Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
Questions:
Why would it fail on Linux? Note: I originally installed Minikube on Windows.
Is there a way to share the Minikube environment?
Second I want to share one Docker context. docker context ls:
Windows:
Returns:
NAME TYPE DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * moby Current DOCKER_HOST based configuration npipe:////./pipe/docker_engine https://127.0.0.1:53873 (default) swarm
desktop-linux moby npipe:////./pipe/dockerDesktopLinuxEngine
Windows WSL (Ubuntu):
docker context ls
NAME TYPE DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * moby Current DOCKER_HOST based configuration unix:///var/run/docker.sock https://127.0.0.1:51967 (default) swarm
desktop-linux moby
Questions:
What is default?
What is desktop-linux?
Which one is recommended to fully utilize the performance boost of WSL?
Third I want to share one Kubernetes context. kubectl config get-contexts:
Windows:
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
docker-desktop docker-desktop docker-desktop
kubernetes/REDACTED kubernetes REDACTED
* minikube minikube minikube default
Windows WSL (Ubuntu):
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
docker-desktop docker-desktop docker-desktop
* minikube minikube minikube
Questions:
What is docker-desktop?
Can I safely delete docker-desktop?

I was able to synchronize both Windows/WSL by copying the configuration files:
mkdir ~/.kube \ && cp /mnt/c/Users/[USERNAME]/.kube/config ~/.kube
kubectl config use-context docker-for-desktop # Select the Windows context
kubectl cluster-info # Check if it works## Heading ##
Ref: https://devkimchi.com/2018/06/05/running-kubernetes-on-wsl/

Related

MiniKube status

I am new to kubernetes and I am from .Net back ground. Windows 10 edition Home OS and I have installed Docker for Desktop in my machine along with Minikube and Kubectl. When I run minikube status command , I get the following message.
****! Executing "docker container inspect minikube --format={{.State.Status}}" took an unusually long time: 3.2301512s
Restarting the docker service may improve performance.****
minikube.
type: Control Plane.
host: Running.
kubelet: Running.
apiserver: Running.
kubeconfig: Configured.
I see the same error when I try the command minikube service

How to ssh mini-kube or docker-desktop?

I want to ssh minikube/docker-desktop, but I cant. How can i do that?
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
minikube Ready control-plane,master 4m47s v1.20.2 192.168.49.2 <none> Ubuntu 20.04.2 LTS 4.19.121-linuxkit docker://20.10.6
ssh minikube
ssh: Could not resolve hostname minikube: nodename nor servname provided, or not known
I am learning K8s and able to ssh while working on K8s hands-on labs available online. I'd like t test some stuff on my local environment.
minikube is the node name within the Kubernetes API, not a hostname in this case. Minikube offers a wrapper minikube ssh command to automate pulling the IP and whatnot. Docker Desktop does not offer an official way to get a shell in the VM as it's a single-purpose appliance and they want it in a known state, but you can fake it by running a super-superuser container like docker run -it --rm --privileged --pid=host justincormack/nsenter1 to break out into the host namespaces.

Can't connect Docker CLI to local Docker Daemon

I downloaded minikube after that ...
I did minikube start... so, node started
I played around with some containers(deployment object)
Now when I am doing docker ps => it's showing all the k8's container running -_-"
What I wanted to see is the local Docker Daemon containers rather than Vm's containers
When I run minikube docker-env it shows:
Exiting due to ENV_DRIVER_CONFLICT: 'none' driver does not support 'minikube docker-env' command
What should I do now to connect to local Docker Daemon ?
I am using Ubuntu 18 :)
Since you started minikube without specifying driver, the host docker daemon will be used, so you can access it without any special environment variables. That’s why you see β€œ Exiting due to ENV_DRIVER_CONFLICT: 'none' driver does not support 'minikube docker-env' command”
Try starting minikube using other driver viz minikube start --driver=hyperkit
or stopping minkikube

Exiting due to GUEST_MOUNT_CONFLICT : While starting minikube

I am trying to use kubernetes for local deployment using minikube, I want to mount a share a directory between host machine and pods. For this, I am trying to mount directory to minikube. But I already had minikube running on which few deployments were running. I deleted them. But every time I restart minikube with mount I get following error
$ minikube start --mount-string="/var/log:/log" --mount
* minikube v1.14.2 on Ubuntu 18.04
* Using the docker driver based on existing profile
* Starting control plane node minikube in cluster minikube
* Restarting existing docker container for "minikube" ...
X Exiting due to GUEST_MOUNT_CONFLICT: Sorry, docker does not allow mounts to be changed after container creation (previous mount: '', new mount: '/var/log:/log)'
Output for kubectl get all is
kubectl get all
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2s
What am I doing wrong here. I need to mount /var/log:/log in my pods just like docker
You will have to delete the minikube container first using minikube delete , after that recreate the container with the new mount path minikube start --mount-string="/var/log:/log" --mount
Check this Github Issue for more details
You can try
$ minikube mount /Users/user/dir:/opt/dir
$ minikube ssh
$ ls /opt/dir # this should be mounted within minikube VM
and start minikube initially without any flags
$ minikube start
The error you see happens when you try to change the mount configuration on an existing cluster when using Docker. Docker doesn't allow changing of volumes after the container has been created and thus you cannot change the mount-string on minikube start after the cluster has already been created. More info and source for this behavior can be found here and here.

Unable to start container using kubectl

I am learning kubernetes and using minikube to create single node cluster in my ubuntu machine. In my ubuntu machine Oracle Virtualbox is also installed. As I run
$ minikube start
Starting local Kubernetes v1.6.4 cluster...
...
$ cat ~/.kube/config
apiVersion: v1
clusters:
- cluster:
certificate-authority: /root/.minikube/ca.crt
server: https://192.168.99.100:8443
name: minikube
...
$ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8000
error: failed to discover supported resources: Get https://192.168.99.100:8443/api: Service Unavailable
I am not getting that what is causing this error. Is there some place we can check for logs. I cannot use kubectl logs as it requires container to mention which is not creating at all. Please provide any possible solution to problem.
You can debug using these steps:
kubectl talks to kube-apiserver at port 8443 to do its thing. Try curl -k https://192.168.99.100:8443 and see if there's a positive response. If this fails, it means kube-apiserver isn't running at all. You can try restarting the VM or rebuilding minikube to see if it comes up properly the 2nd time round.
You can also debug the VM directly if you feel brave. In this case, get a shell on the VM spun up by minikube. Run docker ps | grep apiserver to check if the kube-apiserver pod is running. Also try ps aux | grep apiserver to check if it's run natively. If both don't turn up results, check the logs using journalctl -xef.

Resources