We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

DNS

Now that we've configured the Gateway to route the domains:

  • synchat.internal to the web-service
  • synchatapi.internal to the api-service

We need to configure our local machine to resolve those domains to the Gateway load balancer. We won't be setting up global DNS so that anyone on the internet can access our app! We'll just be configuring our local machine to resolve those domains to the Gateway load balancer.

Assignment

There is a file called /etc/hosts on your local machine that is used to resolve domain names to IP addresses. We can add entries to that file to resolve our domains to the Gateway load balancer.

First, get the Gateway IP address:

kubectl get gateway app-gateway -o custom-columns="IP:.status.addresses[0].value" --no-headers

If it prints <none>, open a second terminal and run:

minikube tunnel -c

Then run the kubectl get gateway command again.

Open /etc/hosts in your favorite text editor and add the following lines:

<gateway-ip>        synchat.internal
<gateway-ip>        synchatapi.internal

Replace <gateway-ip> with the IP address from the previous command. You'll probably need to provide your password to save the file.

To make sure it's working, run:

ping synchat.internal

You should see something like:

PING synchat.internal (<gateway-ip>): 56 data bytes
64 bytes from <gateway-ip>: icmp_seq=0 ttl=64 time=0.104 ms
64 bytes from <gateway-ip>: icmp_seq=1 ttl=64 time=0.105 ms
64 bytes from <gateway-ip>: icmp_seq=2 ttl=64 time=0.150 ms
...

You can kill the ping with Ctrl+C.

If you get "cannot resolve host", then you did something wrong. Be sure to ping the synchatapi.internal domain as well.

If ping resolves the IP but doesn't get a response, try curl http://synchat.internal instead. Some environments block ICMP (ping) traffic.

WSL

For WSL users, you also need to add the same entries to the Windows hosts file, C:\Windows\System32\drivers\etc\hosts. The WSL path to this file is /mnt/c/Windows/System32/drivers/etc/hosts. Run your terminal as an administrator from the Start menu.

Linux

If the Gateway IP changes later, update your /etc/hosts entries to match it.