-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Baremetal: Deploy using CoreOS ISO from the release payload #5473
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
Changes from all commits
570b2b9
d6acf25
8d5c7b1
5f21d99
5944ca7
08b0837
b3a3cb2
7354d0a
d6ae97b
d5eeeae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,11 +4,9 @@ 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) | ||||||
|
|
||||||
| # This image is templated in via the installer pkg/asset/ignition/bootstrap/bootstrap.go | ||||||
| RHCOS_BOOT_IMAGE_URL="{{.BootImage}}" | ||||||
| IRONIC_AGENT_IMAGE=$(image_for ironic-agent) | ||||||
| CUSTOMIZATION_IMAGE=$(image_for image-customization-controller) | ||||||
| MACHINE_OS_IMAGES_IMAGE=$(image_for machine-os-images) | ||||||
|
|
||||||
| # 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. | ||||||
|
|
@@ -19,7 +17,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 | ||||||
|
|
@@ -105,21 +103,11 @@ IP_OPTIONS="ip=dhcp6" | |||||
| IP_OPTIONS="ip=dhcp" | ||||||
| {{ end }} | ||||||
|
|
||||||
| # Set CACHEURL to the the same IP as is used in RHCOS_BOOT_IMAGE_URL, assuming any cache would | ||||||
| # be the same host, if none is found then the downloader containers just skip and download | ||||||
| # from the internet location ( IP=n.n.n.n:nn or [x:x::x]:nn ) | ||||||
| IP=$(echo $RHCOS_BOOT_IMAGE_URL | sed -e 's/.*:\/\/\([^/]*\)\/.*/\1/g' ) | ||||||
| CACHEURL="http://$IP/images" | ||||||
| podman run -d --net host --name coreos-downloader \ | ||||||
| podman run -d --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 \ | ||||||
| ${MACHINE_OS_IMAGES_IMAGE} /bin/copy-metal --all /shared/html/images/ | ||||||
|
|
||||||
| # 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 | ||||||
|
|
@@ -152,11 +140,53 @@ $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}} | ||||||
|
|
||||||
| IRONIC_IP="{{.PlatformData.BareMetal.APIVIP}}" | ||||||
| # If the IP contains a colon, then it's an IPv6 address, and the HTTP | ||||||
| # host needs surrounding with brackets | ||||||
| if [[ "$IRONIC_IP" =~ .*:.* ]]; then | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: The
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied this from a working example. |
||||||
| IRONIC_HOST="[${IRONIC_IP}]" | ||||||
| else | ||||||
| IRONIC_HOST="${IRONIC_IP}" | ||||||
| fi | ||||||
|
|
||||||
| # Embed agent ignition into the rhcos live iso | ||||||
| sudo podman run -d --net host --privileged --name image-customization \ | ||||||
| --env DEPLOY_ISO="/shared/html/images/ironic-python-agent.iso" \ | ||||||
| --env DEPLOY_INITRD="/shared/html/images/ironic-python-agent.initramfs" \ | ||||||
| --env IRONIC_BASE_URL="http://${IRONIC_HOST}" \ | ||||||
| --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 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"]' \ | ||||||
zaneb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| -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 \ | ||||||
|
|
@@ -165,6 +195,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=${IP_OPTIONS} \ | ||||||
| --entrypoint /bin/runironic-conductor \ | ||||||
| -v $AUTH_DIR:/auth:ro \ | ||||||
| -v $IRONIC_SHARED_VOLUME:/shared:z ${IRONIC_IMAGE} | ||||||
|
|
@@ -176,6 +207,7 @@ podman run -d --net host --privileged --name ironic-inspector \ | |||||
| --restart on-failure \ | ||||||
| --env PROVISIONING_INTERFACE=$PROVISIONING_NIC \ | ||||||
| --env HTTP_BASIC_HTPASSWD=${IRONIC_HTPASSWD} \ | ||||||
| --env IRONIC_KERNEL_PARAMS=${IP_OPTIONS} \ | ||||||
| --entrypoint /bin/runironic-inspector \ | ||||||
| -v $AUTH_DIR:/auth:ro \ | ||||||
| -v $IRONIC_SHARED_VOLUME:/shared:z "${IRONIC_IMAGE}" | ||||||
|
|
@@ -216,7 +248,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 | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,13 +50,13 @@ 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.2 | ||
| 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-baremetal v0.0.0-20210924143856-c2d3ece4da38 | ||
| 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 | ||
|
|
@@ -85,7 +85,7 @@ require ( | |
| github.com/vmware/govmomi v0.24.0 | ||
| github.com/zclconf/go-cty v1.8.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 | ||
|
|
@@ -389,7 +389,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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🏆 |
||
| 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.