Exiting due to GUEST_MOUNT_CONFLICT : While starting minikube - docker

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.

Related

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

Getting ErrImagePull when trying to use Local Docker Registry with Kubernetes

First I create a local Docker registry...
docker run -d -p 5000:5000 --restart=always --name registry registry:2
Then I push
docker push localhost:5000/jrg/hello-k8s
I confirm it is there by
$ docker pull localhost:5000/jrg/hello-k8s
Using default tag: latest
latest: Pulling from jrg/hello-k8s
Digest: sha256:c475cb7167208e8f018e54ad81d4b7bbbb9c14875bc1624bcce730edf9afede0
Status: Image is up to date for localhost:5000/jrg/hello-k8s:latest
Then I start Minikube
minikube start --insecure-registry=localhost:5000
But when I run
kubectl create deployment hello-k8s --image=localhost:5000/jrg/hello-k8s
I get
NAME READY STATUS RESTARTS AGE
hello-k8s-75846c4bfc-b7zp7 0/1 ErrImagePull 0 4s
What am I missing?
Update
I also tried (assuming 5.5.5.5 is the IP address for my wireless adapter (confirmed by accessing in the browser).
Then I start Minikube
minikube start --insecure-registry=5.5.5.5:5000
But when I run
kubectl create deployment hello-k8s --image=5.5.5.5:5000/jrg/hello-k8s
But I still get the same issue, also after a while it appears to become ImagePullBackOff
FYI Project (https://github.com/jrgleason/hello-kubernetes/tree/ADD_CASSANDRA)
I think the issue is localhost will reference the kubernetes host itself, and not your registry.
You need to make it so that the registry is accessible from inside minikube. Try using the ip address of your computer instead of localhost.
There is a proxy addon for minikube that will allow you to access localhost from within minikube. I would suggest setting this up as the simplest solution https://github.com/Faithlife/minikube-registry-proxy
If this doesn't work there is a guide here to setup minikube with a local registry https://blog.hasura.io/sharing-a-local-registry-for-minikube-37c7240d0615/
If you are using minikube you must start the docker registry on the minikube machine.
You can either use the minikube registry addon, or use docker yourself. Make sure to use the docker daemon from the minikube host:
eval $(minikube docker-env)
You must push the image to the right registry then, f.e. by using the remote docker daemon for building and pushing to 'localhost' (which is the minikube VM in that case)

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.

networking options for a docker image in minikube

I have a docker image (usermanagement:latest) from which I normally create containers this way when I'm testing locally:
docker run --net "host" -p 8096:8096 -v $(pwd):/etc usermanagement:latest -port 8096 -configfile /etc/config
Both port and configfile has default values and port's default value is 8096.
I can then simply reach it at localhost:8096/1/users/some_api. This gives me the flexibility of being able to create many containers of the same image listening to different ports.
Now, I've pushed this image into a private registry and want to use minikube which also has access to the registry (all good and fine).
Problem is I can't figure out how to specify networking options (--net or -p) or even volume option (-v) when creating a Kubernetes deployment.
I tried:
kubectl run usr --image=$REGISTRY_IP:80/usermanagement:latest --port=8096
kubectl expose deployment usr --target-port=8096 --type=NodePort
Where REGISTRY_IP is the IP of the private registry from which the image has already been pulled into the minikube's docker.
I've verified the service is created and exposed, but I can't reach (getting 404) the container in minikube using:
curl -v http://192.168.42.149:31900/1/users/some_api
Service's IP and port above came from:
kubectl get svc usr
minikube ip
Any help is appreciated.

Resources