Skip to content

Commit a502e90

Browse files
zouy414dtantsur
authored andcommitted
feat: support specifying bmc verify ca
Signed-off-by: Zou Yu <[email protected]>
1 parent c999161 commit a502e90

File tree

6 files changed

+31
-1
lines changed

6 files changed

+31
-1
lines changed

data/data/bootstrap/baremetal/files/etc/containers/systemd/ironic.container.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Volume=ironic.volume:/shared:z
2222
Volume=/opt/openshift/tls/ironic/:/certs/vmedia/:z
2323
{{ end }}
2424
Volume=/opt/openshift/tls/ironic/:/certs/ironic/:z
25+
{{ if ne len(.PlatformData.BareMetal.BMCVerifyCA) 0 }}
26+
Volume=/tmp/cert/ca/bmc:/certs/ca/bmc:z
27+
{{ end }}
2528
Environment="IRONIC_RAMDISK_SSH_KEY=${IRONIC_RAMDISK_SSH_KEY}"
2629
Environment="PROVISIONING_INTERFACE=${PROVISIONING_INTERFACE}"
2730
Environment="OS_CONDUCTOR__HEARTBEAT_TIMEOUT=120"

data/data/bootstrap/baremetal/files/usr/local/bin/build-ironic-env.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ build_ironic_env() {
2323
printf 'CUSTOMIZATION_IMAGE="%s"\n' "$(image_for machine-image-customization-controller)"
2424
printf 'MACHINE_OS_IMAGES_IMAGE="%s"\n' "$(image_for machine-os-images)"
2525

26+
if [[ "$BMC_VERIFY_CA" ]]; then
27+
mkdir -p /tmp/cert/ca/bmc
28+
echo "$BMC_VERIFY_CA" > /tmp/cert/ca/bmc/verify_ca.crt
29+
fi
30+
2631
# set password for ironic basic auth
2732
# The ironic container contains httpd (and thus httpd-tools), so rely on it
2833
# to supply the htpasswd command

data/data/bootstrap/baremetal/systemd/units/build-ironic-env.service.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Environment="PROVISIONING_MAC={{.PlatformData.BareMetal.ProvisioningInterfaceMAC
1010
Environment="PROVISIONING_NETWORK_TYPE={{.PlatformData.BareMetal.ProvisioningNetwork}}"
1111
Environment="IRONIC_IP={{index .PlatformData.BareMetal.APIVIPs 0}}"
1212
Environment="IRONIC_USERNAME={{.PlatformData.BareMetal.IronicUsername}}"
13+
Environment="BMC_VERIFY_CA={{.PlatformData.BareMetal.BMCVerifyCA}}"
1314
ExecStart=/usr/local/bin/build-ironic-env.sh
1415
Type=oneshot
1516
RemainAfterExit=true

data/data/bootstrap/bootstrap-in-place/files/opt/openshift/bootstrap-in-place/bootstrap-in-place-post-reboot.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function wait_for_api {
1313
}
1414

1515
# This is required since the progress service (https://github.com/openshift/installer/blob/dd9047c4c119e942331f702a4b7da85c60042da5/data/data/bootstrap/files/usr/local/bin/report-progress.sh#L22-L33),
16-
# usually dedicated to creating the bootstrap ConfigMap, will fail to create this configmap in case of bootstrap-in-place single node deployment,
16+
# usually dedicated to creating the bootstrap ConfigMap, will fail to create this configmap in case of bootstrap-in-place single node deployment,
1717
# due to the lack of a control plane when bootkube is complete
1818
function signal_bootstrap_complete {
1919
until oc get cm bootstrap -n kube-system &> /dev/null
@@ -24,6 +24,21 @@ function signal_bootstrap_complete {
2424
done
2525
}
2626

27+
function create_bmc_verify_ca_cm {
28+
local ca_storage_dir="/tmp/cert/ca/bmc"
29+
local name="bmc-verify-ca"
30+
local ns="openshift-machine-api"
31+
32+
[[ -d "$ca_storage_dir" ]] || return
33+
34+
until [ "$(oc get cm "${name}" -n "${ns}")" -eq 0 ];
35+
do
36+
echo "Creating bmc verify ca configmap ..."
37+
oc create cm "${name}" -n "${ns}" --from-file="${ca_storage_dir}" || true
38+
sleep 5
39+
done
40+
}
41+
2742
function release_lease {
2843
local ns="$1"
2944
local lease="$2"
@@ -130,6 +145,7 @@ function clean {
130145

131146
wait_for_api
132147
signal_bootstrap_complete
148+
create_bmc_verify_ca_cm
133149
release_cvo_lease
134150
release_cpc_lease
135151
restore_cvo_overrides

pkg/asset/ignition/bootstrap/baremetal/template.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ type TemplateData struct {
8989

9090
// AdditionalNTPServers holds a list of additional NTP servers to be used for provisioning
9191
AdditionalNTPServers []string
92+
93+
BMCVerifyCA string
9294
}
9395

9496
func externalURLs(apiVIPs []string, protocol string) (externalURLv4 string, externalURLv6 string) {
@@ -126,6 +128,7 @@ func GetTemplateData(config *baremetal.Platform, networks []types.MachineNetwork
126128
templateData.ExternalStaticGateway = config.BootstrapExternalStaticGateway
127129
templateData.ExternalStaticDNS = config.BootstrapExternalStaticDNS
128130
templateData.ExternalMACAddress = config.ExternalMACAddress
131+
templateData.BMCVerifyCA = config.BMCVerifyCA
129132

130133
if len(config.AdditionalNTPServers) > 0 {
131134
templateData.AdditionalNTPServers = config.AdditionalNTPServers

pkg/types/baremetal/platform.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,6 @@ type Platform struct {
250250
// +kubebuilder:validation:UniqueItems=true
251251
// +optional
252252
AdditionalNTPServers []string `json:"additionalNTPServers,omitempty"`
253+
254+
BMCVerifyCA string `json:"bmcVerifyCA,omitempty"`
253255
}

0 commit comments

Comments
 (0)