I have the minikube
environment as the following: –
- Host OS:
CentOS Linux release 7.7.1908 (Core)
- Docker:
Docker Engine - Community 20.10.7
- minikube:
minikube version: v1.20.0
I would like to add some additional host mapping (5+ IP and name) to the /etc/hosts
inside the minikube
container. Then I use the minikube ssh
to enter to the shell and try to echo "172.17.x.x my.some.host" >> /etc/hosts
. There is an error as -bash: /etc/hosts: Permission denied
since the user who login to this shell is a docker
, not a root
.
I also found that at the host machine there is a docker container named minikube
running, by using the docker container ls
. Even I can go to this container with root
by using docker exec -it -u root minikube /bin/bash
. I understand that it is a kind of tweak and may be a bad practice. Especially it is too much tasks.
Regarding to the docker
and docker-compose
which provides the --add-host
and extra_hosts
respectively to add hostname mappings, Does the minikube
provide it? Is there any good practice to achieve this within the minikube
and/or system administrator point-of-view good practice?
Edit 1
After echo 172.17.x.x my.some.host > ~/.minikube/files/etc/hosts
and start the minikube
, there are some error as the following: –
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp: lookup localhost on 8.8.8.8:53: no such host.
Unfortunately, an error has occurred:
timed out waiting for the condition
This error is likely caused by:
- The kubelet is not running
- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
- 'systemctl status kubelet'
- 'journalctl -xeu kubelet'
Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI.
Here is one example how you may list all Kubernetes containers running in docker:
- 'docker ps -a | grep kube | grep -v pause'
Once you have found the failing container, you can inspect its logs with:
- 'docker logs CONTAINERID'
Then I use the vi
to create a whole hosts
file at ~/.minikube/files/etc/hosts
as the following: –
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.x.x my.some.host1
172.17.x.y my.some.host2
...
At this time the minikube
is started properly.
2
Answers
Minikube has a built-in sync mechanism that could deploy a desired /etc/hosts with the following example:
Then go and check if it’s working:
And once you are inside the container:
The built-in synch for /etc/hosts was helpful, but, if you don’t add the entries that Minikube normally does – specifically control-plane.minikube.internal, Minikube will fail to start.