cleans up the ingress-dns docs
parent
9abb3b5bac
commit
2eb6de818a
|
|
@ -1,33 +1,35 @@
|
||||||
---
|
---
|
||||||
title: "Ingress DNS"
|
title: "Ingress DNS"
|
||||||
linkTitle: "Minikube Ingress DNS"
|
linkTitle: "Ingress DNS"
|
||||||
weight: 1
|
weight: 1
|
||||||
date: 2021-06-03
|
date: 2021-11-08
|
||||||
---
|
---
|
||||||
DNS service for ingress controllers running on your minikube server
|
DNS service for ingress controllers running on your minikube server
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
### Problem
|
### Problem
|
||||||
When running minikube locally you are highly likely to want to run your services on an ingress controller so that you
|
When running minikube locally, you may want to run your services on an ingress controller so that you don't have to use
|
||||||
don't have to use minikube tunnel or NodePorts to access your services. While NodePort might be ok in a lot of
|
minikube tunnel or NodePorts to access your services. While NodePort might be okay in a lot of circumstances, an ingress
|
||||||
circumstances in order to test some features an ingress is necessary. Ingress controllers are great because you can
|
is necessary to test some features. Ingress controllers are great because you can define your entire architecture in
|
||||||
define your entire architecture in something like a helm chart and all your services will be available. There is only
|
something like a helm chart and all your services will be available.
|
||||||
1 problem. That is that your ingress controller works basically off of dns and while running minikube that means that
|
|
||||||
your local dns names like `myservice.test` will have to resolve to `$(minikube ip)` not really a big deal except the
|
However, for minikube, there is an additional challenge. Your ingress controller relies on DNS, so local DNS names like
|
||||||
only real way to do this is to add an entry for every service in your `/etc/hosts` file. This gets messy for obvious
|
`myservice.test` will have to resolve to your `minikube ip`. The only real way to do this is to add an entry for every
|
||||||
reasons. If you have a lot of services running that each have their own dns entry then you have to set those up
|
service in your `/etc/hosts` file. This gets messy for obvious reasons. For each service you are running that each has
|
||||||
manually. Even if you automate it you then need to rely on the host operating system storing configurations instead of
|
its own DNS entry, you will need to configure it manually. Even if you automate it, you then need to rely on the host
|
||||||
storing them in your cluster. To make it worse it has to be constantly maintained and updated as services are added,
|
operating system for storing configurations instead of storing them in your cluster. To make it worse, these
|
||||||
remove, and renamed. I call it the `/etc/hosts` pollution problem.
|
configurations have to be constantly maintained and updated as services are added, remove, and renamed. I call it the
|
||||||
|
`/etc/hosts` pollution problem.
|
||||||
|
|
||||||
### Solution
|
### Solution
|
||||||
What if you could just access your local services magically without having to edit your `/etc/hosts` file? Well now you
|
What if you could just access your local services magically without having to edit your `/etc/hosts` file? Well, now you
|
||||||
can. This addon acts as a DNS service that runs inside your kubernetes cluster. All you have to do is install the
|
can. The `ingress-dns` addon acts as a DNS service that runs inside your Kubernetes cluster. All you have to do is
|
||||||
service and add the `$(minikube ip)` as a DNS server on your host machine. Each time the dns service is queried an
|
install the service and add the `$(minikube ip)` as a DNS server on your host machine. Each time the DNS service is
|
||||||
API call is made to the kubernetes master service for a list of all the ingresses. If a match is found for the name a
|
queried, an API call is made to the Kubernetes master service for a list of all the ingresses. If a match is found for
|
||||||
response is given with an IP address as the `$(minikube ip)`. So for example lets say my minikube ip address is
|
the name, a response is given with an IP address matching `minikube ip`. For example, with a `minikube ip` of
|
||||||
`192.168.99.106` and I have an ingress controller with the name of `myservice.test` then I would get a result like so:
|
`192.168.99.106` and an ingress rule for `myservice.test` configured in the cluster, a DNS query from the host would
|
||||||
|
produce:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
#bash:~$ nslookup myservice.test $(minikube ip)
|
#bash:~$ nslookup myservice.test $(minikube ip)
|
||||||
|
|
@ -41,56 +43,57 @@ Address: 192.168.99.169
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Start minikube
|
<h3 class="step"><span class="fa-stack fa-1x"><i class="fa fa-circle fa-stack-2x"></i><strong class="fa-stack-1x text-primary">1</strong></span>Start minikube</h2>
|
||||||
```
|
|
||||||
|
```bash
|
||||||
minikube start
|
minikube start
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install the kubernetes resources
|
<h3 class="step"><span class="fa-stack fa-1x"><i class="fa fa-circle fa-stack-2x"></i><strong class="fa-stack-1x text-primary">2</strong></span>Enable the addons</h2>
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
minikube addons enable ingress
|
||||||
minikube addons enable ingress-dns
|
minikube addons enable ingress-dns
|
||||||
```
|
```
|
||||||
|
|
||||||
### Add the minikube ip as a dns server
|
<h3 class="step"><span class="fa-stack fa-1x"><i class="fa fa-circle fa-stack-2x"></i><strong class="fa-stack-1x text-primary">3</strong></span>Add the `minikube ip` as a DNS server</h2>
|
||||||
|
|
||||||
#### Mac OS
|
{{% card %}}
|
||||||
Create a file in `/etc/resolver/minikube-profilename-test`
|
|
||||||
```
|
|
||||||
domain test
|
|
||||||
nameserver 192.168.99.169
|
|
||||||
search_order 1
|
|
||||||
timeout 5
|
|
||||||
```
|
|
||||||
Replace `192.168.99.169` with your minikube ip and `profilename` is the name of the minikube profile for the
|
|
||||||
corresponding ip address
|
|
||||||
|
|
||||||
If you have multiple minikube ips you must configure multiple files
|
{{% quiz_row base="" name="Operating system" %}}
|
||||||
|
{{% quiz_button option="Linux" %}} {{% quiz_button option="macOS" %}} {{% quiz_button option="Windows" %}}
|
||||||
|
{{% /quiz_row %}}
|
||||||
|
|
||||||
See https://www.unix.com/man-page/opendarwin/5/resolver/
|
{{% card %}}
|
||||||
Note that even though the `port` feature is documented. It does not actually work.
|
|
||||||
|
{{% quiz_instruction_plain id="/Linux" %}}
|
||||||
|
|
||||||
|
Update the file `/etc/resolvconf/resolv.conf.d/base` to have the following contents.
|
||||||
|
|
||||||
#### Linux
|
|
||||||
Update the file `/etc/resolvconf/resolv.conf.d/base` to have the following contents
|
|
||||||
```
|
```
|
||||||
search test
|
search test
|
||||||
nameserver 192.168.99.169
|
nameserver 192.168.99.169
|
||||||
timeout 5
|
timeout 5
|
||||||
```
|
```
|
||||||
Replace `192.168.99.169` with your minikube ip
|
|
||||||
|
|
||||||
If your linux OS uses `systemctl` run the following commands
|
Replace `192.168.99.169` with your `minikube ip`.
|
||||||
|
|
||||||
|
If your Linux OS uses `systemctl`, run the following commands.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo resolvconf -u
|
sudo resolvconf -u
|
||||||
systemctl disable --now resolvconf.service
|
systemctl disable --now resolvconf.service
|
||||||
```
|
```
|
||||||
|
|
||||||
If your linux does not use `systemctl` run the following commands
|
If your Linux OS does not use `systemctl`, run the following commands.
|
||||||
|
|
||||||
TODO add supporting docs for Linux OS that do not use `systemctl`
|
```bash
|
||||||
|
# TODO add supporting docs for Linux OS that do not use `systemctl`
|
||||||
|
```
|
||||||
|
|
||||||
See https://linux.die.net/man/5/resolver
|
See https://linux.die.net/man/5/resolver
|
||||||
|
|
||||||
When you are using Network Manager with the dnsmasq plugin, you can add an additional configuration file, but you need
|
When you are using Network Manager with the `dnsmasq` plugin, you can add an additional configuration file, but you need
|
||||||
to restart NetworkManager to activate the change.
|
to restart NetworkManager to activate the change.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
@ -100,62 +103,95 @@ systemctl restart NetworkManager.service
|
||||||
|
|
||||||
Also see `dns=` in [NetworkManager.conf](https://developer.gnome.org/NetworkManager/stable/NetworkManager.conf.html).
|
Also see `dns=` in [NetworkManager.conf](https://developer.gnome.org/NetworkManager/stable/NetworkManager.conf.html).
|
||||||
|
|
||||||
#### Windows
|
{{% /quiz_instruction_plain %}}
|
||||||
Open `Powershell` as Administrator and execute the following
|
|
||||||
|
{{% quiz_instruction_plain id="/macOS" %}}
|
||||||
|
|
||||||
|
Create a file in `/etc/resolver/minikube-test` with the following content.
|
||||||
|
|
||||||
|
```
|
||||||
|
domain test
|
||||||
|
nameserver 192.168.99.169
|
||||||
|
search_order 1
|
||||||
|
timeout 5
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace `192.168.99.169` with your `minikube ip`.
|
||||||
|
|
||||||
|
If you have multiple minikube IPs, you must configure a file for each.
|
||||||
|
|
||||||
|
See https://www.unix.com/man-page/opendarwin/5/resolver/
|
||||||
|
|
||||||
|
Note that the `port` feature does not work as documented.
|
||||||
|
|
||||||
|
{{% /quiz_instruction_plain %}}
|
||||||
|
|
||||||
|
{{% quiz_instruction_plain id="/Windows" %}}
|
||||||
|
|
||||||
|
Open `Powershell` as Administrator and execute the following.
|
||||||
```sh
|
```sh
|
||||||
Add-DnsClientNrptRule -Namespace ".test" -NameServers "$(minikube ip)"
|
Add-DnsClientNrptRule -Namespace ".test" -NameServers "$(minikube ip)"
|
||||||
```
|
```
|
||||||
|
|
||||||
The following will remove any matching rules, before creating one. This is helpful if your minikube has a new ip
|
The following will remove any matching rules before creating a new one. This is useful for updating the `minikube ip`.
|
||||||
```sh
|
```sh
|
||||||
Get-DnsClientNrptRule | Where-Object {$_.Namespace -eq '.test'} | Remove-DnsClientNrptRule -Force; Add-DnsClientNrptRule -Namespace ".test" -NameServers "$(minikube ip)"
|
Get-DnsClientNrptRule | Where-Object {$_.Namespace -eq '.test'} | Remove-DnsClientNrptRule -Force; Add-DnsClientNrptRule -Namespace ".test" -NameServers "$(minikube ip)"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
{{% /quiz_instruction_plain %}}
|
||||||
|
|
||||||
|
{{% /card %}}
|
||||||
|
|
||||||
|
{{% /card %}}
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
### Add the test ingress
|
<h3 class="step"><span class="fa-stack fa-1x"><i class="fa fa-circle fa-stack-2x"></i><strong class="fa-stack-1x text-primary">1</strong></span>Add the test ingress</h2>
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl apply -f https://raw.githubusercontent.com/kubernetes/minikube/master/deploy/addons/ingress-dns/example/example.yaml
|
kubectl apply -f https://raw.githubusercontent.com/kubernetes/minikube/master/deploy/addons/ingress-dns/example/example.yaml
|
||||||
```
|
```
|
||||||
Note: Minimum Kubernetes version for example ingress is 1.19
|
Note: Minimum Kubernetes version for the example ingress is 1.19
|
||||||
|
|
||||||
|
<h3 class="step"><span class="fa-stack fa-1x"><i class="fa fa-circle fa-stack-2x"></i><strong class="fa-stack-1x text-primary">2</strong></span>Confirm that DNS queries are returning A records</h2>
|
||||||
|
|
||||||
### Validate DNS queries are returning A records
|
|
||||||
```bash
|
```bash
|
||||||
nslookup hello-john.test $(minikube ip)
|
nslookup hello-john.test $(minikube ip)
|
||||||
nslookup hello-jane.test $(minikube ip)
|
nslookup hello-jane.test $(minikube ip)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Validate domain names are resolving on host OS
|
<h3 class="step"><span class="fa-stack fa-1x"><i class="fa fa-circle fa-stack-2x"></i><strong class="fa-stack-1x text-primary">3</strong></span>Confirm that domain names are resolving on the host OS</h2>
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ping hello-john.test
|
ping hello-john.test
|
||||||
|
ping hello-jane.test
|
||||||
```
|
```
|
||||||
|
|
||||||
Expected results:
|
Expected results:
|
||||||
```text
|
```text
|
||||||
PING hello-john.test (192.168.99.169): 56 data bytes
|
PING hello-john.test (192.168.99.169): 56 data bytes
|
||||||
64 bytes from 192.168.99.169: icmp_seq=0 ttl=64 time=0.361 ms
|
64 bytes from 192.168.99.169: icmp_seq=0 ttl=64 time=0.361 ms
|
||||||
```
|
```
|
||||||
```bash
|
|
||||||
ping hello-jane.test
|
|
||||||
```
|
|
||||||
```text
|
```text
|
||||||
PING hello-jane.test (192.168.99.169): 56 data bytes
|
PING hello-jane.test (192.168.99.169): 56 data bytes
|
||||||
64 bytes from 192.168.99.169: icmp_seq=0 ttl=64 time=0.262 ms
|
64 bytes from 192.168.99.169: icmp_seq=0 ttl=64 time=0.262 ms
|
||||||
```
|
```
|
||||||
|
|
||||||
### Curl the example server
|
<h3 class="step"><span class="fa-stack fa-1x"><i class="fa fa-circle fa-stack-2x"></i><strong class="fa-stack-1x text-primary">4</strong></span>Curl the example server</h2>
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl http://hello-john.test
|
curl http://hello-john.test
|
||||||
|
curl http://hello-jane.test
|
||||||
```
|
```
|
||||||
Expected result:
|
|
||||||
|
Expected results:
|
||||||
```text
|
```text
|
||||||
Hello, world!
|
Hello, world!
|
||||||
Version: 1.0.0
|
Version: 1.0.0
|
||||||
Hostname: hello-world-app-557ff7dbd8-64mtv
|
Hostname: hello-world-app-557ff7dbd8-64mtv
|
||||||
```
|
```
|
||||||
```bash
|
|
||||||
curl http://hello-jane.test
|
|
||||||
```
|
|
||||||
Expected result:
|
|
||||||
```text
|
```text
|
||||||
Hello, world!
|
Hello, world!
|
||||||
Version: 1.0.0
|
Version: 1.0.0
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div data-quiz-id="{{ with .Get "id"}}{{.}}{{end}}" class="quiz-instruction">
|
||||||
|
{{ .Inner }}
|
||||||
|
</div>
|
||||||
Loading…
Reference in New Issue