1
0
Fork 0

add amd64 node to cluster

This commit is contained in:
Massaki Archambault 2021-12-14 20:55:52 -05:00
parent 0b3c77d0b3
commit 387f5bccc7
12 changed files with 75 additions and 22 deletions

View File

@ -11,6 +11,7 @@ haproxy:
- 192.168.20.21
- 192.168.20.22
- 192.168.20.23
- 192.168.20.24
# - src:
# - kubernetes-dashboard.badjnet.home
# - traefik.badjnet.home
@ -28,6 +29,7 @@ haproxy:
- 192.168.20.21:30022
- 192.168.20.22:30022
- 192.168.20.23:30022
- 192.168.20.24:30022
letsencrypt:
domains:

8
hosts
View File

@ -45,14 +45,22 @@ all:
hosts:
k3s-s0:
ansible_host: 192.168.20.20
platform: raspberrypi
k3s-agent:
hosts:
k3s-w0:
ansible_host: 192.168.20.21
platform: raspberrypi
k3s-w1:
ansible_host: 192.168.20.22
platform: raspberrypi
k3s-w2:
ansible_host: 192.168.20.23
platform: raspberrypi
k3s-w3:
ansible_host: 192.168.20.24
platform: lxc
k3s_extra_args: --node-taint kubernetes.io/arch=amd64:PreferNoSchedule
debian:
hosts:
ubiquiti:

View File

@ -0,0 +1 @@
k3s_extra_args: ""

View File

@ -6,7 +6,7 @@ After=network-online.target
Type=notify
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s agent --server https://{{ hostvars[groups['k3s-server'][0]]['ansible_facts']['default_ipv4']['address'] }}:6443 --token {{ hostvars[groups['k3s-server'][0]]['token'] }} {{ k3s.extra_agent_args | default("") }}
ExecStart=/usr/local/bin/k3s agent --server https://{{ hostvars[groups['k3s-server'][0]]['ansible_facts']['default_ipv4']['address'] }}:6443 --token {{ hostvars[groups['k3s-server'][0]]['token'] }} {{ k3s.extra_agent_args | default("") }} {{ k3s_extra_args }}
KillMode=process
Delegate=yes
# Having non-zero Limit*s causes performance problems due to accounting overhead

View File

@ -0,0 +1 @@
k3s_extra_args: ""

View File

@ -7,7 +7,7 @@ After=network-online.target
Type=notify
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s server {{ k3s.extra_server_args | default("") }}
ExecStart=/usr/local/bin/k3s server {{ k3s.extra_server_args | default("") }} {{ k3s_extra_args }}
KillMode=process
Delegate=yes
# Having non-zero Limit*s causes performance problems due to accounting overhead

View File

@ -0,0 +1 @@
platform: lxc

10
roles/k3s/files/rc.local Normal file
View File

@ -0,0 +1,10 @@
#!/bin/sh -e
# Kubeadm 1.15 needs /dev/kmsg to be there, but it's not in lxc, but we can just use /dev/console instead
# see: https://github.com/kubernetes-sigs/kind/issues/662
if [ ! -e /dev/kmsg ]; then
ln -s /dev/console /dev/kmsg
fi
# https://medium.com/@kvaps/run-kubernetes-in-lxc-container-f04aa94b6c9c
mount --make-rshared /

16
roles/k3s/tasks/lxc.yml Normal file
View File

@ -0,0 +1,16 @@
- name: Download amd64 k3s binary
get_url:
url: https://github.com/k3s-io/k3s/releases/download/{{ k3s.version }}/k3s
checksum: sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s.version }}/sha256sum-amd64.txt
dest: /usr/local/bin/k3s
owner: root
group: root
mode: 0755
notify: reboot
- name: Configure /etc/rc.local
copy:
src: rc.local
dest: /etc/rc.local
mode: +x
notify: reboot

View File

@ -1,21 +1,7 @@
- name: Download k3s binary
get_url:
url: https://github.com/k3s-io/k3s/releases/download/{{ k3s.version }}/k3s-arm64
checksum: sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s.version }}/sha256sum-arm64.txt
dest: /usr/local/bin/k3s
owner: root
group: root
mode: 0755
notify: reboot
- name: Install required packages
apt:
name:
- open-iscsi
- nfs-common
- name: Configure poe hat fan speed control udev rules
copy:
src: 50-rpi-fan.rules
dest: /etc/udev/rules.d/50-rpi-fan.rules
notify: reboot
- name: Configure kernel command line parameters
copy:
src: cmdline.txt
dest: /boot/firmware/cmdline.txt
notify: reboot
- include_tasks: '{{ platform }}.yml'

View File

@ -0,0 +1,21 @@
- name: Download arm64 k3s binary
get_url:
url: https://github.com/k3s-io/k3s/releases/download/{{ k3s.version }}/k3s-arm64
checksum: sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s.version }}/sha256sum-arm64.txt
dest: /usr/local/bin/k3s
owner: root
group: root
mode: 0755
notify: reboot
- name: Configure poe hat fan speed control udev rules
copy:
src: 50-rpi-fan.rules
dest: /etc/udev/rules.d/50-rpi-fan.rules
notify: reboot
- name: Configure kernel command line parameters
copy:
src: cmdline.txt
dest: /boot/firmware/cmdline.txt
notify: reboot

View File

@ -34,6 +34,13 @@
line: 'acl:1:/:{{ item.key }}@pam:Administrator:'
with_dict: '{{ users }}'
- name: Enable ipv4 packet forwarding
lineinfile:
path: /etc/sysctl.conf
regexp: '^#?net.ipv4.ip_forward='
line: net.ipv4.ip_forward=1
notify: update grub
# - name: Force quorum to always be reached
# lineinfile:
# path: /etc/pve/corosync.conf