Installing OpenShift 4.8 without a DNS server

Installing OpenShift 4.8 without a DNS server

dnsmasq on the rescue

Table of contents

No heading

No headings in the article.

For all us being used to OpenShift 3.x, shifting to OpenShift 4.x may sound like a big hassle, but after carefully going through all the docs is much easier than it seems (granted that you grasp the concept of operators, of course).

You can choose to deploy it on bare metals or on different cloud providers. In our case, we deployed it on OpenStack.

However, using all open source software, we specifically deployed OKD 4.8 on OpenStack upstream Train.

The https://docs.okd.io/4.8/welcome/index.html docs are not clear about this point, as they merely mention RHOSP (RedHat OpenStack Platform) 13 and 16, which correspond to Queens and Train, respectively.

You have two way to install OpenShift, an installer-provisioned and a user-provisioned. Basically, the first creates all the resources it needs automatically and then deploy OKD upon them, whereas the second implies that you're in charge of creating each and every resource by yourself; in any case, you can find more info on the official docs, of course. We chose the installer provisioned.

Now, the docs are very clear about a prerequisite:

OpenStack’s networking service need to have DHCP agents forward instances' DNS queries

This is required because the bootstrap machine needs to get the configuration and the artifacts it needs to initialize the installation process.

According to the OpenStack https://docs.openstack.org/neutron/rocky/admin/config-dns-res.html, there are different ways to achieve this.

In particular, one way is the following:

Queries are forwarded to an explicitly configured set of DNS resolvers.

What if you don't have a DNS server which you can configure as you please?

One possible solution is to replace your local network name resolution service with dnsmasq.

The procedure is for Ubuntu, but of course applyes to other Linux-based OSes.

sudo apt install dnsmasq ldns 
sudo nano /etc/dnsmasq.conf

Inside /etc/dnsmasq.conf, add the following lines

listen-address=::1,127.0.0.1,<your_own_LAN_IP_address> #to specifiy where dnsmasq should be accessible
server=8.8.8.8
server=8.8.4.4 #where queries that can't be resolved locally should be forwarded to
address=/FQDN/IP #each address that may be needed by the OpenShift installation process

Then

sudo systemctl disable systemd-resolved #or the local network name resolution service you use
sudo systemctl stop systemd-resolved

Then remove /etc/resolv.conf and create it anew with the following content:

nameserver ::1
nameserver 127.0.0.1
options trust-ad

Also, in order to block NetworkManager from overwriting that file, create the following file /etc/NetworkManager/conf.d/dns.conf with the following content

[main]
dns=none

Then restart it, sudo systemctl restart NetworkManager.

Finally enable and start dnsmasq sudo systemctl enable dnsmasq; systemctl start dnsmasq

As a last step, you need to update the Neutron DHCPAgent. Simply add the following line to the dhcpagent.ini file:

[DEFAULT]
dnsmasq_dns_servers = <your_own_LAN_IP_address>

Once you re-run the openshift installer create cluster command, everything should be run fine.

Alla prossima! 🇮🇹