Last active
September 15, 2023 02:31
-
-
Save ralvares/976dce493b43c498cf781f8b8dff28d3 to your computer and use it in GitHub Desktop.
Installing single node with staticIP and nip.io
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
## Download Artifacts | |
## openshift-client | |
curl -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/4.9/openshift-client-linux.tar.gz | tar zxvf - oc && mv oc /usr/local/bin | |
## 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/4.9.0/rhcos-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/clients/coreos-installer/v0.8.0-3/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.9.8-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.9.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=4 \ | |
--ram=16384 \ | |
--disk path=/home/sno/master-snp.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