Skip to content
Closed
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
2 changes: 2 additions & 0 deletions data/data/baremetal/masters/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ resource "ironic_node_v1" "openshift-master-host" {
power_interface = var.masters[count.index]["power_interface"]
raid_interface = var.masters[count.index]["raid_interface"]
vendor_interface = var.masters[count.index]["vendor_interface"]
deploy_interface = var.masters[count.index]["deploy_interface"]
}

resource "ironic_deployment" "openshift-master-deployment" {
Expand All @@ -48,6 +49,7 @@ resource "ironic_deployment" "openshift-master-deployment" {

instance_info = var.instance_infos[count.index]
user_data = var.ignition_master
deploy_steps = var.deploy_steps[count.index]
}

data "ironic_introspection" "openshift-master-introspection" {
Expand Down
5 changes: 5 additions & 0 deletions data/data/baremetal/variables-baremetal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ variable "instance_infos" {
type = list(map(string))
description = "Instance information for masters"
}

variable "deploy_steps" {
type = list(string)
description = "The contents of custom deploy steps for the node in JSON format"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ set -ex
. /usr/local/bin/release-image.sh

IRONIC_IMAGE=$(image_for ironic)
IPA_DOWNLOADER_IMAGE=$(image_for ironic-ipa-downloader)
COREOS_DOWNLOADER_IMAGE=$(image_for ironic-machine-os-downloader || image_for ironic-rhcos-downloader)
IRONIC_AGENT_IMAGE=$(image_for ironic-agent)
CUSTOMIZATION_IMAGE=$(image_for image-customization-controller)

# This image is templated in via the installer pkg/asset/ignition/bootstrap/bootstrap.go
# This image is templated in via the installer pkg/asset/ignition/bootstrap/common.go
RHCOS_BOOT_IMAGE_URL="{{.BootImage}}"
RHCOS_LIVE_IMAGE_URL="{{.PlatformData.BareMetal.ClusterOSImage}}"

# This DHCP range is used by dnsmasq to serve DHCP to the cluster. If empty
# dnsmasq will only serve TFTP, and DHCP will be disabled.
Expand All @@ -19,7 +21,7 @@ IRONIC_RAMDISK_SSH_KEY="{{.SSHKey}}"

# First we stop any previously started containers, because ExecStop only runs when the ExecStart process
# e.g this script is still running, but we exit if *any* of the containers exits unexpectedly
for name in ironic-api ironic-conductor ironic-inspector ironic-ramdisk-logs dnsmasq httpd mariadb ipa-downloader coreos-downloader; do
for name in ironic-api ironic-conductor ironic-inspector ironic-ramdisk-logs dnsmasq httpd mariadb coreos-downloader image-customization; do
podman ps | grep -w "$name$" && podman kill $name
podman ps --all | grep -w "$name$" && podman rm $name -f
done
Expand Down Expand Up @@ -114,12 +116,7 @@ podman run -d --net host --name coreos-downloader \
--restart on-failure \
--env CACHEURL=${CACHEURL} \
--env IP_OPTIONS=${IP_OPTIONS} \
-v $IRONIC_SHARED_VOLUME:/shared:z ${COREOS_DOWNLOADER_IMAGE} /usr/local/bin/get-resource.sh $RHCOS_BOOT_IMAGE_URL

podman run -d --net host --name ipa-downloader \
--restart on-failure \
--env CACHEURL=${CACHEURL} \
-v $IRONIC_SHARED_VOLUME:/shared:z ${IPA_DOWNLOADER_IMAGE} /usr/local/bin/get-resource.sh
-v $IRONIC_SHARED_VOLUME:/shared:z ${COREOS_DOWNLOADER_IMAGE} /usr/local/bin/get-live-images.sh $RHCOS_BOOT_IMAGE_URL

# Add firewall rules to ensure the IPA ramdisk can reach httpd, Ironic and the Inspector API on the host
for port in 80 5050 6385 ; do
Expand Down Expand Up @@ -152,11 +149,47 @@ $IPTABLES -t raw -A DHCP_IRONIC -j DROP
{{end}}

# Wait for images to be downloaded/ready
podman wait -i 1000ms ipa-downloader
podman wait -i 1000ms coreos-downloader
while ! curl --fail http://localhost/images/rhcos-ootpa-latest.qcow2.md5sum ; do sleep 1; done
while ! curl --fail --head http://localhost/images/ironic-python-agent.initramfs ; do sleep 1; done
while ! curl --fail --head http://localhost/images/ironic-python-agent.kernel ; do sleep 1; done

export KUBECONFIG=/opt/openshift/auth/kubeconfig-loopback

mkdir -p /tmp/nmstate

{{range .PlatformData.BareMetal.Hosts}}
until oc get -n openshift-machine-api baremetalhost {{.Name}}; do
echo Waiting for Host {{.Name}} to appear...
sleep 10
done
secret_name=$(oc get -n openshift-machine-api baremetalhost {{.Name}} -o jsonpath="{.spec.preprovisioningNetworkDataName}")
if [ -n "${secret_name}" ]; then
until oc get -n openshift-machine-api secret "${secret_name}"; do
echo Waiting for Secret "${secret_name}" to appear...
sleep 10
done
oc get -n openshift-machine-api secret ${secret_name} -o jsonpath="{.data.nmstate}" | base64 -d > /tmp/nmstate/{{.Name}}.yaml
else
touch /tmp/nmstate/{{.Name}}.yaml
fi
{{end}}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imain I think that this whole block could be simplified, given that the NetworkConfig field is already available as a template parameter. Ie:

{{range .PlatformData.BareMetal.Hosts}}
  echo "{{.NetworkConfig}}" > /tmp/nmstate/{{.Name}}.yaml
{{end}}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually what I had before. Steve wanted to use the network secrets to get the data. Apparently they could be modified by the user after configuration and before/during deployment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hardys just to clarify, do you have more details about this point? In understood that the main purpose of the secret was for day-2 operation.
During the installation the user is expected to provide the configuration in the install-config.yaml, from where the NetworkConfig field is extracted


# Embed agent ignition into the rhcos live iso
sudo podman run -d -p 8084:8084 --privileged --name image-customization \
--env DEPLOY_ISO="/shared/html/images/ironic-python-agent.iso" \
--env IRONIC_BASE_URL="http://{{.PlatformData.BareMetal.APIVIP}}" \
--env IRONIC_AGENT_IMAGE="" \
--env IRONIC_AGENT_PULL_SECRET="" \
--env IRONIC_RAMDISK_SSH_KEY="$IRONIC_RAMDISK_SSH_KEY" \
--env IRONIC_AGENT_IMAGE="$IRONIC_AGENT_IMAGE" \
--env IRONIC_AGENT_PULL_SECRET="{{.PlatformData.BareMetal.PullSecretBase64}}" \
--env DEPLOY_INITRD="/shared/html/images/ironic-python-agent.initramfs" \
--env PROVISIONING_INTERFACE=$PROVISIONING_NIC \
--env REGISTRIES_CONF_PATH=/tmp/containers/registries.conf \
--entrypoint '["/image-customization-server", "--nmstate-dir=/tmp/nmstate/", "--images-publish-addr=http://0.0.0.0:8084"]' \
-v /tmp/nmstate/:/tmp/nmstate/ \
-v $IRONIC_SHARED_VOLUME:/shared:z \
-v /etc/containers:/tmp/containers:z \
${CUSTOMIZATION_IMAGE}

sudo podman run -d --net host --privileged --name ironic-conductor \
--restart on-failure \
Expand All @@ -165,6 +198,7 @@ sudo podman run -d --net host --privileged --name ironic-conductor \
--env PROVISIONING_INTERFACE=$PROVISIONING_NIC \
--env OS_CONDUCTOR__HEARTBEAT_TIMEOUT=120 \
--env HTTP_BASIC_HTPASSWD=${IRONIC_HTPASSWD} \
--env IRONIC_KERNEL_PARAMS="${IRONIC_KERNEL_PARAMS}" \
--entrypoint /bin/runironic-conductor \
-v $AUTH_DIR:/auth:ro \
-v $IRONIC_SHARED_VOLUME:/shared:z ${IRONIC_IMAGE}
Expand Down Expand Up @@ -216,7 +250,7 @@ while true; do
done

echo "Stopping provisioning services..."
podman stop ironic-api ironic-conductor ironic-inspector ironic-ramdisk-logs $dnsmasq_container_name httpd mariadb
podman stop ironic-api ironic-conductor ironic-inspector ironic-ramdisk-logs $dnsmasq_container_name httpd mariadb image-customization
exit 0
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ spec:
provisioningDHCPRange: "{{.Baremetal.ProvisioningDHCPRange}}"
provisioningOSDownloadURL: "{{.ProvisioningOSDownloadURL}}"
watchAllNamespaces: false
preProvisioningOSDownloadURLs:
initramfsURL: "{{.InitramfsURL}}"
isoURL: "{{.IsoURL}}"
kernelURL: "{{.KernelURL}}"
rootfsURL: "{{.RootfsURL}}"
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ require (
github.com/metal3-io/baremetal-operator v0.0.0-20211201170610-92ffa60c683d
github.com/metal3-io/baremetal-operator/apis v0.0.0
github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.0.0
github.com/metal3-io/cluster-api-provider-baremetal v0.0.0
github.com/mitchellh/cli v1.1.1
github.com/openshift-metal3/terraform-provider-ironic v0.2.6
github.com/openshift-metal3/terraform-provider-ironic v0.2.7
github.com/openshift/api v0.0.0-20211119153416-313e51eab8c8
github.com/openshift/client-go v0.0.0-20211025111749-96ca2abfc56c
github.com/openshift/cloud-credential-operator v0.0.0-20200316201045-d10080b52c9e
github.com/openshift/cluster-api-provider-alibaba v0.0.0-20211123142315-d16daa4e6349
github.com/openshift/cluster-api-provider-gcp v0.0.1-0.20201203141909-4dc702fd57a5
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20210924143856-c2d3ece4da38
github.com/openshift/cluster-api-provider-gcp v0.0.1-0.20210615203611-a02074e8d5bb
github.com/openshift/cluster-api-provider-ibmcloud v0.0.0-20211008100740-4d7907adbd6b
github.com/openshift/cluster-api-provider-libvirt v0.2.1-0.20191219173431-2336783d4603
github.com/openshift/cluster-api-provider-ovirt v0.1.1-0.20211111151530-06177b773958
Expand Down Expand Up @@ -85,7 +85,7 @@ require (
github.com/vmware/govmomi v0.24.0
github.com/zclconf/go-cty v1.6.1
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/lint v0.0.0-20200302205851-738671d3881b
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
google.golang.org/api v0.44.0
Expand Down Expand Up @@ -381,7 +381,6 @@ replace (
github.com/metal3-io/baremetal-operator => github.com/openshift/baremetal-operator v0.0.0-20211201170610-92ffa60c683d // Use OpenShift fork
github.com/metal3-io/baremetal-operator/apis => github.com/openshift/baremetal-operator/apis v0.0.0-20211201170610-92ffa60c683d // Use OpenShift fork
github.com/metal3-io/baremetal-operator/pkg/hardwareutils => github.com/openshift/baremetal-operator/pkg/hardwareutils v0.0.0-20211201170610-92ffa60c683d // Use OpenShift fork
github.com/metal3-io/cluster-api-provider-baremetal => github.com/openshift/cluster-api-provider-baremetal v0.0.0-20190821174549-a2a477909c1d // Pin OpenShift fork
github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20200929181438-91d71ef2122c // Pin client-go
github.com/openshift/machine-config-operator => github.com/openshift/machine-config-operator v0.0.1-0.20201009041932-4fe8559913b8 // Pin MCO so it doesn't get downgraded
github.com/spf13/afero => github.com/spf13/afero v1.2.2
Expand Down
Loading