Kubernetes the hard way lab setup

Материал из noname.com.ua
Перейти к навигацииПерейти к поиску

Настойка лаборатории для K8s

Касается всех нод

Пакеты

apt -y install mc
apt -y install iw
apt -y install i2c-tools
apt -y install python3-smbus python3-netifaces python3-willow
apt -y install python3-rpi.gpio
apt -y install net-tools
apt -y install frr

Консоль

HISTSIZE=100000000
HISTFILESIZE=20000000
HISTTIMEFORMAT="%d/%m/%y %T "
alias date='date -R '
alias ll='ls -lsa'

Ядро

uname -a
Linux master-az3 5.15.0-1014-raspi #16-Ubuntu SMP PREEMPT Thu Aug 25 09:50:55 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

Температура и управление вентилятором

В моем случае ноды питаются от Poe HAT, с дополнительным экраном и охлаждением - для управления этой платой есть отдельный проект

unattended-upgrades

dpkg-reconfigure unattended-upgrades
nano /etc/apt/apt.conf.d/20auto-upgrades

APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Unattended-Upgrade "0";

Схема сети

      +--------------+                                                      +---------------------
      | Master 1    eth0                                                    | Catalyst 3560G
      |              |                                                      |
      |             eth0.101 -- 10.0.11.1/30------VLAN101---10.0.11.2/30 ---+
wifi0-+              |                                                      |
      |             eth0.102 -- 10.0.12.1/30------VLAN102---10.0.12.2/30 ---+ Gi 0/43
      |              |                                                      |
      |             eth0.103 -- 10.0.13.1/30------VLAN101---10.0.13.2/30 ---+
      |              |                                                      |
      |              |                                                      |
      +--------------+                                                      | 
                                                                            |                       
      +--------------+                                                      |
      | Master 2    eth0                                                    | 
      |              |                                                      |
      |             eth0.201 -- 10.0.21.1/30------VLAN201---10.0.21.2/30 ---+
wifi0-+              |                                                      |
      |             eth0.202 -- 10.0.22.1/30------VLAN202---10.0.22.2/30 ---+ Gi 0/44
      |              |                                                      |
      |             eth0.203 -- 10.0.23.1/30------VLAN201---10.0.23.2/30 ---+
      |              |                                                      |
      |              |                                                      |
      +--------------+                                                      | 
                                                                            |                       
      +--------------+                                                      |
      | Master 3    eth0                                                    |
      |              |                                                      |
      |             eth0.301 -- 10.0.31.1/30------VLAN301---10.0.31.2/30 ---+
wifi0-+              |                                                      |
      |             eth0.302 -- 10.0.32.1/30------VLAN302---10.0.32.2/30 ---+ Gi 0/45
      |              |                                                      |
      |             eth0.303 -- 10.0.33.1/30------VLAN301---10.0.33.2/30 ---+
      |              |                                                      |
      |              |                                                      |
      +--------------+                                                      +---------------------

WiFi0 используется исключительно для настройки, в процессе работы никакой траффик через него ходить не будет

  • В номерах VLAN для каждой ноды используется номер ноды что бы проще было запомнить
  • Vlan 101, 201, 301 - используется для etcd

Master Nodes

  • Три ноды которые будут играть роль как master так и worker нод
  • Для лучшего понимания для каждого отдельного сервиса будет назначена своя сеть

master1

network:
    ethernets:
        eth0:
            dhcp4: false
            optional: true
    version: 2
    wifis:
        wlan0:
            access-points:
                ssid-name:
                    password: access-point-password
            dhcp4: true
            optional: true
    vlans:
        eth0.101:
            id: 101
            link: eth0
            addresses: [ "10.0.11.1/30"]
        eth0.102:
            id: 102
            link: eth0
            addresses: [ "10.0.12.1/30"]
        eth0.103:
            id: 103
            link: eth0
            addresses: [ "10.0.13.1/30"]

frr version 8.1
frr defaults traditional
hostname master-az1
log syslog informational
no ipv6 forwarding
service integrated-vtysh-config
!
ip route 10.0.21.0/30 10.0.11.2
ip route 10.0.22.0/30 10.0.12.2
ip route 10.0.23.0/30 10.0.13.2
ip route 10.0.31.0/30 10.0.11.2
ip route 10.0.32.0/30 10.0.12.2
ip route 10.0.33.0/30 10.0.13.2
!
end

master2

network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2
    wifis:
        wlan0:
            access-points:
                ssid-name:
                    password: access-point-password
            dhcp4: true
            optional: true
    vlans:
        eth0.201:
            id: 201
            link: eth0
            addresses: [ "10.0.21.1/30"]
        eth0.202:
            id: 202
            link: eth0
            addresses: [ "10.0.22.1/30"]
        eth0.203:
            id: 203
            link: eth0
            addresses: [ "10.0.23.1/30"]

frr version 8.1
frr defaults traditional
hostname master-az2
log syslog informational
no ipv6 forwarding
service integrated-vtysh-config
!
ip route 10.0.11.0/30 10.0.21.2
ip route 10.0.12.0/30 10.0.22.2
ip route 10.0.13.0/30 10.0.23.2
ip route 10.0.31.0/30 10.0.21.2
ip route 10.0.32.0/30 10.0.22.2
ip route 10.0.33.0/30 10.0.23.2
!
end

master3

network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2
    wifis:
        wlan0:
            access-points:
                ssid-name:
                    password: access-point-password
            dhcp4: true
            optional: true
    vlans:
        eth0.301:
            id: 301
            link: eth0
            addresses: [ "10.0.31.1/30"]
        eth0.302:
            id: 302
            link: eth0
            addresses: [ "10.0.32.1/30"]
        eth0.303:
            id: 303
            link: eth0
            addresses: [ "10.0.33.1/30"]

frr version 8.1
frr defaults traditional
hostname master-az3
log syslog informational
no ipv6 forwarding
service integrated-vtysh-config
!
ip route 10.0.11.0/30 10.0.31.2
ip route 10.0.12.0/30 10.0.32.2
ip route 10.0.13.0/30 10.0.33.2
ip route 10.0.21.0/30 10.0.31.2
ip route 10.0.22.0/30 10.0.32.2
ip route 10.0.23.0/30 10.0.33.2
!
end

Worker Nodes

Catalyst 3550G



vlan 101
 name etcd-az1-k8s-cluster0-home
 mtu 9000
 exit
!
vlan 201
 name etcd-az2-k8s-cluster0-home
 mtu 9000
 exit
!
vlan 301
 name etcd-az3-k8s-cluster0-home
 mtu 9000
 exit
!
vlan 102
 mtu 9000
!
vlan 202
 mtu 9000
!
vlan 302
 mtu 9000
!
vlan 103
 mtu 9000
!
vlan 203
 mtu 9000
!
vlan 303
 mtu 9000
!


 vrf definition k8s-cluster0
 description Cluster 0
 rd 65532:101010



no interface Vlan101
interface Vlan101
 description master-az1-etcd
 vrf forwarding k8s-cluster0
 ip address 10.0.11.2 255.255.255.252
exit
!
no interface Vlan102
interface Vlan102
 vrf forwarding k8s-cluster0
 ip address 10.0.12.2 255.255.255.252
exit

no interface Vlan103
interface Vlan103
 vrf forwarding k8s-cluster0
 ip address 10.0.13.2 255.255.255.252
exit
!
!

no interface Vlan201!
interface Vlan201
 description master-az2-etcd
 vrf forwarding k8s-cluster0
 ip address 10.0.21.2 255.255.255.252
exit
!
no interface Vlan202
interface Vlan202
 vrf forwarding k8s-cluster0
 ip address 10.0.22.2 255.255.255.252
exit
!
no interface Vlan203
interface Vlan203
 vrf forwarding k8s-cluster0
 ip address 10.0.23.2 255.255.255.252
exit
!
!
!
!
no interface Vlan301
interface Vlan301
 description master-az2-etcd
 vrf forwarding k8s-cluster0
 ip address 10.0.31.2 255.255.255.252
exit
!
no interface Vlan302
interface Vlan302
 vrf forwarding k8s-cluster0
 ip address 10.0.32.2 255.255.255.252
exit
!
no interface Vlan303
interface Vlan303
 vrf forwarding k8s-cluster0
 ip address 10.0.33.2 255.255.255.252
exit
!
!
!
!
Current configuration : 247 bytes
!
interface GigabitEthernet0/43
 description master-az1.k8s.cluster0.home
 switchport trunk encapsulation dot1q
 switchport trunk native vlan 2003
 switchport trunk allowed vlan 101-103
 switchport mode trunk
 spanning-tree bpdufilter enable
exit
!
interface GigabitEthernet0/44
 description master-az2.k8s.cluster0.home
 switchport access vlan 2002
 switchport trunk encapsulation dot1q
 switchport trunk native vlan 2002
 switchport trunk allowed vlan 201-203
 switchport mode trunk
 spanning-tree bpdufilter enable
exit
!
interface GigabitEthernet0/45
 description master-az3.k8s.cluster0.home
 switchport access vlan 2001
 switchport trunk encapsulation dot1q
 switchport trunk native vlan 2001
 switchport trunk allowed vlan 301-303
 switchport mode trunk
 spanning-tree bpdufilter enable
exit