We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Configure Static IPv4 Address in OpenShift 4.x CoreOS Servers

Learn how to – Configure Static IPv4 Address in OpenShift 4.x CoreOS Servers.

You just finished setting up your OpenShift 4.x or OKD 4.x cluster and would like to have static IP addresses configured on the nodes?. This is a common requirement for an OpenShift UPI cluster deployed on-premise, e.g cluster installed in a VMware, RHEV or Baremetal servers where DHCP server is not highly reliable. In this post we will use nmcli Network Management tool to configure static IPv4 address on OpenShift 4.x servers – Infra, Masters and Worker machines.

Since the process used in this guide is manual, it means you need ssh access to the servers where static IP address is to be configured. In our example, where DHCP server was used to assign IPv4 address to the machines during bootstrapping, below is sample DHCP configuration for worker machines.

....
subnet 172.22.100.0 netmask 255.255.255.0 {
        pool {
            range 172.22.100.1 172.22.100.100;
    	    option routers 172.22.100.254;
            option subnet-mask 255.255.255.0;
            option broadcast-address 172.22.100.255;
            option domain-name-servers 172.22.100.254,8.8.8.8;
            option domain-name "ocp.example.net";

            # Worker Machines
            host worker1 {
                hardware ethernet 00:50:56:bf:c0:f7;
                fixed-address 172.22.100.10;
                option host-name "worker1.ocp.example.net";
            }
            host worker2 {
                hardware ethernet 00:50:56:bf:07:5a;
                fixed-address 172.22.100.11;
                option host-name "worker2.ocp.example.net";
            }
            host worker3 {
                hardware ethernet 00:50:56:bf:b2:a6;
                fixed-address 172.22.100.12;
                option host-name "worker3.ocp.example.net";
            }
....

I’ll login to one of the worker nodes – worker1 , whose IP Address assigned though DHCP Server is 172.22.100.10.

$ ssh core@172.22.100.10
Red Hat Enterprise Linux CoreOS 44.81.202007010318-0
  Part of OpenShift 4.4, RHCOS is a Kubernetes native operating system
  managed by the Machine Config Operator (`clusteroperator/machine-config`).

WARNING: Direct SSH access to machines is not recommended; instead,
make configuration changes via `machineconfig` objects:
  https://docs.openshift.com/container-platform/4.4/architecture/architecture-rhcos.html

---
Last login: Sat Oct 31 19:55:16 2020 from 172.22.100.200
[core@worker1 ~]$ 

You can also use oc debug command to gain shell access to the node.

$ oc debug node/<nodename>

Configure Static IP Address in Red Hat CoreOS / Fedora CoreOS using NMCLI

Once you’re logged in to the terminal check network configuration with nmcli.

$ nmcli connection show 
NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  1dbbec73-04b1-3726-9d04-458f9ba17ff6  ethernet  ens192 

You can get more details about the connection:

$ nmcli con show 'Wired connection 1'

To configure IPv4 address, Gateway and DNS update the network connection settings with nmcli.

sudo nmcli connection mod 'Wired connection 1' 
ipv4.method manual 
connection.autoconnect yes 
ipv4.addresses 172.22.100.10/24 
ipv4.gateway 172.22.100.254 
ipv4.dns 172.22.100.254 
+ipv4.dns 8.8.8.8

In my setup the settings used are:

  • 172.22.100.10 is the IPv4 address of the server.
  • 172.22.100.254 is the gateway and DNS server IPv4 address.
  • 8.8.8.8 is the secondary DNS server IPv4 address.
  • ‘connection.autoconnect yes‘ sets the connection to come up on system boot.
  • ‘ipv4.method manual‘ switch the connection from DHCP to Static IPv4 address.
  • ‘Wired connection 1‘ is the name of connection to be modified.

Upon execution a static network configuration script is created.

$ ls /etc/sysconfig/network-scripts/
ifcfg-Wired_connection_1

Reboot to confirm if the IP address request is sent to DHCP server or assigned manually.

sudo systemctl reboot

Set Hostname on Red Hat CoreOS / Fedora CoreOS using NMCLI

You can also use the NMCLI command line tool to configure static hostname of the CoreOS server.

sudo nmcli general hostname worker1.ocp.example.net

Confirm the setting.

$ hostnamectl 
   Static hostname: worker1.ocp.example.net
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 93ba80b38e9948acbb6aa6346bb5312c
           Boot ID: d885cc0011c04ac08c4d3e3ef3441ed0
    Virtualization: vmware
  Operating System: Red Hat Enterprise Linux CoreOS 44.81.202007010318-0 (Ootpa)
            Kernel: Linux 4.18.0-147.20.1.el8_1.x86_64
      Architecture: x86-64

You can also cat the /etc/hostname file.

$ cat /etc/hostname 
worker1.ocp.example.net

OpenShift Courses:

Practical OpenShift for Developers – New Course 2021

Ultimate Openshift (2021) Bootcamp by School of Devops

You now have static IPv4 address set in your Red Hat CoreOS and Fedora CoreOS servers. Stay connected for more OpenShift guides while checking other available guides.

How To List and Approve Pending CSR in OpenShift 4.x

Sending OpenShift Logs and Events to Splunk

Grant Users Access to Project/Namespace in OpenShift

Cart

Your Cart is Empty

Back To Shop