Configuring DHCP Server for OKD HA Clusters

Introduction

Earlier we installed a simple DHCP server for Single node OKD cluster, this time we are about to extend the existing setup to facilitate our new HA cluster requirement. Just by adding few more configs we are good with our new cluster dhcp requirements.

If you are looking to setup a simple DHCP for all in one OKD cluster refer to below URL

Installing Package

Install the dhcp-server package using yum or dnf. The original dhcpd.conf file will be empty and contain no content. Copy the example file from /usr/share/doc/dhcp-server/ to the main configuration location as shown below.

$ dnf install dhcp-server -y
$ cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf-original
$ cat /usr/share/doc/dhcp-server/dhcpd.conf.example > /etc/dhcp/dhcpd.conf

Main DHCP configuration file

The below config includes for both single and HA OKD cluster.

Since all components are installed on a single server for a single-node OKD cluster, we have configured it with a fixed IP address. The setup is compact and straightforward.

Additionally, for the current HA OKD cluster, we have defined a separate configuration for each node to assign fixed IP addresses.

$ vim /etc/dhcp/dhcpd.conf

# option definitions common to all supported networks...
default-lease-time 600;
max-lease-time 7200;
log-facility local7;

# Fixed IP addresses for single node OKD Cluster host.
host control-plane {
  option domain-name-servers ns1.okd.linuxsysadmins.lan;
  option domain-name "okd.linuxsysadmins.lan";
  option routers 192.168.11.1;
  option broadcast-address 192.168.11.255;
  hardware ethernet BC:24:11:EC:84:07;
  fixed-address 192.168.11.101;
  option host-name "control-plane.okd.linuxsysadmins.lan";
  option ntp-servers 192.168.11.100;
  deny unknown-clients;
}
# DHCP server for three node OKD Clusters.
subnet 192.168.11.0 netmask 255.255.255.0 {
  option domain-name-servers ns1.okdcls.linuxsysadmins.lan;
  option domain-name "okdcls.linuxsysadmins.lan";
  option routers 192.168.11.1;
  option broadcast-address 192.168.11.255;
  option ntp-servers 192.168.11.100;
  deny unknown-clients;
}
# Fixed IP addressess for three node OKD cluster hosts
host control-plane1 {
  hardware ethernet BC:24:11:EC:84:01;
  fixed-address 192.168.11.201;
  option host-name "control-plane1.okdcls.linuxsysadmins.lan";
}

host control-plane2 {
  hardware ethernet BC:24:11:EC:84:02;
  fixed-address 192.168.11.202;
  option host-name "control-plane2.okdcls.linuxsysadmins.lan";
}

host control-plane3 {
  hardware ethernet BC:24:11:EC:84:03;
  fixed-address 192.168.11.203;
  option host-name "control-plane3.okdcls.linuxsysadmins.lan";
}

host compute1 {
  hardware ethernet BC:24:11:EC:84:04;
  option host-name "compute1.okdcls.linuxsysadmins.lan";
  fixed-address 192.168.11.204;
}

host compute2 {
  hardware ethernet BC:24:11:EC:84:05;
  option host-name "compute2.okdcls.linuxsysadmins.lan";
  fixed-address 192.168.11.205;
}

host compute3 {
  hardware ethernet BC:24:11:EC:84:06;
  option host-name "compute3.okdcls.linuxsysadmins.lan";
  fixed-address 192.168.11.206;
}

host bootstrap {
  hardware ethernet BC:24:11:EC:84:08;
  option host-name "bootstrap.okd.linuxsysadmins.lan";
  fixed-address 192.168.11.107;
}

Firewall Exclusion

Add a firewall rule to allow client machines to reach this DHCP server.

$ firewall-cmd --add-service=dhcp --permanent
$ firewall-cmd --reload

Finally, start and enable the service persistently.

$ systemctl enable dhcpd --now

That’s it! Now, when we power on the virtual machine, it will automatically receive the tagged fixed IP’s from our DHCP server according to its MAC address.