Bug 1905986 - Hostname can not persist when installing RHCOS
Summary: Hostname can not persist when installing RHCOS
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: RHCOS
Version: 4.6
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: ---
: 4.8.0
Assignee: Micah Abbott
QA Contact: Michael Nguyen
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-12-09 13:18 UTC by yhe
Modified: 2024-03-25 17:28 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-02-25 16:52:23 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github coreos fedora-coreos-tracker issues 697 0 None open RFE: provide a way to persist hostname via live ISO/`coreos-installer` 2021-02-07 20:26:32 UTC

Description yhe 2020-12-09 13:18:07 UTC
Description of problem:
When installing RHCOS, the hostname configured with the nmtui tool can't persist and gets reset to localhost after rebooting.
Will upload the screenshot later.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Configure the network including the hostname with the nmtui tool.
2. Run the coreos-installer command.
3. Reboot

Actual results:
The hostname gets reset to localhost.

Expected results:
The hostname persists.

Additional info:

Comment 4 Micah Abbott 2020-12-09 20:56:58 UTC
The `--copy-network` command only copies the configurations under /etc/NetworkManager/system-connections.  When setting the hostname via `nmtui`, the hostname is configured in /etc/hostname.  Therefore, the `--copy-network` operation is insufficient for configuring the hostname.

The recommended way to configure the hostname would be to provide an Ignition config that writes out `/etc/hostname` with the desired value for the system.

We can pursue improving the UX in this case; I'll link to an upstream issue where input can be gathered.

Comment 6 Micah Abbott 2020-12-10 17:18:04 UTC
Here's the upstream issue discussing support for persiting the hostname - https://github.com/coreos/fedora-coreos-tracker/issues/697

Comment 7 Micah Abbott 2020-12-10 17:51:38 UTC
The preferred way of modifying nodes at install time would be to use MachineConfigs.  However, it is not possible to create per-node MachineConfigs at this time, so you would have to provide unique Ignition configs during install time.

Using the UPI bare metal instructions as a guide:  https://docs.openshift.com/container-platform/4.6/installing/installing_bare_metal/installing-bare-metal-network-customizations.html

For example:

```
$ mkdir modify_hostname
$ vi modify_hostname/install-config.yaml                                                                                                                                                                                                                 
$ ./openshift-install create ignition-configs --dir=modify_hostname                                                                                                                        
INFO Consuming Install Config from target directory                                                                                                                                                                                                                                                                           
WARNING Making control-plane schedulable by setting MastersSchedulable to true for Scheduler cluster settings 
INFO Ignition-Configs created in: modify_hostname and modify_hostname/auth 
$ cp modify_hostname/worker.ign modify_hostname/worker0.ign
$ vi modify_hostname/worker0.ign
$ jq . < modify_hostname/worker0.ign
{
  "ignition": {
    "config": {
      "merge": [
        {
          "source": "https://api-int.test.example.com:22623/config/worker"
        }
      ]
    },
    "security": {
      "tls": {
        "certificateAuthorities": [
          {
            "source": "data:text/plain;charset=utf-8;base64,LS0tLS1CR...."
          }
        ]
      }
    },
    "version": "3.1.0"
  },
  "storage": {
    "files": [
      {
        "path": "/etc/hostname",
        "contents": {
          "source": "data:,worker0.example.com"
        },
        "mode": 420
      }
    ]
  }
}
```

In the example worker0.ign, you can see that a `storage` section has been added to the Igntion config.  This section instructs Ignition to write out `/etc/hostame` with the contents `worker0.example.com`

Users will need to create modified Ignition configurations for each node they need to configure the hostname for and then make them available via HTTP or HTTPS.

When installing RHCOS to disk from the ISO, the command would look like:  `coreos-installer install --copy-network --insecure-igntion --ignition-url=http://<ip address>/worker0.ign /dev/sda`

Comment 8 Micah Abbott 2020-12-18 19:54:28 UTC
We have provided steps for configuring the hostname via Igntion config and are discussing how this can improved when using `coreos-installer` upstream.  This will not be able to be implemented for 4.7, so resetting the Target Release until we have more consensus upstream.

Comment 9 Micah Abbott 2021-01-15 20:52:47 UTC
Higher priority work has prevented this issue from being solved; adding the UpcomingSprint keyword

Comment 10 Micah Abbott 2021-02-07 20:27:38 UTC
Discussing options in upstream issue

Comment 11 Micah Abbott 2021-02-25 16:52:23 UTC
Since it is possible to set the hostname via Ignition and expanding the functionality of `coreos-installer` to persist the hostname is an RFE, I am going to close this BZ.

Please follow the upstream issue for additional progress - https://github.com/coreos/fedora-coreos-tracker/issues/697


Note You need to log in before you can comment on or make changes to this bug.