Yet another web developer blog

Configure kind cluster with wildcard domains on Ubuntu

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:

  1. Enable the dnsmasq module in the systemd-resolvedby creating a config file ``/etc/NetworkManager/conf.d/00-use-dnsmasq.conf`:
# This enabled the dnsmasq plugin.
# Put also "DNS=" to the /etc/systemd/resolved.conf
  1. In the /etc/systemd/resolved.conf file - set to use the local DNS server by a line:
  1. Configure a kind cluster to map Ingress ports to the local IP address in the cluster config file kind.conf:
kind: Cluster
- role: control-plane
  - |
    kind: InitConfiguration
        node-labels: "ingress-ready=true"
  - containerPort: 80
    hostPort: 80
    protocol: TCP
    listenAddress: ""
  - containerPort: 443
    hostPort: 443
    protocol: TCP
    listenAddress: ""

And create or recreate the cluster using:

$ kind create cluster --config=./kind.conf
  1. 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:
# We use a separate local IP address here to route this traffic to the `kind` Ingress Controller.
# This line is needed to read mappings from the `hosts` file by `dnsmasq`.
  1. 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!