Jerzy Suzanowicz

I work mostly with Java, AngularJs, ReactJs, Docker, GKE, K8s, OpenShift.

OKD in one box with libvirt/KVM

01 May 2023 » openshift, okd

On Fedora, CentOS/RHEL:

sudo ./create-kvm.sh

default libvirt network

sudo virsh net-edit default
<network connections='3'>
  <name>default</name>
  <uuid>adea4adb-2e02-4f17-8eaf-1f78f8fab14b</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:f1:f6:86'/>
  <dns>
    <host ip='192.168.124.20'>
      <hostname>bootstrap.okd.suzanowicz.pl</hostname>
    </host>
    <host ip='192.168.124.21'>
      <hostname>master-1.okd.suzanowicz.pl</hostname>
    </host>
    <host ip='192.168.124.22'>
      <hostname>master-2.okd.suzanowicz.pl</hostname>
    </host>
    <host ip='192.168.124.23'>
      <hostname>master-3.okd.suzanowicz.pl</hostname>
    </host>
    <host ip='192.168.124.24'>
      <hostname>worker-1.okd.suzanowicz.pl</hostname>
    </host>
  </dns>
  <ip address='192.168.124.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.124.2' end='192.168.124.254'/>
      <host mac='52:54:00:00:00:20' ip='192.168.124.20'/>
      <host mac='52:54:00:00:00:21' ip='192.168.124.21'/>
      <host mac='52:54:00:00:00:22' ip='192.168.124.22'/>
      <host mac='52:54:00:00:00:23' ip='192.168.124.23'/>
      <host mac='52:54:00:00:00:24' ip='192.168.124.24'/>
    </dhcp>
  </ip>
</network>

/etc/haproxy/haproxy.cfg

global
    log         127.0.0.1 local2 info
    chroot	/var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group	haproxy
    daemon

defaults
    timeout connect         5s
    timeout client          30s
    timeout server          30s
    log                     global

frontend kubernetes_api
    bind 0.0.0.0:6443
    default_backend kubernetes_api
    mode tcp
    option tcplog

backend kubernetes_api
    balance source
    mode tcp
    server bootstrap 192.168.124.20:6443 check
    server master-1 192.168.124.21:6443 check
    server master-2 192.168.124.22:6443 check
    server master-3 192.168.124.23:6443 check

frontend machine_config
    bind 0.0.0.0:22623
    default_backend machine_config
    mode tcp
    option tcplog

backend machine_config
    balance source
    mode tcp
    server bootstrap 192.168.124.20:22623 check
    server master-1 192.168.124.21:22623 check
    server master-2 192.168.124.22:22623 check
    server master-3 192.168.124.23:22623 check
    
frontend router_https
    bind 0.0.0.0:443
    default_backend router_https
    mode tcp
    option tcplog

backend router_https
    balance source
    mode tcp
    server worker-1 192.168.124.24:443 check

frontend router_http
    bind 0.0.0.0:80
    default_backend router_http
    mode tcp
    option tcplog

backend router_http
    balance source
    mode tcp
    server worker-1 192.168.124.24:80 check

restart haproxy

sudo systemctl restart haproxy.service

/etc/hosts

sudo nano /etc/hosts
# Loopback entries; do not change.
# For historical reasons, localhost precedes localhost.localdomain:
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
# See hosts(5) for proper format and other examples:
# 192.168.1.10 foo.mydomain.org foo
# 192.168.1.13 bar.mydomain.org bar
192.168.124.20 bootstrap.okd.suzanowicz.pl bootstrap
192.168.124.21 master-1.okd.suzanowicz.pl master-1
192.168.124.22 master-2.okd.suzanowicz.pl master-2
192.168.124.23 master-3.okd.suzanowicz.pl master-3
192.168.124.24 worker-1.okd.suzanowicz.pl worker-1
192.168.124.1  api.okd.suzanowicz.pl api-int.okd.suzanowicz.pl

trigger install

./openshift-install --dir=/data/okd wait-for bootstrap-complete --log-level=info
ssh core@bootstrap.okd.suzanowicz.pl journalctl -b -f -u bootkube.service

when master cannot get ignition

virsh list --all

sudo setenforce 0
sudo systemctl start firewalld.service
sudo systemctl stop firewalld.service

sudo ./openshift-install --dir=/data/okd wait-for bootstrap-complete --log-level=debug

ssh core@master1.okd.suzanowicz.pl journalctl -b -f -u kubelet.service