-
Notifications
You must be signed in to change notification settings - Fork 200
Move ironic to the virt host #75
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
9d273dc
3b4d360
5f01bc4
75e5425
8b8ee80
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 | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,72 @@ | ||||||
| #!/bin/bash | ||||||
|
|
||||||
| set -ex | ||||||
|
|
||||||
| source common.sh | ||||||
|
|
||||||
| # Get the various images | ||||||
| source get_images.sh | ||||||
|
|
||||||
| # ironic dnsmasq and ipxe config | ||||||
| cp ironic/dnsmasq.conf $IRONIC_DATA_DIR/ | ||||||
| cp ironic/dualboot.ipxe ironic/inspector.ipxe $IRONIC_DATA_DIR/html/ | ||||||
|
|
||||||
| # Either pull or build the ironic images | ||||||
| # To build the IRONIC image set | ||||||
| # IRONIC_IMAGE=https://github.com/metalkube/metalkube-ironic | ||||||
| for IMAGE_VAR in IRONIC_IMAGE IRONIC_INSPECTOR_IMAGE ; do | ||||||
| IMAGE=${!IMAGE_VAR} | ||||||
| # Is it a git repo? | ||||||
| if [[ "$IMAGE" =~ "://" ]] ; then | ||||||
| REPOPATH=~/${IMAGE##*/} | ||||||
| # Clone to ~ if not there already | ||||||
| [ -e "$REPOPATH" ] || git clone $IMAGE $REPOPATH | ||||||
| cd $REPOPATH | ||||||
| export $IMAGE_VAR=localhost/${IMAGE##*/}:latest | ||||||
| sudo podman build -t ${!IMAGE_VAR} . | ||||||
| cd - | ||||||
| else | ||||||
| sudo podman pull "$IMAGE" | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
| # Adding an IP address in the libvirt definition for this network results in | ||||||
| # dnsmasq being run, we don't want that as we have our own dnsmasq, so set | ||||||
| # the IP address here | ||||||
| if [ ! -e /etc/sysconfig/network-scripts/ifcfg-brovc ] ; then | ||||||
| echo -e "DEVICE=brovc\nONBOOT=yes\nNM_CONTROLLED=no\nTYPE=Ethernet\nBOOTPROTO=static\nIPADDR=172.22.0.1\nNETMASK=255.255.255.0" | sudo dd of=/etc/sysconfig/network-scripts/ifcfg-brovc | ||||||
| sudo ifdown brovc || true | ||||||
| sudo ifup brovc | ||||||
| fi | ||||||
|
|
||||||
| # Workaround so that the dracut network module does dhcp on eth0 & eth1 | ||||||
| RHCOS_IMAGE_FILENAME_RAW="${RHCOS_IMAGE_FILENAME_OPENSTACK}.raw" | ||||||
| if [ ! -e "$IRONIC_DATA_DIR/html/images/$RHCOS_IMAGE_FILENAME_DUALDHCP" ] ; then | ||||||
| pushd $IRONIC_DATA_DIR/html/images | ||||||
|
Collaborator
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.
Suggested change
|
||||||
| qemu-img convert "$RHCOS_IMAGE_FILENAME_OPENSTACK" "${RHCOS_IMAGE_FILENAME_RAW}" | ||||||
| LOOPBACK=$(sudo losetup --show -f "${RHCOS_IMAGE_FILENAME_RAW}" | cut -f 3 -d /) | ||||||
| mkdir -p /tmp/mnt | ||||||
| sudo kpartx -a /dev/$LOOPBACK | ||||||
| sudo mount /dev/mapper/${LOOPBACK}p1 /tmp/mnt | ||||||
| sudo sed -i -e 's/ip=eth0:dhcp/ip=eth0:dhcp ip=eth1:dhcp/g' /tmp/mnt/grub2/grub.cfg | ||||||
|
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: is it possible that
Collaborator
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. The safest thing would probably be to use augeas cli for this purpose
Collaborator
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. We could make this a little more robust in a later patch, I'm trying as much as possible to just move around the existing code to keep the patch as simple as possible. |
||||||
| sudo umount /tmp/mnt | ||||||
| sudo kpartx -d /dev/${LOOPBACK} | ||||||
| sudo losetup -d /dev/${LOOPBACK} | ||||||
| qemu-img convert -O qcow2 -c "$RHCOS_IMAGE_FILENAME_RAW" "$RHCOS_IMAGE_FILENAME_DUALDHCP" | ||||||
| rm "$RHCOS_IMAGE_FILENAME_RAW" | ||||||
| popd | ||||||
| fi | ||||||
|
|
||||||
|
|
||||||
| for name in ironic ironic-inspector ; do | ||||||
| sudo podman ps | grep -w "$name$" && sudo podman kill $name | ||||||
| sudo podman ps --all | grep -w "$name$" && sudo podman rm $name | ||||||
| done | ||||||
|
|
||||||
| # Start Ironic and inspector | ||||||
| sudo podman run -d --net host --privileged --name ironic \ | ||||||
| -v $IRONIC_DATA_DIR/dnsmasq.conf:/etc/dnsmasq.conf \ | ||||||
| -v $IRONIC_DATA_DIR/html/images:/var/www/html/images \ | ||||||
| -v $IRONIC_DATA_DIR/html/dualboot.ipxe:/var/www/html/dualboot.ipxe \ | ||||||
| -v $IRONIC_DATA_DIR/html/inspector.ipxe:/var/www/html/inspector.ipxe ${IRONIC_IMAGE} | ||||||
| sudo podman run -d --net host --privileged --name ironic-inspector "${IRONIC_INSPECTOR_IMAGE}" | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ source common.sh | |
| # Note This logic will likely run in a container (on the bootstrap VM) | ||
| # for the final solution, but for now we'll prototype the workflow here | ||
| export OS_TOKEN=fake-token | ||
| export OS_URL=http://api.ostest.test.metalkube.org:6385/ | ||
| export OS_URL=http://localhost:6385/ | ||
|
|
||
| wait_for_json ironic \ | ||
| "${OS_URL}/v1/nodes" \ | ||
|
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. Not specific to this patch but I noticed the wait_for_ironic thing doesn't work. I noticed this because the default makefile target is still missing ironic, so the containers weren't ruinning:
Collaborator
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.
Ya, I also noticed this wasn't working, I havn't look into why,
Opps I thought I added it, will fix now. |
||
|
|
@@ -29,7 +29,7 @@ cp ocp/master.ign configdrive/openstack/latest/user_data | |
| for node in $(jq -r .nodes[].name $MASTER_NODES_FILE); do | ||
|
|
||
| # FIXME(shardy) we should parameterize the image | ||
| openstack baremetal node set $node --instance-info image_source=http://172.22.0.1/images/redhat-coreos-maipo-47.284-openstack_dualdhcp.qcow2 --instance-info image_checksum=$(md5sum images/redhat-coreos-maipo-47.284-openstack_dualdhcp.qcow2 | awk '{print $1}') --instance-info root_gb=25 --property root_device="{\"name\": \"$ROOT_DISK\"}" | ||
| openstack baremetal node set $node --instance-info "image_source=http://172.22.0.1/images/$RHCOS_IMAGE_FILENAME_DUALDHCP" --instance-info image_checksum=$(md5sum "$IRONIC_DATA_DIR/html/images/$RHCOS_IMAGE_FILENAME_DUALDHCP" | awk '{print $1}') --instance-info root_gb=25 --property root_device="{\"name\": \"$ROOT_DISK\"}" | ||
| openstack baremetal node manage $node --wait | ||
| openstack baremetal node provide $node --wait | ||
| done | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| .PHONY: default requirements configure repo_sync build ocp_run clean ocp_cleanup libvirt_cleanup | ||
| default: requirements configure repo_sync build ocp_run | ||
| .PHONY: default requirements configure repo_sync ironic build ocp_run clean ocp_cleanup host_cleanup | ||
| default: requirements configure repo_sync ironic build ocp_run | ||
|
|
||
| requirements: | ||
| ./01_install_requirements.sh | ||
|
|
@@ -10,18 +10,21 @@ configure: | |
| repo_sync: | ||
| ./03_ocp_repo_sync.sh | ||
|
|
||
| ironic: | ||
| ./04_setup_ironic.sh | ||
|
|
||
| build: | ||
| ./04_build_ocp_installer.sh | ||
| ./05_build_ocp_installer.sh | ||
|
|
||
| ocp_run: | ||
| ./05_deploy_bootstrap_vm.sh | ||
| ./06_deploy_masters.sh | ||
| ./06_deploy_bootstrap_vm.sh | ||
|
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 think either here or in the default target we need to call 04_setup_ironic.sh?
Collaborator
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. opps, will put it into default |
||
| ./07_deploy_masters.sh | ||
|
|
||
| clean: ocp_cleanup libvirt_cleanup | ||
| clean: ocp_cleanup host_cleanup | ||
|
|
||
| ocp_cleanup: | ||
| ./ocp_cleanup.sh | ||
|
|
||
| libvirt_cleanup: | ||
| ./libvirt_cleanup.sh | ||
| host_cleanup: | ||
| ./host_cleanup.sh | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,15 @@ if [ ! -f "$RHCOS_IMAGE_FILENAME" ]; then | |
| curl --insecure --compressed -L -o "${RHCOS_IMAGE_FILENAME}" "${RHCOS_IMAGE_URL}/${RHCOS_IMAGE_VERSION}/${RHCOS_IMAGE_FILENAME}".gz | ||
| fi | ||
|
|
||
| mkdir -p images | ||
| pushd images | ||
| mkdir -p "$IRONIC_DATA_DIR/html/images" | ||
|
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 had to chown my $WORKING_DIR for this to work, but that could be because I've still got it pointed to /home/stack which was world readable but not writable by my local shardy user.. 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. One thing which would be nice is to move any existing images directory to $IRONIC_DATA_DIR, then any existing users can avoid downloading all-the-things again? :)
Collaborator
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. ok |
||
| # Move images from the old directory to the new one if we have already downloaded them | ||
| # TODO: delete this in a week or so | ||
| if [ -d images ] ; then | ||
| find images -type f -exec mv {} "$IRONIC_DATA_DIR/html/images/" \; | ||
| rmdir images | ||
| fi | ||
|
|
||
| pushd "$IRONIC_DATA_DIR/html/images" | ||
| if [ ! -f "${RHCOS_IMAGE_FILENAME_OPENSTACK}" ]; then | ||
| curl --insecure --compressed -L -o "${RHCOS_IMAGE_FILENAME_OPENSTACK}" "${RHCOS_IMAGE_URL}/${RHCOS_IMAGE_VERSION}/${RHCOS_IMAGE_FILENAME_OPENSTACK}".gz | ||
| fi | ||
|
|
||
This file was deleted.
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.
nit: could
$IRONIC_DATA_DIR/html/imagesdirectory be missing?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.
Its created above in get_images.sh