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

openstack: make dhcp files available to UPI too #2606

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions data/data/bootstrap/openstack/OWNERS
@@ -0,0 +1,5 @@
# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md
# This file just uses aliases defined in OWNERS_ALIASES.

approvers:
- openstack-approvers
@@ -0,0 +1,2 @@
[main]
dhcp=dhclient
2 changes: 2 additions & 0 deletions data/data/bootstrap/openstack/files/etc/dhcp/dhclient.conf
@@ -0,0 +1,2 @@
send dhcp-client-identifier = hardware;
prepend domain-name-servers 127.0.0.1;
44 changes: 2 additions & 42 deletions docs/user/openstack/install_upi.md
Expand Up @@ -304,11 +304,9 @@ Make sure your shell session has the `$INFRA_ID` environment variable set when y

### Update Bootstrap Ignition

There is some bootstrap configuration we weed to add explicitly to the ignition file. The IPI installer does this automatically via Terraform, but the changes do not show up in the files generated by `create ignition-configs`. This section should go away in the future.
We need to set the bootstrap hostname explicitly. The IPI installer does this automatically, but for now UPI does not.

The contents of the files we need to create have to be base64-encoded.

We will create three files:
We will update the ignition to create the following file:

**`/etc/hostname`**:

Expand All @@ -318,20 +316,6 @@ openshift-qlvwv-bootstrap

(using the `infraID`)

**`/etc/NetworkManager/conf.d/dhcp-client.conf`**:

```
[main]
dhcp=dhclient
```

**`/etc/dhcp/dhclient.conf`**:

```
send dhcp-client-identifier = hardware;
prepend domain-name-servers 127.0.0.1;
```

**NOTE**: We recommend you back up the Ignition files before making any changes!

You can edit the Ignition file manually or run this Python script:
Expand Down Expand Up @@ -359,30 +343,6 @@ files.append(
'filesystem': 'root',
})

dhcp_client_conf_b64 = base64.standard_b64encode(b'[main]\ndhcp=dhclient\n').decode().strip()
files.append(
{
'path': '/etc/NetworkManager/conf.d/dhcp-client.conf',
'mode': 420,
'contents': {
'source': 'data:text/plain;charset=utf-8;base64,' + dhcp_client_conf_b64,
'verification': {}
},
'filesystem': 'root',
})

dhclient_cont_b64 = base64.standard_b64encode(b'send dhcp-client-identifier = hardware;\nprepend domain-name-servers 127.0.0.1;\n').decode().strip()
files.append(
{
'path': '/etc/dhcp/dhclient.conf',
'mode': 420,
'contents': {
'source': 'data:text/plain;charset=utf-8;base64,' + dhclient_cont_b64,
'verification': {}
},
'filesystem': 'root'
})

ignition['storage']['files'] = files;

with open('bootstrap.ign', 'w') as f:
Expand Down
38 changes: 1 addition & 37 deletions pkg/tfvars/openstack/bootstrap_ignition.go
Expand Up @@ -68,42 +68,8 @@ func createBootstrapSwiftObject(cloud string, bootstrapIgn string, clusterID str
func generateIgnitionShim(userCA string, clusterID string, swiftObject string) (string, error) {
fileMode := 420

// DHCP Config
contents := `[main]
dhcp=dhclient`

dhcpConfigFile := ignition.File{
Node: ignition.Node{
Filesystem: "root",
Path: "/etc/NetworkManager/conf.d/dhcp-client.conf",
},
FileEmbedded1: ignition.FileEmbedded1{
Mode: &fileMode,
Contents: ignition.FileContents{
Source: fmt.Sprintf("data:text/plain;base64,%s", b64.StdEncoding.EncodeToString([]byte(contents))),
},
},
}

// DNS Config
contents = `send dhcp-client-identifier = hardware;
prepend domain-name-servers 127.0.0.1;`

dnsConfigFile := ignition.File{
Node: ignition.Node{
Filesystem: "root",
Path: "/etc/dhcp/dhclient.conf",
},
FileEmbedded1: ignition.FileEmbedded1{
Mode: &fileMode,
Contents: ignition.FileContents{
Source: fmt.Sprintf("data:text/plain;base64,%s", b64.StdEncoding.EncodeToString([]byte(contents))),
},
},
}

// Hostname Config
contents = fmt.Sprintf("%s-bootstrap", clusterID)
contents := fmt.Sprintf("%s-bootstrap", clusterID)

hostnameConfigFile := ignition.File{
Node: ignition.Node{
Expand Down Expand Up @@ -143,8 +109,6 @@ prepend domain-name-servers 127.0.0.1;`
},
Storage: ignition.Storage{
Files: []ignition.File{
dhcpConfigFile,
dnsConfigFile,
hostnameConfigFile,
},
},
Expand Down