Created
October 4, 2022 09:37
-
-
Save ralvares/9165194993a11842eff1532a418fc70f to your computer and use it in GitHub Desktop.
sno-staticip version 4.11.5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Updated for OCP 4.11.5 | |
# https://gist.github.com/ralvares/976dce493b43c498cf781f8b8dff28d3 | |
## Download Artifacts | |
# housekeep old vm if necessary | |
virsh destroy master-sno | |
virsh undefine master-sno | |
## openshift-client | |
export OCP_RELEASE=4.11.5 | |
wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/$OCP_RELEASE/openshift-client-linux-$OCP_RELEASE.tar.gz | |
tar xzf openshift-client-linux-$OCP_RELEASE.tar.gz -C /usr/local/bin/ oc kubectl | |
which oc | |
## butane | |
wget https://mirror.openshift.com/pub/openshift-v4/clients/butane/latest/butane -O /usr/local/bin/butane && chmod +x /usr/local/bin/butane | |
## CoreOS live media | |
wget https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/latest/rhcos-4.11.0-x86_64-live.x86_64.iso -O /var/lib/libvirt/images/rhcos-live.x86_64.iso | |
## Downloading coreos-installer | |
wget https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/coreos-installer/latest/coreos-installer -O /usr/local/bin/coreos-installer && chmod +x /usr/local/bin/coreos-installer | |
## Get Pull Secret | |
Download your pull secret from the https://cloud.redhat.com/openshift/install/pull-secret site and save on the file /root/pullsecret.txt | |
## Extract the openshift-baremetal-install installer | |
oc adm release extract -a /root/pullsecret.txt --command=openshift-baremetal-install "quay.io/openshift-release-dev/ocp-release:4.11.5-x86_64" && mv ./openshift-baremetal-install /usr/local/bin/ | |
## Creating install-config.yaml | |
mkdir sno | |
## Variables | |
export IP=192.168.122.200 | |
export GATEWAY=192.168.122.1 | |
export NETMASK=255.255.255.0 | |
export CIDR=24 | |
export INT=ens3 | |
export CLUSTER_NAME=sno | |
export DNS=192.168.122.1 | |
## USING NIP.IO | |
export DOMAIN=${IP}.nip.io | |
## Make sure you have this files created | |
export PULL_SECRET=$(cat /root/pullsecret.txt) | |
export SSH_KEY=$(cat $HOME/.ssh/id_rsa.pub) | |
cat << EOF > sno/install-config.yaml | |
apiVersion: v1beta4 | |
baseDomain: ${DOMAIN} | |
metadata: | |
name: ${CLUSTER_NAME} | |
networking: | |
networkType: OVNKubernetes | |
compute: | |
- name: worker | |
replicas: 0 | |
controlPlane: | |
name: master | |
replicas: 1 | |
platform: | |
none: {} | |
BootstrapInPlace: | |
InstallationDisk: /dev/sda | |
pullSecret: | | |
${PULL_SECRET} | |
sshKey: | | |
${SSH_KEY} | |
EOF | |
## Creating machineconfig to apply the network configuration to the SNO node IP and hostname. | |
cat << EOF > sno/01-master-network.bu | |
variant: openshift | |
version: 4.11.0 | |
metadata: | |
name: 01-master-network-${INT} | |
labels: | |
machineconfiguration.openshift.io/role: master | |
storage: | |
files: | |
- path: /etc/NetworkManager/system-connections/${INT}.nmconnection | |
mode: 0600 | |
overwrite: true | |
contents: | |
inline: | | |
[connection] | |
id=${INT} | |
type=ethernet | |
interface-name=${INT} | |
[ethernet] | |
mtu=1500 | |
[ipv4] | |
address1=${IP}/${CIDR},${GATEWAY} | |
dns=${DNS}; | |
method=manual | |
[ipv6] | |
method=disabled | |
- path: /etc/hostname | |
mode: 0644 | |
overwrite: true | |
contents: | |
inline: | | |
singlenode | |
EOF | |
## Generate the manifests and copy the manifests | |
openshift-baremetal-install --dir=sno create manifests | |
butane sno/01-master-network.bu -o sno/openshift/01-master-network.yaml | |
## Generate the ign file | |
openshift-baremetal-install --dir=sno create single-node-ignition-config | |
## Customizing iso media | |
coreos-installer iso ignition embed -fi /root/sno/bootstrap-in-place-for-live-iso.ign /var/lib/libvirt/images/rhcos-live.x86_64.iso | |
coreos-installer iso kargs modify -a "console=ttyS0 rd.neednet=1 ip=${IP}::${GATEWAY}:${NETMASK}:${HOSTNAME}:${INT}:none nameserver=${DNS}" /var/lib/libvirt/images/rhcos-live.x86_64.iso | |
## Time to test it, you can use VirtualBox, Vmware, or old laptop, just make sure to have the proper network interface name. | |
virt-install --name="master-sno" \ | |
--vcpus=10 \ | |
--ram=131072 \ | |
--disk path=/var/lib/libvirt/images/master-sno.qcow2,bus=sata,size=120 \ | |
--network network=default,model=virtio \ | |
--boot menu=on \ | |
--console pty,target_type=serial \ | |
--cpu host-passthrough \ | |
--cdrom /var/lib/libvirt/images/rhcos-live.x86_64.iso & | |
virsh console master-sno | |
# The machine will reboot 2x.. it might take 30 to 50 minutes to install, it depends on your internet and hardware! | |
# start the install and go grab something! :) | |
openshift-baremetal-install wait-for install-complete --dir /root/sno |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment