Page
Configure DHCP for Red Hat OpenShift

At this point, we have the NNCPs and the NADs configured on the worker nodes and the OCP cluster. The next step is to modify the network configuration with patching the Cluster Network Operator.
Prerequisites:
- Kubernetes NMState operator
- Red Hat Local storage operator
- Red Hat OpenShift Data Foundation operator
- A Red Hat OpenShift/Kubernetes environment
In this lesson, you will:
- Configure DHCP to accommodate pods.
DHCP configuration for Red Hat OpenShift
IP addresses for the ODF pods are assigned by the DHCP server at pod creation time, but the lease must be periodically renewed. To accomplish this, the DHCP IPAM CNI daemon is required. A modification of the Cluster Network Operator (CNO) is required to trigger the deployment of this daemon as part of the network setup.
A shim network attachment can be created by patching the CNO configuration by adding the following parameters to the .spec
section of the network.operator.openshift.io/cluster
CR. Please refer to the Red Hat OpenShift Networking user’s guide for any updates or changes in requirements.
spec:
additionalNetworks:
- name: dhcp-shim
namespace: default
rawCNIConfig: |-
{
"name": "dhcp-shim",
"cniVersion": "0.3.1",
"type": "bridge",
"ipam": {
"type": "dhcp"
}
}
type: Raw
Use the oc patch
command to update the CNO and trigger the deployment of the DHCP IPAM daemon.
oc patch --type merge network.operator.openshift.io/cluster -p '{"spec":{"additionalNetworks":[{"name":"dhcp-shim","namespace":"default","rawCNIConfig":"{\"name\":\"dhcp-shim\",\"cniVersion\":\"0.3.1\",\"type\":\"bridge\",\"ipam\":{\"type\":\"dhcp\"}}","type":"Raw"}]}}'
network.operator.openshift.io/cluster patched
Verify the network.operator.openshift.io/cluster
CR with the oc get
command. The dhcp-shim
will be in the .spec
section.
oc get network.operator.openshift.io cluster -o yaml
apiVersion: operator.openshift.io/v1
kind: Network
metadata:
name: cluster
spec:
additionalNetworks:
- name: dhcp-shim
namespace: default
type: Raw
rawCNIConfig: '{"name":"dhcp-shim","cniVersion":"0.3.1","type":"bridge","ipam":{"type":"dhcp"}}'
clusterNetwork:
…
Now that we have all of the network configuration complete, it's time to verify the network and ensure it's ready for the storage cluster to be created.