Skip to content

Instantly share code, notes, and snippets.

@ralvares
Last active May 3, 2022 16:39
Show Gist options
  • Save ralvares/b61ff8054884c5a9720a314d260ffe2a to your computer and use it in GitHub Desktop.
Save ralvares/b61ff8054884c5a9720a314d260ffe2a to your computer and use it in GitHub Desktop.
Install Single Node Cluster on KVM - for fun
My environment is below:
Centos8
libvirtd (libvirt) 7.0.0
libvirt network: default - Range 192.168.122.0/24
Domain and Single Node IP: *.sno.local 192.168.122.10
Extracting openshift-baremetal-install
export VERSION=latest-4.8
export RELEASE_IMAGE=$(curl -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/$VERSION/release.txt | grep 'Pull From: quay.io' | awk -F ' ' '{print $3}')
export cmd=openshift-baremetal-install
export pullsecret_file=~/pullsecret.txt
curl -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/$VERSION/openshift-client-linux.tar.gz | tar zxvf - oc
sudo cp oc /usr/local/bin
oc adm release extract --registry-config "${pullsecret_file}" --command=$cmd --to . ${RELEASE_IMAGE}
sudo cp ./openshift-baremetal-install /usr/local/bin
Downloading coreos-installer
wget https://mirror.openshift.com/pub/openshift-v4/clients/coreos-installer/v0.8.0-3/coreos-installer
cp ./coreos-installer /usr/local/bin && chmod +x /usr/local/bin/coreos-installer
Downloading rhcos live media
wget https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/latest/4.8.2/rhcos-4.8.2-x86_64-live.x86_64.iso
Preparing the host
yum install centos-release-advanced-virtualization
yum groupinstall "Virtualization Host" -y
yum install virt-install libvirt-client -y
systemctl enable --now libvirtd.service
Checking the libvirt network - default and IP Range
virsh net-dumpxml default | grep -i 192.168.122
Configuring DNS using dnsmas and NetworkManager
Domain: sno.local
SNO NODE IP: 192.168.122.10
yum install dnsmasq
echo -e "[main]\ndns=dnsmasq" | sudo tee /etc/NetworkManager/conf.d/openshift.conf
echo listen-address=127.0.0.1 > /etc/NetworkManager/dnsmasq.d/openshift.conf
echo bind-interfaces >> /etc/NetworkManager/dnsmasq.d/openshift.conf
echo server=185.12.64.1 >> /etc/NetworkManager/dnsmasq.d/openshift.conf
echo server=185.12.64.2 >> /etc/NetworkManager/dnsmasq.d/openshift.conf
echo server=8.8.8.8 >> /etc/NetworkManager/dnsmasq.d/openshift.conf
echo address=/sno.local/192.168.122.10 >> /etc/NetworkManager/dnsmasq.d/openshift.conf
systemctl reload NetworkManager
nslookup master.sno.local
Creating install-config.yaml
mkdir sno
export PULL_SECRET=$(cat /root/pullsecret.txt | jq )
export SSH_KEY=$(cat $HOME/.ssh/id_rsa.pub)
export CLUSTER_NAME=sno
cat << EOF > sno/install-config.yaml
apiVersion: v1beta4
baseDomain: local
metadata:
name: sno
networking:
networkType: OVNKubernetes
machineCIDR: 192.168.122.0/24
compute:
- name: worker
replicas: 0
controlPlane:
name: master
replicas: 1
platform:
none: {}
BootstrapInPlace:
InstallationDisk: /dev/sda
pullSecret: |
${PULL_SECRET}
sshKey: |
${SSH_KEY}
EOF
Generating single node media
openshift-baremetal-install --dir=sno create single-node-ignition-config
coreos-installer iso ignition embed -fi /root/sno/bootstrap-in-place-for-live-iso.ign /root/rhcos-4.8.2-x86_64-live.x86_64.iso
cp -rf rhcos-4.8.2-x86_64-live.x86_64.iso /var/lib/libvirt/images/rhcos-4.8.2-x86_64-live.x86_64.iso
Installing Single Node Cluster
virsh net-update default add ip-dhcp-host "<host mac='52:54:00:65:aa:da' name='master.sno.local' ip='192.168.122.10'/>" --live --config
virt-install --name="master-sno" \
--vcpus=4 \
--ram=32768 \
--disk path=/var/lib/libvirt/images/master-snp.qcow2,bus=sata,size=120 \
--network network=default,model=virtio \
-m 52:54:00:65:aa:da \
--boot menu=on \
--graphics vnc --console pty,target_type=serial --noautoconsole \
--cpu host-passthrough \
--cdrom /var/lib/libvirt/images/rhcos-4.8.2-x86_64-live.x86_64.iso
Let's Grab Some Coffee, it might take around 40 to 60 minutes.
You can check the progress: ( expect lots of erros and ignore it )
openshift-baremetal-install wait-for install-complete --dir /root/sno
export KUBECONFIG=/root/sno/auth/kubeconfig
oc get nodes
oc get co
oc get clusterversion
Have fun.
@rcarrata
Copy link

rcarrata commented Sep 30, 2021

@ralvares line 62 refers to pullsecret.txt but in the line 13 you're exporting pull-secret.txt

in line 62 the command (at least in centos8) not worked properly:

export PULL_SECRET=$(cat /root/pull-secret.txt | jq -c)                                                                             
jq - commandline JSON processor [version 1.5]                                                                                                 
Usage: jq [options] <jq filter> [file...]                                                                                                     

the cat | jq itself is working, but the export with the passing vars are failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment