Skip to content

Commit e7fdbac

Browse files
Merge pull request #7645 from bfournie/host-bmc-config
AGENT-739: Support for install-config baremetal host BMC fields
2 parents 94ec923 + da28ed9 commit e7fdbac

File tree

9 files changed

+503
-97
lines changed

9 files changed

+503
-97
lines changed
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Verify a default configuration for the compact topology on baremetal using install-config hosts with BMC configuration
2+
3+
exec openshift-install agent create image --dir $WORK
4+
5+
stderr 'The rendezvous host IP \(node0 IP\) is 192.168.111.80'
6+
7+
exists $WORK/agent.x86_64.iso
8+
exists $WORK/auth/kubeconfig
9+
exists $WORK/auth/kubeadmin-password
10+
isocmp agent.x86_64.iso /etc/assisted/manifests/agent-cluster-install.yaml expected/agent-cluster-install.yaml
11+
12+
-- install-config.yaml --
13+
apiVersion: v1
14+
baseDomain: test.metalkube.org
15+
controlPlane:
16+
name: master
17+
replicas: 3
18+
compute:
19+
- name: worker
20+
replicas: 0
21+
metadata:
22+
namespace: cluster0
23+
name: ostest
24+
networking:
25+
clusterNetwork:
26+
- cidr: 10.128.0.0/14
27+
hostPrefix: 23
28+
networkType: OVNKubernetes
29+
machineNetwork:
30+
- cidr: 192.168.111.0/24
31+
serviceNetwork:
32+
- 172.30.0.0/16
33+
platform:
34+
baremetal:
35+
apiVips:
36+
- 192.168.111.5
37+
ingressVips:
38+
- 192.168.111.4
39+
provisioningNetworkInterface: enp1s0
40+
provisioningNetworkCIDR: 172.22.0.0/24
41+
provisioningNetwork: Managed
42+
provisioningDHCPRange: 172.22.0.10,172.22.0.254
43+
hosts:
44+
- name: master-0
45+
bootMACAddress: 00:00:00:aa:bb:01
46+
bmc:
47+
address: http://172.22.0.10:8000/redfish/v1/Systems/d3fe1eb9-f04c-465d-b5d6-d267f0a0059b
48+
username: foo
49+
password: pwd1
50+
disableCertificateVerification: false
51+
networkConfig:
52+
interfaces:
53+
- ipv4:
54+
address:
55+
- ip: 192.168.111.80
56+
prefix-length: 24
57+
dhcp: false
58+
enabled: true
59+
mac-address: 00:00:00:aa:bb:01
60+
name: eth0
61+
state: up
62+
type: ethernet
63+
routes:
64+
config:
65+
- destination: 0.0.0.0/0
66+
next-hop-address: 192.168.111.1
67+
next-hop-interface: eth0
68+
table-id: 254
69+
- name: master-1
70+
bootMACAddress: 00:00:00:aa:bb:02
71+
bmc:
72+
address: http://172.22.0.11:8000/redfish/v1/Systems/65bf6806-b634-4494-bccf-032ebdecc65d
73+
username: foo
74+
password: pwd2
75+
disableCertificateVerification: false
76+
networkConfig:
77+
interfaces:
78+
- ipv4:
79+
address:
80+
- ip: 192.168.111.81
81+
prefix-length: 24
82+
dhcp: false
83+
enabled: true
84+
mac-address: 00:00:00:aa:bb:02
85+
name: eth0
86+
state: up
87+
type: ethernet
88+
routes:
89+
config:
90+
- destination: 0.0.0.0/0
91+
next-hop-address: 192.168.111.1
92+
next-hop-interface: eth0
93+
table-id: 254
94+
- name: master-2
95+
bootMACAddress: 00:00:00:aa:bb:03
96+
bmc:
97+
address: http://172.22.0.12:8000/redfish/v1/Systems/ff67e706-28c4-42f6-b9a2-ce714195300a
98+
username: foo
99+
password: pwd3
100+
disableCertificateVerification: false
101+
networkConfig:
102+
interfaces:
103+
- ipv4:
104+
address:
105+
- ip: 192.168.111.82
106+
prefix-length: 24
107+
dhcp: false
108+
enabled: true
109+
mac-address: 00:00:00:aa:bb:03
110+
name: eth0
111+
state: up
112+
type: ethernet
113+
routes:
114+
config:
115+
- destination: 0.0.0.0/0
116+
next-hop-address: 192.168.111.1
117+
next-hop-interface: eth0
118+
table-id: 254
119+
sshKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDK6UTEydcEKzuNdPaofn8Z2DwgHqdcionLZBiPf/zIRNco++etLsat7Avv7yt04DINQd5zjxIFgG8jblaUB5E5C9ClUcMwb52GO0ay2Y9v1uBv1a4WhI3peKktAzYNk0EBMQlJtXPjRMrC9ylBPh+DsBHMu+KmDnfk7PIwyN4efC8k5kSRuPWoNdme1rz2+umU8FSmaWTHIajrbspf4GQbsntA5kuKEtDbfoNCU97o2KrRnUbeg3a8hwSjfh3u6MhlnGcg5K2Ij+zivEsWGCLKYUtE1ErqwfIzwWmJ6jnV66XCQGHf4Q1iIxqF7s2a1q24cgG2Z/iDXfqXrCIfy4P7b/Ztak3bdT9jfAdVZtdO5/r7I+O5hYhF86ayFlDWzZWP/ByiSb+q4CQbfVgK3BMmiAv2MqLHdhesmD/SmIcoOWUF6rFmRKZVFFpKpt5ATNTgUJ3JRowoXrrDruVXClUGRiCS6Zabd1rZ3VmTchaPJwtzQMdfIWISXj+Ig+C4UK0=
120+
pullSecret: '{"auths": {"quay.io": {"auth": "c3VwZXItc2VjcmV0Cg=="}}}'
121+
122+
-- agent-config.yaml --
123+
apiVersion: v1alpha1
124+
metadata:
125+
name: ostest
126+
namespace: cluster0
127+
rendezvousIP: 192.168.111.80
128+
129+
-- expected/agent-cluster-install.yaml --
130+
metadata:
131+
annotations:
132+
agent-install.openshift.io/install-config-overrides: '{"platform":{"baremetal":{"hosts":[{"name":"master-0","bmc":{"username":"foo","password":"pwd1","address":"http://172.22.0.10:8000/redfish/v1/Systems/d3fe1eb9-f04c-465d-b5d6-d267f0a0059b","disableCertificateVerification":false},"role":"","bootMACAddress":"00:00:00:aa:bb:01","hardwareProfile":""},{"name":"master-1","bmc":{"username":"foo","password":"pwd2","address":"http://172.22.0.11:8000/redfish/v1/Systems/65bf6806-b634-4494-bccf-032ebdecc65d","disableCertificateVerification":false},"role":"","bootMACAddress":"00:00:00:aa:bb:02","hardwareProfile":""},{"name":"master-2","bmc":{"username":"foo","password":"pwd3","address":"http://172.22.0.12:8000/redfish/v1/Systems/ff67e706-28c4-42f6-b9a2-ce714195300a","disableCertificateVerification":false},"role":"","bootMACAddress":"00:00:00:aa:bb:03","hardwareProfile":""}],"clusterProvisioningIP":"172.22.0.3","provisioningNetwork":"Managed","provisioningNetworkInterface":"enp1s0","provisioningNetworkCIDR":"172.22.0.0/24","provisioningDHCPRange":"172.22.0.10,172.22.0.254"}}}'
133+
creationTimestamp: null
134+
name: ostest
135+
namespace: cluster0
136+
spec:
137+
apiVIPs:
138+
- 192.168.111.5
139+
clusterDeploymentRef:
140+
name: ostest
141+
imageSetRef:
142+
name: openshift-was not built correctly
143+
ingressVIPs:
144+
- 192.168.111.4
145+
networking:
146+
clusterNetwork:
147+
- cidr: 10.128.0.0/14
148+
hostPrefix: 23
149+
machineNetwork:
150+
- cidr: 192.168.111.0/24
151+
networkType: OVNKubernetes
152+
serviceNetwork:
153+
- 172.30.0.0/16
154+
platformType: BareMetal
155+
provisionRequirements:
156+
controlPlaneAgents: 3
157+
sshPublicKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDK6UTEydcEKzuNdPaofn8Z2DwgHqdcionLZBiPf/zIRNco++etLsat7Avv7yt04DINQd5zjxIFgG8jblaUB5E5C9ClUcMwb52GO0ay2Y9v1uBv1a4WhI3peKktAzYNk0EBMQlJtXPjRMrC9ylBPh+DsBHMu+KmDnfk7PIwyN4efC8k5kSRuPWoNdme1rz2+umU8FSmaWTHIajrbspf4GQbsntA5kuKEtDbfoNCU97o2KrRnUbeg3a8hwSjfh3u6MhlnGcg5K2Ij+zivEsWGCLKYUtE1ErqwfIzwWmJ6jnV66XCQGHf4Q1iIxqF7s2a1q24cgG2Z/iDXfqXrCIfy4P7b/Ztak3bdT9jfAdVZtdO5/r7I+O5hYhF86ayFlDWzZWP/ByiSb+q4CQbfVgK3BMmiAv2MqLHdhesmD/SmIcoOWUF6rFmRKZVFFpKpt5ATNTgUJ3JRowoXrrDruVXClUGRiCS6Zabd1rZ3VmTchaPJwtzQMdfIWISXj+Ig+C4UK0=
158+
status:
159+
debugInfo:
160+
eventsURL: ""
161+
logsURL: ""
162+
progress:
163+
totalPercentage: 0

pkg/asset/agent/agentconfig/agenthosts.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/openshift/installer/pkg/asset"
1515
agentAsset "github.com/openshift/installer/pkg/asset/agent"
1616
"github.com/openshift/installer/pkg/types/agent"
17-
"github.com/openshift/installer/pkg/types/baremetal"
1817
"github.com/openshift/installer/pkg/types/baremetal/validation"
1918
"github.com/openshift/installer/pkg/validate"
2019
)
@@ -66,23 +65,22 @@ func (a *AgentHosts) Generate(dependencies asset.Parents) error {
6665
a.Hosts = append(a.Hosts, agentConfig.Config.Hosts...)
6766
if len(a.Hosts) > 0 {
6867
// Hosts defined in agent-config take precedence
69-
logrus.Infof("Using hosts from %s", agentConfigFilename)
68+
logrus.Debugf("Using hosts from %s", agentConfigFilename)
7069
}
7170
}
7271

7372
if installConfig != nil && installConfig.GetBaremetalHosts() != nil {
74-
icHosts := installConfig.GetBaremetalHosts()
73+
// Only use hosts from install-config if they are not defined in agent-config
7574
if len(a.Hosts) == 0 {
76-
if err := a.getInstallConfigDefaults(icHosts); err != nil {
75+
if err := a.getInstallConfigDefaults(installConfig); err != nil {
7776
return errors.Wrapf(err, "invalid host definition in %s", agentAsset.InstallConfigFilename)
7877
}
79-
}
80-
if len(a.Hosts) > 0 && len(icHosts) > 0 {
78+
} else {
8179
logrus.Warnf(fmt.Sprintf("hosts from %s are ignored", agentAsset.InstallConfigFilename))
8280
}
8381
}
8482

85-
if err := a.validateAgentHosts().ToAggregate(); err != nil {
83+
if err := a.validateAgentHosts(installConfig).ToAggregate(); err != nil {
8684
return errors.Wrapf(err, "invalid Hosts configuration")
8785
}
8886

@@ -99,7 +97,7 @@ func (a *AgentHosts) Load(f asset.FileFetcher) (bool, error) {
9997
return false, nil
10098
}
10199

102-
func (a *AgentHosts) validateAgentHosts() field.ErrorList {
100+
func (a *AgentHosts) validateAgentHosts(installConfig *agentAsset.OptionalInstallConfig) field.ErrorList {
103101
allErrs := field.ErrorList{}
104102

105103
macs := make(map[string]bool)
@@ -198,12 +196,8 @@ func (a *AgentHosts) validateRendezvousIPNotWorker(rendezvousIP string, hosts []
198196
}
199197

200198
// Add the baremetal hosts defined in install-config to the agent Hosts.
201-
func (a *AgentHosts) getInstallConfigDefaults(hosts []*baremetal.Host) error {
202-
if hosts == nil {
203-
return nil
204-
}
205-
206-
for _, icHost := range hosts {
199+
func (a *AgentHosts) getInstallConfigDefaults(installConfig *agentAsset.OptionalInstallConfig) error {
200+
for _, icHost := range installConfig.GetBaremetalHosts() {
207201
if icHost.BootMACAddress == "" {
208202
return errors.New("host bootMACAddress is required")
209203
}
@@ -221,8 +215,6 @@ func (a *AgentHosts) getInstallConfigDefaults(hosts []*baremetal.Host) error {
221215
return errors.Wrap(err, "failed to unmarshal networkConfig")
222216
}
223217
host.NetworkConfig.Raw = contents
224-
logrus.Warningf("hostNetworkconfig.Raw %s", icHost.NetworkConfig.Raw)
225-
logrus.Warningf("contents %s", contents)
226218

227219
// Create interfaces table from NetworkConfig
228220
var netInterfaces nmStateInterface
@@ -258,7 +250,10 @@ func (a *AgentHosts) getInstallConfigDefaults(hosts []*baremetal.Host) error {
258250
host.Interfaces = append(host.Interfaces, hostInterface)
259251
}
260252

261-
logrus.Infof("Using hosts from %s", agentAsset.InstallConfigFilename)
253+
// Add BMC configuration
254+
host.BMC = icHost.BMC
255+
256+
logrus.Debugf("Using host %s from %s", host.Hostname, agentAsset.InstallConfigFilename)
262257
a.Hosts = append(a.Hosts, host)
263258
}
264259
return nil

pkg/asset/agent/installconfig.go

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/openshift/installer/pkg/types"
1616
"github.com/openshift/installer/pkg/types/baremetal"
1717
baremetaldefaults "github.com/openshift/installer/pkg/types/baremetal/defaults"
18+
baremetalvalidation "github.com/openshift/installer/pkg/types/baremetal/validation"
1819
"github.com/openshift/installer/pkg/types/external"
1920
"github.com/openshift/installer/pkg/types/none"
2021
"github.com/openshift/installer/pkg/types/validation"
@@ -117,6 +118,10 @@ func (a *OptionalInstallConfig) validateSupportedPlatforms(installConfig *types.
117118
allErrs = append(allErrs, a.validateVSpherePlatform(installConfig)...)
118119
}
119120

121+
if installConfig.Platform.Name() == baremetal.Name {
122+
allErrs = append(allErrs, a.validateBMCConfig(installConfig)...)
123+
}
124+
120125
return allErrs
121126
}
122127

@@ -256,6 +261,25 @@ func (a *OptionalInstallConfig) GetBaremetalHosts() []*baremetal.Host {
256261
return nil
257262
}
258263

264+
func (a *OptionalInstallConfig) validateBMCConfig(installConfig *types.InstallConfig) field.ErrorList {
265+
var allErrs field.ErrorList
266+
267+
bmcConfigured := false
268+
for _, host := range installConfig.Platform.BareMetal.Hosts {
269+
if host.BMC.Address == "" {
270+
continue
271+
}
272+
bmcConfigured = true
273+
}
274+
275+
if bmcConfigured {
276+
fieldPath := field.NewPath("Platform", "BareMetal")
277+
allErrs = append(allErrs, baremetalvalidation.ValidateProvisioningNetworking(installConfig.Platform.BareMetal, installConfig.Networking, fieldPath)...)
278+
}
279+
280+
return allErrs
281+
}
282+
259283
func warnUnusedConfig(installConfig *types.InstallConfig) {
260284
// "Proxyonly" is the default set from generic install config code
261285
if installConfig.AdditionalTrustBundlePolicy != "Proxyonly" {
@@ -298,14 +322,6 @@ func warnUnusedConfig(installConfig *types.InstallConfig) {
298322
fieldPath := field.NewPath("Platform", "Baremetal", "LibvirtURI")
299323
logrus.Debugf(fmt.Sprintf("%s: %s is ignored", fieldPath, baremetal.LibvirtURI))
300324
}
301-
if baremetal.ClusterProvisioningIP != defaultBM.ClusterProvisioningIP {
302-
fieldPath := field.NewPath("Platform", "Baremetal", "ClusterProvisioningIP")
303-
logrus.Warnf(fmt.Sprintf("%s: %s is ignored", fieldPath, baremetal.ClusterProvisioningIP))
304-
}
305-
if baremetal.DeprecatedProvisioningHostIP != defaultBM.DeprecatedProvisioningHostIP {
306-
fieldPath := field.NewPath("Platform", "Baremetal", "ProvisioningHostIP")
307-
logrus.Warnf(fmt.Sprintf("%s: %s is ignored", fieldPath, baremetal.DeprecatedProvisioningHostIP))
308-
}
309325
if baremetal.BootstrapProvisioningIP != defaultBM.BootstrapProvisioningIP {
310326
fieldPath := field.NewPath("Platform", "Baremetal", "BootstrapProvisioningIP")
311327
logrus.Debugf(fmt.Sprintf("%s: %s is ignored", fieldPath, baremetal.BootstrapProvisioningIP))
@@ -314,48 +330,12 @@ func warnUnusedConfig(installConfig *types.InstallConfig) {
314330
fieldPath := field.NewPath("Platform", "Baremetal", "ExternalBridge")
315331
logrus.Warnf(fmt.Sprintf("%s: %s is ignored", fieldPath, baremetal.ExternalBridge))
316332
}
317-
if baremetal.ProvisioningNetwork != defaultBM.ProvisioningNetwork {
318-
fieldPath := field.NewPath("Platform", "Baremetal", "ProvisioningNetwork")
319-
logrus.Warnf(fmt.Sprintf("%s: %s is ignored", fieldPath, baremetal.ProvisioningNetwork))
320-
}
321333
if baremetal.ProvisioningBridge != defaultBM.ProvisioningBridge {
322334
fieldPath := field.NewPath("Platform", "Baremetal", "ProvisioningBridge")
323335
logrus.Warnf(fmt.Sprintf("%s: %s is ignored", fieldPath, baremetal.ProvisioningBridge))
324336
}
325-
if baremetal.ProvisioningNetworkInterface != defaultBM.ProvisioningNetworkInterface {
326-
fieldPath := field.NewPath("Platform", "Baremetal", "ProvisioningNetworkInterface")
327-
logrus.Warnf(fmt.Sprintf("%s: %s is ignored", fieldPath, baremetal.ProvisioningNetworkInterface))
328-
}
329-
if baremetal.ProvisioningNetworkCIDR.String() != defaultBM.ProvisioningNetworkCIDR.String() {
330-
fieldPath := field.NewPath("Platform", "Baremetal", "ProvisioningNetworkCIDR")
331-
logrus.Warnf(fmt.Sprintf("%s: %s is ignored", fieldPath, baremetal.ProvisioningNetworkCIDR))
332-
}
333-
if baremetal.DeprecatedProvisioningDHCPExternal != defaultBM.DeprecatedProvisioningDHCPExternal {
334-
fieldPath := field.NewPath("Platform", "Baremetal", "ProvisioningDHCPExternal")
335-
logrus.Warnf(fmt.Sprintf("%s: true is ignored", fieldPath))
336-
}
337-
if baremetal.ProvisioningDHCPRange != defaultBM.ProvisioningDHCPRange {
338-
fieldPath := field.NewPath("Platform", "Baremetal", "ProvisioningDHCPRange")
339-
logrus.Warnf(fmt.Sprintf("%s: %s is ignored", fieldPath, baremetal.ProvisioningDHCPRange))
340-
}
341337

342338
for i, host := range baremetal.Hosts {
343-
if host.BMC.Username != "" {
344-
fieldPath := field.NewPath("Platform", "Baremetal", fmt.Sprintf("Hosts[%d]", i), "BMC", "Username")
345-
logrus.Warnf(fmt.Sprintf("%s: %s is ignored", fieldPath, host.BMC.Username))
346-
}
347-
if host.BMC.Password != "" {
348-
fieldPath := field.NewPath("Platform", "Baremetal", fmt.Sprintf("Hosts[%d]", i), "BMC", "Password")
349-
logrus.Warnf(fmt.Sprintf("%s is ignored", fieldPath))
350-
}
351-
if host.BMC.Address != "" {
352-
fieldPath := field.NewPath("Platform", "Baremetal", fmt.Sprintf("Hosts[%d]", i), "BMC", "Address")
353-
logrus.Warnf(fmt.Sprintf("%s: %s is ignored", fieldPath, host.BMC.Address))
354-
}
355-
if host.BMC.DisableCertificateVerification {
356-
fieldPath := field.NewPath("Platform", "Baremetal", fmt.Sprintf("Hosts[%d]", i), "BMC", "DisableCertificateVerification")
357-
logrus.Warnf(fmt.Sprintf("%s: true is ignored", fieldPath))
358-
}
359339
// The default is UEFI. +kubebuilder:validation:Enum="";UEFI;UEFISecureBoot;legacy. Set from generic install config code
360340
if host.BootMode != "UEFI" {
361341
fieldPath := field.NewPath("Platform", "Baremetal", fmt.Sprintf("Hosts[%d]", i), "BootMode")

0 commit comments

Comments
 (0)