Installing the kind
cluster with an Ingress Controller is pretty easy task for Ubuntu. But configuring opening Ingress domains by wildcard locally - already not so easy! So, let's describe the steps on how to do this! It's tested by me on Ubuntu 22.04 and 23.10, but should work well for other versions too.
Fortunately, modern Ubuntu versions use systemd-resolved
for DNS resolving, that have the dnsmasq
feature built-in, so you don't need to install the dnsmasq
as a separate package.
Here are the steps to configure opening all subdomains of the .kind
top level domain through your kind
Ingress Controller:
- Enable the
dnsmasq
module in thesystemd-resolved
by creating a config file ``/etc/NetworkManager/conf.d/00-use-dnsmasq.conf`:
# This enabled the dnsmasq plugin.
[main]
dns=dnsmasq
# Put also "DNS=127.0.0.1" to the /etc/systemd/resolved.conf
- In the
/etc/systemd/resolved.conf
file - set to use the local DNS server by a line:
[Resolve]
DNS=127.0.0.1
- Configure a
kind
cluster to map Ingress ports to the local IP address127.0.0.2
in the cluster config filekind.conf
:
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
listenAddress: "127.0.0.2"
- containerPort: 443
hostPort: 443
protocol: TCP
listenAddress: "127.0.0.2"
And create or recreate the cluster using:
$ kind create cluster --config=./kind.conf
- Create a configuration file
/etc/NetworkManager/dnsmasq.d/50-kind-wildcard.conf
to map a top level domain and all it subdomains to your localhost:
local=/kind/
# We use a separate local IP address here to route this traffic to the `kind` Ingress Controller.
address=/.kind/127.0.0.2
# This line is needed to read mappings from the `hosts` file by `dnsmasq`.
addn-hosts=/etc/hosts
- Then, restart the systemd:
$ sudo systemctl restart systemd-resolved
And open a domain like https://my-local-ingress-endpoint.kind/
in a web browser, and it should work well!
And seems that's it!