How to use network-kargs to deploy RHCOS Nodes with Static IPs in Openshift 4 on VMware
Environment
- Red Hat OpenShift Container Platform (RHOCP)
- 4.6 and higher
- VMware vSphere
- 6.7 U3 and higher
Issue
- Is it possible to deploy a node in VMware with a Static IP in RHOCP?
- How do I use network-kargs to configure Static IP addresses in VMware using OpenShift Container Platform?
- Why using
guestinfo.afterburn.initrd.network-kargs
property is not affecting the node configuration?
Resolution
Starting in OpenShift Container Platform 4.6, Red Hat CoreOS Enterprise Linux has the ability to utilize a static network configuration and override the automatic DHCP setup. Custom networking command-line ip=
parameter can be configured via guestinfo.afterburn.initrd.network-kargs
property.
Note: guestinfo.afterburn.initrd.network-kargs
property must be set on the VM before the first boot and it does not affect subsequent boots.
The full syntax of the ip= parameter is documented in Dracut manpages.
ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<dns1>][:<dns2>]]
explicit network configuration. If you want do define a IPv6
address, put it in brackets (e.g. [2001:DB8::1]). This
parameter can be specified multiple times. <peer> is
optional and is the address of the remote endpoint for
pointopoint interfaces and it may be followed by a slash and
a decimal number, encoding the network prefix length.
Utilizing the govc
vSphere CLI you can use the following example to deploy a new node called Worker3 from the RHCOS46 Template to the raid0 Datastore with 4 vCPU, 16GB of RAM, on the 10.0.0.x-254 Network to the openshift-ctxdz folder.
WORKER_CONFIG=$(cat worker.ign | base64 -w0)
IPCFG="ip=10.0.0.103::10.0.0.254:255.255.255.0:worker3:ens192:off:10.0.0.1:10.0.0.2"
govc vm.clone -vm=RHCOS46 -ds=raid0 -c=4 -m=16384 -net=10.0.0.x-24 -folder=openshift-ctxdz -on=false worker3
govc vm.disk.change -vm worker3 -size 120G
govc vm.change -vm worker3 -e "guestinfo.ignition.config.data.encoding=base64"
govc vm.change -vm worker3 -e "guestinfo.ignition.config.data=${WORKER_CONFIG}"
govc vm.change -vm worker3 -e "guestinfo.afterburn.initrd.network-kargs=${IPCFG}"
govc vm.power -on worker3
In this example, using the Ansible along with the vmware_guest module, you will be deploying the same node Worker3 from the RHCOS46 Template to the raid0 Datastore with 4 vCPU, 16GB of RAM, on the 10.0.0.x-254 Network to the openshift-ctxdz folder.
NOTE - You will need to define the workerContent
as a variable with the contents of worker.ign.
- name: Create worker VMs from the template
vmware_guest:
hostname: vcenter.lab.int
username: Administrator@vsphere.local
password: ...
datacenter: OCP4
validate_certs: no
folder: /vm/openshift-ctxdz/
name: worker3
state: PoweredOn
template: RHCOS46
disk:
- size_gb: 120
type: thin
datastore: raid0
hardware:
memory_mb: 16384
num_cpus: 4
memory_reservation_lock: True
networks:
- name: 10.0.0.x-254
wait_for_ip_address: no
customvalues:
- key: guestinfo.ignition.config.data
value: "{{ workerContent }}"
- key: guestinfo.ignition.config.data.encoding
value: base64
- key: guestinfo.afterburn.initrd.network-kargs
value: "ip=10.0.0.103::10.0.0.254:255.255.255.0:worker3:ens192:off:10.0.0.1:10.0.0.2"
The implementations that need IPv4 and IPv6, both parameters can be passed to the network-kargs considering the syntax standards from Dracut manpages:
ip=10.0.0.103::10.0.0.254:255.255.255.0:worker3:ens192:off:10.0.0.1:10.0.0.2
ip=[2001::2001]::[2001::2002]:[ffff:ffff:ffff:ffff::]:worker3:ens192:off::
If you no longer have access to your Master or Worker Ignition files you can retrieve them by following KCS: How to retrieve Master or Worker Ignition Configuration?
Disclaimers:
Links contained herein to external website(s) are provided for convenience only. Red Hat has not reviewed the links and is not responsible for the content or its availability. The inclusion of any link to an external website does not imply endorsement by Red Hat of the website or their entities, products or services. You agree that Red Hat is not responsible or liable for any loss or expenses that may result due to your use of (or reliance on) the external site or content.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments