Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.7] Bug 1975819: upi/vsphere: Use Afterburn guestinfo for static IP and hostname config #5025

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 5 additions & 61 deletions docs/user/vsphere/install_upi.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,72 +279,16 @@ The Ignition config created by the OpenShift Installer cannot be used directly b
},
}
```
### Hostname

The hostname of each control plane and worker machine must be resolvable from all nodes within the cluster.

Preferrably, the hostname will be set via DHCP. If you need to manually set a hostname, you can create a hostname file by adding an entry in the `.storage.files` list in an Ignition config.

For example, the following Ignition config will create a hostname file that sets the hostname of a machine to `control-plane-0.

```json
{
"ignition": {
"version": "3.1.0"
},
"storage": {
"files": [
{
"path": "/etc/hostname",
"contents": {
"source": "data:text/plain;charset=utf-8,control-plane-0",
},
"mode": 420
}
]
},
}
```

### Static IP Addresses
## Configuring Hostname and Static IP Addresses with Afterburn

Preferrably, the IP address for each machine will be set via DHCP. If you need to use a static IP address, you can be set one for a machine by creating an ifcfg file. You can create an ifcfg file by adding an entry in the `.storage.files` list in an Ignition config.

For example, the following Ignition config will create an ifcfg file that sets the IP address of the ens192 device to 10.0.0.2.
The hostname of each control plane and worker machine must be resolvable from all nodes within the cluster.

```json
{
"ignition": {
"version": "3.1.0"
},
"storage": {
"files": [
{
"path": "/etc/sysconfig/network-scripts/ifcfg-ens192",
"contents": {
"source": "data:text/plain;charset=utf-8;base64,VFlQRT1FdGhlcm5ldApCT09UUFJPVE89bm9uZQpOQU1FPWVuczE5MgpERVZJQ0U9ZW5zMTkyCk9OQk9PVD15ZXMKSVBBRERSPTEwLjAuMC4yClBSRUZJWD0yNApHQVRFV0FZPTEwLjAuMC4xCkRPTUFJTj1teWRvbWFpbi5jb20KRE5TMT04LjguOC44",
},
"mode": 420
}
]
},
}
```
Preferrably, the hostname and IP address will be set via DHCP.

The ifcfg file will have the following contents.
If you need to manually set a hostname and/or configure a static IP address, you can pass a custom networking command-line `ip=` parameter to Afterburn for configuration. In order to do so, set the vApp property `guestinfo.afterburn.initrd.network-kargs` to the `ip` parameter using this format: `ip=<ip_address>::<gateway>:<netmask>:<hostname>:<iface>:<protocol>:<dns_address>`, e.g. `ip=10.0.0.2::10.0.0.2:255.255.255.0:compute-1:ens192:none:8.8.8.8`

```
TYPE=Ethernet
BOOTPROTO=none
NAME=ens192
DEVICE=ens192
ONBOOT=yes
IPADDR=10.0.0.2
PREFIX=24
GATEWAY=10.0.0.1
DOMAIN=mydomain.com
DNS1=8.8.8.8
```
The full syntax of the `ip=` parameter is documented in the [Dracut manpages](https://www.man7.org/linux/man-pages/man7/dracut.cmdline.7.html).

## Watching your installation

Expand Down
12 changes: 0 additions & 12 deletions upi/vsphere/vm/ifcfg.tmpl

This file was deleted.

45 changes: 0 additions & 45 deletions upi/vsphere/vm/ignition.tf

This file was deleted.

5 changes: 3 additions & 2 deletions upi/vsphere/vm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ resource "vsphere_virtual_machine" "vm" {
}

extra_config = {
"guestinfo.ignition.config.data" = base64encode(data.ignition_config.ign[each.key].rendered)
"guestinfo.ignition.config.data.encoding" = "base64"
"guestinfo.ignition.config.data" = base64encode(var.ignition)
"guestinfo.ignition.config.data.encoding" = "base64"
"guestinfo.afterburn.initrd.network-kargs" = "ip=${each.value}::${cidrhost(var.machine_cidr, 1)}:${cidrnetmask(var.machine_cidr)}:${element(split(".", each.key), 0)}:ens192:none:${join(":", var.dns_addresses)}"
}
}