The goal here is to allow me to test out OpenShift Container Platform on top of Red Hat OpenStack Platform. I want to be able to build and tear down the environment quickly so I can check out different configurations. OpenStack provides a way for me to do this via snapshots.
The first thing I did was upload a RHEL 7 image. Then I booted and configured two servers from that image:
- Bastion Host
- Master-Infra-AppNode
To configure these servers, I followed the Red Hat Reference Architecture Red Hat OpenShift Container Platform 3 on Red Hat OpenStack Platform 8 up to page 47, right before deploying OpenShift Container Platform. This allowed me to update the servers, configure the interfaces, sudo access, etc... Here are what my servers look like:
$ nova list
+--------------------------------------+---------------------------+---------+------------+-------------+------------------------------------------------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+---------------------------+---------+------------+-------------+------------------------------------------------------------------------+
| 82a42602-030f-4137-94bb-bac5f275dc1b | bastion-gold | SHUTOFF | - | Shutdown | tenant-network=172.18.20.13; control-network=192.168.x.6, 10.19.x.80 |
| 17a505d0-9252-4a65-a0c8-196f6f25e605 | master-infra-appnode-gold | SHUTOFF | - | Shutdown | tenant-network=172.18.20.4; control-network=192.168.x.5, 10.19.x.53 |
+--------------------------------------+---------------------------+---------+------------+-------------+------------------------------------------------------------------------+
After the servers were configured, I shut them down and created an image from each of those servers called "bastion-gold" image, and "master-infra-appnode-gold" image. This will allow for me to create my OpenShift Container Platform environment from these images. The steps I followed to create the snapshots are:
$ openstack server list
$ nova image-create --poll master-infra-appnode-gold sc-master-0.rhops.eng.x.x.redhat.com-snap
$ nova image-create --poll master-infra-appnode-gold sc-node-0.rhops.eng.x.x.redhat.com-snap
$ nova image-create --poll master-infra-appnode-gold sc-node-1.rhops.eng.x.x.redhat.com-snap
$ nova image-create --poll bastion-gold sc-bastion.rhops.eng.x.x.redhat.com-snap
This gives me a snapshot for my OpenShift Container Platform Master, Application and Bastion hosts. My new list of images looks like this:
$ openstack image list
+--------------------------------------+-------------------------------------------+--------+
| ID | Name | Status |
+--------------------------------------+-------------------------------------------+--------+
| fa45f2e3-14bc-4592-8871-c555ea1f5ced | sc-bastion.rhops.eng.x.x.redhat.com-snap | active |
| 8c14bf10-eba5-4968-bbf3-1f327461f8cd | sc-node-1.rhops.eng.x.x.redhat.com-snap | active |
| 128fa2b3-ac04-4465-b9b0-dcfbfbfb77d7 | sc-node-0.rhops.eng.x.x.redhat.com-snap | active |
| 1a8e5507-665e-4657-a09e-f470fa5a5243 | sc-master-0.rhops.eng.x.x.redhat.com-snap | active |
| 86182aaa-dc67-479c-897a-7d6dc3388bb4 | rhel7 | active |
+--------------------------------------+-------------------------------------------+--------+
Now that I have all my snapshots created, I can boot my servers. I am also using cinder volumes for the Docker storage, so I need to create those and attach to the servers. Here's the simple script to create the cinder volumes:
#!/bin/bash
source ./vars.sh
VOLUME_SIZE=${VOLUME_SIZE:-15}
for NODE in $MASTERSAPPS; do
cinder create --name ${NODE}-docker ${VOLUME_SIZE}
done
After the cinder volumes are created, I just need to boot the new servers from the snapshots and attach the cinder volumes. Simple script here:
#!/bin/bash
source ./vars.sh
# Deploy bastion node
nova boot --flavor m1.small --image sc-bastion.rhops.eng.x.x.redhat.com-snap \
--key-name ocp3_rsa \
--nic net-name=control-network --nic net-name=tenant-network \
--user-data=user-data/sc-bastion.yaml \
sc-bastion.${DOMAIN}
# Deploy master node
for HOSTNAME in "sc-master-0"; do
VOLUMEIDMASTER=$(cinder show ${HOSTNAME}.${DOMAIN}-docker | grep ' id ' | awk '{print $4}')
nova boot --flavor m1.large --image sc-master-0.rhops.eng.x.x.redhat.com-snap \
--key-name ocp3_rsa \
--nic net-name=control-network --nic net-name=tenant-network \
--block-device source=volume,dest=volume,device=vdb,id=${VOLUMEIDMASTER} \
--user-data=user-data/${HOSTNAME}.yaml \
sc-master-${HOSTNUM}.${DOMAIN}
done
# Deploy application node 0
for HOSTNAME in "sc-node-0"; do
VOLUMEIDNODE0=$(cinder show ${HOSTNAME}.${DOMAIN}-docker | grep ' id ' | awk '{print $4}')
nova boot --flavor m1.large --image sc-node-0.rhops.eng.x.x.redhat.com-snap \
--key-name ocp3_rsa \
--nic net-name=control-network --nic net-name=tenant-network \
--block-device source=volume,dest=volume,device=vdb,id=${VOLUMEIDNODE0} \
--user-data=user-data/${HOSTNAME}.yaml \
${HOSTNAME}.${DOMAIN}
done
# Deploy application node 1
for HOSTNAME in "sc-node-1"; do
VOLUMEIDNODE1=$(cinder show ${HOSTNAME}.${DOMAIN}-docker | grep ' id ' | awk '{print $4}')
nova boot --flavor m1.large --image sc-node-1.rhops.eng.x.x.redhat.com-snap \
--key-name ocp3_rsa \
--nic net-name=control-network --nic net-name=tenant-network \
--block-device source=volume,dest=volume,device=vdb,id=${VOLUMEIDNODE1} \
--user-data=user-data/${HOSTNAME}.yaml \
${HOSTNAME}.${DOMAIN}
done
Now I'll attach my floating IPs to my Bastion and Master nodes:
openstack server add floating ip sc-bastion.rhops.eng.x.x.redhat.com 10.19.x.80
openstack server add floating ip sc-master-0.rhops.eng.x.x.redhat.com 10.19.x.53
Now, remember, after booting these new servers, you'll need to update DNS with the new IP addresses on your control_network per the reference architecture. You'll also need to adjust your Ansible inventory file to reflect the new IPs. Otherwise, you are now good to go.
To reset my environment, all I have to do is "nova delete" the snapshots, and run the above scripts to get right back to a state where I can re-install OpenShift Container Platform.
Thanks for reading!
P.S. Credit to Mark Lamourine for writing that refarch and letting me "borrow" some of his scripts.
No comments:
Post a Comment