kxr / ocp4_setup_upi_kvm

Script to Setup an OpenShift 4 UPI Cluster on KVM. Based on this guide: https://kxr.me/2019/08/17/openshift-4-upi-install-libvirt-kvm/
52 stars 57 forks source link

adaptions for ubuntu 20.04 #22

Closed max-boehm closed 3 years ago

max-boehm commented 3 years ago

Hi Khizer,

very good script. For making it work on Ubuntu 20.04 I had to do some small adjustments:

Regards, Max

Below is the diff

diff --git a/ocp4_setup_upi_kvm.sh b/ocp4_setup_upi_kvm.sh
index f92f787..57ad084 100755
--- a/ocp4_setup_upi_kvm.sh
+++ b/ocp4_setup_upi_kvm.sh
@@ -519,8 +519,8 @@ for x in virsh virt-install virt-customize systemctl dig wget
 do
     builtin type -P $x &> /dev/null || err "executable $x not found"
 done
-for f in "/usr/lib64/libvirt/connection-driver/libvirt_driver_network.so" \
-         "/usr/share/libvirt/networks/default.xml"
+for f in "/usr/lib/x86_64-linux-gnu/libvirt/connection-driver/libvirt_driver_network.so" \
+         "/etc/libvirt/qemu/networks/default.xml"
 do
     test -e "$f" &> /dev/null || err "file $f not found"
 done
@@ -567,9 +567,9 @@ test -z "$existing" || err "Found existing record in /etc/hosts: $existing" "(Yo
 ok

 echo -n "====> Checking if first entry in resolv.conf is pointing locally: "
-test "$(grep -m1 "^nameserver " /etc/resolv.conf | awk '{print $2}')" = "127.0.0.1" || \
-    err "First entry in /etc/resolv.conf not pointing to 127.0.0.1"
-ok
+#test "$(grep -m1 "^nameserver " /etc/resolv.conf | awk '{print $2}')" = "127.0.0.1" || \
+#    err "First entry in /etc/resolv.conf not pointing to 127.0.0.1"
+#ok

 echo -n "====> Checking if DNS service (dnsmasq or NetworkManager) is active: "
 if [ "$DNS_DIR" -ef "/etc/NetworkManager/dnsmasq.d" ]
@@ -607,7 +607,7 @@ elif [ -n "$VIR_NET_OCT" ]; then
         fi
     fi
     echo -n "====> Creating libvirt network ocp-${VIR_NET_OCT}"
-    /usr/bin/cp /usr/share/libvirt/networks/default.xml /tmp/new-net.xml > /dev/null || err "Network creation failed"
+    /usr/bin/cp /etc/libvirt/qemu/networks/default.xml /tmp/new-net.xml > /dev/null || err "Network creation failed"
     sed -i "s/default/ocp-${VIR_NET_OCT}/" /tmp/new-net.xml
     sed -i "s/virbr0/ocp-${VIR_NET_OCT}/" /tmp/new-net.xml
     sed -i "s/122/${VIR_NET_OCT}/g" /tmp/new-net.xml
@@ -781,6 +781,7 @@ echo -n "====> Downloading Centos 7 cloud image: "; download get "$LB_IMG" "$LB_
 echo -n "====> Copying Image for Loadbalancer VM: "
 cp "${CACHE_DIR}/CentOS-7-x86_64-GenericCloud.qcow2" "${VM_DIR}/${CLUSTER_NAME}-lb.qcow2" || \
     err "Copying '${VM_DIR}/CentOS-7-x86_64-GenericCloud.qcow2' to '${VM_DIR}/${CLUSTER_NAME}-lb.qcow2' failed"; ok
+chown libvirt-qemu.kvm "${VM_DIR}/${CLUSTER_NAME}-lb.qcow2"

 echo "====> Setting up Loadbalancer VM: "
 virt-customize -a "${VM_DIR}/${CLUSTER_NAME}-lb.qcow2" \
@@ -853,7 +854,7 @@ echo "srv-host=xxxtestxxx.${BASE_DOM},yyyayyy.${BASE_DOM},2380,0,10" > ${DNS_DIR
 systemctl $DNS_CMD $DNS_SVC || err "systemctl $DNS_CMD $DNS_SVC failed"; ok

 echo -n "====> Testing SRV record from LB: "
-srv_dig=$(ssh -i sshkey "lb.${CLUSTER_NAME}.${BASE_DOM}" "dig srv +short 'xxxtestxxx.${BASE_DOM}' 2> /dev/null" | grep -q -s "yyyayyy.${BASE_DOM}") || \
+srv_dig=$(ssh -i sshkey "lb.${CLUSTER_NAME}.${BASE_DOM}" "dig +short 'xxxtestxxx.${BASE_DOM}' srv 2> /dev/null" | grep -q -s "yyyayyy.${BASE_DOM}") || \
     err "ERROR: Testing SRV record failed"; ok

 echo -n "====> Cleaning up: "
kxr commented 3 years ago

@max-boehm Thank you for sharing this. I will test these changes and add it to the script.

kxr commented 3 years ago

@max-boehm I have done some restructuring. And this time I am testing the script on ubuntu as well. You diff was helpful. Thanks :)