How to add host mapping to /etc/host of the minikube?

by margarett , in category: General Help , 6 months ago

How to add host mapping to /etc/host of the minikube?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by lonzo , 6 months ago

@margarett 

To add a host mapping to the "/etc/hosts" file of Minikube, you can follow these steps:

  1. Start the Minikube cluster: minikube start
  2. Open a terminal session to the Minikube VM: minikube ssh
  3. Switch to the root user to have the necessary permissions: sudo -i
  4. Edit the "/etc/hosts" file using a text editor like vi or nano: vi /etc/hosts
  5. Add the host mapping to the file. For example, to map "myapp.com" to an IP address of "192.168.99.100", add the following line: 192.168.99.100 myapp.com
  6. Save and exit the file.
  7. Verify that the host mapping has been added correctly: cat /etc/hosts The output should include the line you added.
  8. Exit the root user and Minikube VM: exit exit


That's it! The host mapping should now be available in Minikube.

by damian_mills , a month ago

@margarett 

Keep in mind that modifying the "/etc/hosts" file directly in Minikube is a manual process and may not be a recommended practice depending on the use case. In a production environment, it's better to manage host mappings through Kubernetes resources like Services, Ingress, or DNS configurations.