4 Commits

Author SHA1 Message Date
Gabor A aa09e3e9df fix: typos (#416)
Co-authored-by: Techno Tim <timothystewart6@gmail.com>
2024-01-25 20:40:56 +00:00
sholdee 511c410451 Add Debian Bookworm support and refactor Pi OS detection (#415)
* Refactor Pi OS detection and add Debian Bookworm support

* Add bullseye back

---------

Co-authored-by: Techno Tim <timothystewart6@gmail.com>
2024-01-25 19:20:02 +00:00
Balázs Hasprai df9c6f3014 Fix http_proxy service dir in k3s_agent role (#400)
* Fix http_proxy service dir in k3s_agent role

* Fix http_proxy reset: rm conf files before dirs

* Fix http_proxy reset rm order

---------

Co-authored-by: Techno Tim <timothystewart6@gmail.com>
2024-01-25 11:34:46 -06:00
Timothy Stewart 5ae8fd1223 fix(molecule): lower resources for nodes 2024-01-25 09:30:02 -06:00
9 changed files with 49 additions and 73 deletions
+2 -2
View File
@@ -66,9 +66,9 @@ metal_lb_ip_range: "192.168.30.80-192.168.30.90"
# Please read https://gist.github.com/triangletodd/02f595cd4c0dc9aac5f7763ca2264185 before using this. # Please read https://gist.github.com/triangletodd/02f595cd4c0dc9aac5f7763ca2264185 before using this.
# Most notably, your containers must be privileged, and must not have nesting set to true. # Most notably, your containers must be privileged, and must not have nesting set to true.
# Please note this script disables most of the security of lxc containers, with the trade off being that lxc # Please note this script disables most of the security of lxc containers, with the trade off being that lxc
# containers are significantly more resource efficent compared to full VMs. # containers are significantly more resource efficient compared to full VMs.
# Mixing and matching VMs and lxc containers is not supported, ymmv if you want to do this. # Mixing and matching VMs and lxc containers is not supported, ymmv if you want to do this.
# I would only really recommend using this if you have partiularly low powered proxmox nodes where the overhead of # I would only really recommend using this if you have particularly low powered proxmox nodes where the overhead of
# VMs would use a significant portion of your available resources. # VMs would use a significant portion of your available resources.
proxmox_lxc_configure: false proxmox_lxc_configure: false
# the user that you would use to ssh into the host, for example if you run ssh some-user@my-proxmox-host, # the user that you would use to ssh into the host, for example if you run ssh some-user@my-proxmox-host,
+5 -5
View File
@@ -7,7 +7,7 @@ platforms:
- name: control1 - name: control1
box: generic/ubuntu2204 box: generic/ubuntu2204
memory: 4096 memory: 1024
cpus: 2 cpus: 2
groups: groups:
- k3s_cluster - k3s_cluster
@@ -23,7 +23,7 @@ platforms:
- name: control2 - name: control2
box: generic/debian11 box: generic/debian11
memory: 4096 memory: 1024
cpus: 2 cpus: 2
groups: groups:
- k3s_cluster - k3s_cluster
@@ -34,7 +34,7 @@ platforms:
- name: control3 - name: control3
box: generic/rocky9 box: generic/rocky9
memory: 4096 memory: 1024
cpus: 2 cpus: 2
groups: groups:
- k3s_cluster - k3s_cluster
@@ -45,7 +45,7 @@ platforms:
- name: node1 - name: node1
box: generic/ubuntu2204 box: generic/ubuntu2204
memory: 4096 memory: 1024
cpus: 2 cpus: 2
groups: groups:
- k3s_cluster - k3s_cluster
@@ -61,7 +61,7 @@ platforms:
- name: node2 - name: node2
box: generic/rocky9 box: generic/rocky9
memory: 4096 memory: 1024
cpus: 2 cpus: 2
groups: groups:
- k3s_cluster - k3s_cluster
+3 -3
View File
@@ -6,7 +6,7 @@ driver:
platforms: platforms:
- name: control1 - name: control1
box: generic/ubuntu2204 box: generic/ubuntu2204
memory: 4096 memory: 1024
cpus: 2 cpus: 2
groups: groups:
- k3s_cluster - k3s_cluster
@@ -22,7 +22,7 @@ platforms:
- name: control2 - name: control2
box: generic/ubuntu2204 box: generic/ubuntu2204
memory: 4096 memory: 1024
cpus: 2 cpus: 2
groups: groups:
- k3s_cluster - k3s_cluster
@@ -38,7 +38,7 @@ platforms:
- name: node1 - name: node1
box: generic/ubuntu2204 box: generic/ubuntu2204
memory: 4096 memory: 1024
cpus: 2 cpus: 2
groups: groups:
- k3s_cluster - k3s_cluster
+2 -2
View File
@@ -6,8 +6,8 @@ driver:
platforms: platforms:
- name: control1 - name: control1
box: generic/ubuntu2204 box: generic/ubuntu2204
memory: 8192 memory: 4096
cpus: 8 cpus: 4
config_options: config_options:
# We currently can not use public-key based authentication on Ubuntu 22.04, # We currently can not use public-key based authentication on Ubuntu 22.04,
# see: https://github.com/chef/bento/issues/1405 # see: https://github.com/chef/bento/issues/1405
+9 -10
View File
@@ -1,19 +1,18 @@
--- ---
- name: Manage K3s HTTP Proxy Configuration
when: proxy_env is defined - name: Create k3s-node.service.d directory
block: file:
- name: Create k3s.service.d directory path: '{{ systemd_dir }}/k3s-node.service.d'
ansible.builtin.file: state: directory
path: '{{ systemd_dir }}/k3s.service.d'
owner: root owner: root
group: root group: root
state: directory
mode: '0755' mode: '0755'
- name: Deploy the K3s http_proxy configuration file
ansible.builtin.template: - name: Copy K3s http_proxy conf file
template:
src: "http_proxy.conf.j2" src: "http_proxy.conf.j2"
dest: "{{ systemd_dir }}/k3s.service.d/http_proxy.conf" dest: "{{ systemd_dir }}/k3s-node.service.d/http_proxy.conf"
owner: root owner: root
group: root group: root
mode: '0755' mode: '0755'
+8 -20
View File
@@ -1,31 +1,19 @@
--- ---
- name: Check for PXE-booted system
block:
- name: Check if system is PXE-booted
ansible.builtin.command:
cmd: cat /proc/cmdline
register: boot_cmdline
changed_when: false
check_mode: false
- name: Set fact for PXE-booted system - name: Deploy K3s http_proxy conf
ansible.builtin.set_fact: include_tasks: http_proxy.yml
is_pxe_booted: "{{ 'root=/dev/nfs' in boot_cmdline.stdout }}" when: proxy_env is defined
when: boot_cmdline.stdout is defined
- name: Include http_proxy configuration tasks - name: Copy K3s service file
ansible.builtin.include_tasks: http_proxy.yml template:
- name: Configure the k3s service
ansible.builtin.template:
src: "k3s.service.j2" src: "k3s.service.j2"
dest: "{{ systemd_dir }}/k3s-node.service" dest: "{{ systemd_dir }}/k3s-node.service"
owner: root owner: root
group: root group: root
mode: '0755' mode: 0755
- name: Manage k3s service - name: Enable and check K3s service
ansible.builtin.systemd: systemd:
name: k3s-node name: k3s-node
daemon_reload: true daemon_reload: true
state: restarted state: restarted
+3 -6
View File
@@ -7,14 +7,11 @@ After=network-online.target
Type=notify Type=notify
ExecStartPre=-/sbin/modprobe br_netfilter ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay ExecStartPre=-/sbin/modprobe overlay
# Conditional snapshotter based on PXE boot status ExecStart=/usr/local/bin/k3s agent --server https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443 --token {{ hostvars[groups[group_name_master | default('master')][0]]['token'] | default(k3s_token) }} {{ extra_agent_args | default("") }}
ExecStart=/usr/local/bin/k3s agent \
--server https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443 \
{% if is_pxe_booted | default(false) %}--snapshotter native \
{% endif %}--token {{ hostvars[groups[group_name_master | default('master')][0]]['token'] | default(k3s_token) }} \
{{ extra_agent_args | default("") }}
KillMode=process KillMode=process
Delegate=yes Delegate=yes
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=1048576 LimitNOFILE=1048576
LimitNPROC=infinity LimitNPROC=infinity
LimitCORE=infinity LimitCORE=infinity
+8 -18
View File
@@ -17,21 +17,19 @@
when: when:
grep_cpuinfo_raspberrypi.rc == 0 or grep_device_tree_model_raspberrypi.rc == 0 grep_cpuinfo_raspberrypi.rc == 0 or grep_device_tree_model_raspberrypi.rc == 0
- name: Set detected_distribution to Raspbian - name: Set detected_distribution to Raspbian (ARM64 on Raspbian, Debian Buster/Bullseye/Bookworm)
set_fact:
detected_distribution: Raspbian
when: >
raspberry_pi|default(false) and
( ansible_facts.lsb.id|default("") == "Raspbian" or
ansible_facts.lsb.description|default("") is match("[Rr]aspbian.*") )
- name: Set detected_distribution to Raspbian (ARM64 on Debian Buster)
set_fact: set_fact:
detected_distribution: Raspbian detected_distribution: Raspbian
vars:
allowed_descriptions:
- "[Rr]aspbian.*"
- "Debian.*buster"
- "Debian.*bullseye"
- "Debian.*bookworm"
when: when:
- ansible_facts.architecture is search("aarch64") - ansible_facts.architecture is search("aarch64")
- raspberry_pi|default(false) - raspberry_pi|default(false)
- ansible_facts.lsb.description|default("") is match("Debian.*buster") - ansible_facts.lsb.description|default("") is match(allowed_descriptions | join('|'))
- name: Set detected_distribution_major_version - name: Set detected_distribution_major_version
set_fact: set_fact:
@@ -39,14 +37,6 @@
when: when:
- detected_distribution | default("") == "Raspbian" - detected_distribution | default("") == "Raspbian"
- name: Set detected_distribution to Raspbian (ARM64 on Debian Bullseye)
set_fact:
detected_distribution: Raspbian
when:
- ansible_facts.architecture is search("aarch64")
- raspberry_pi|default(false)
- ansible_facts.lsb.description|default("") is match("Debian.*bullseye")
- name: Execute OS related tasks on the Raspberry Pi - {{ action_ }} - name: Execute OS related tasks on the Raspberry Pi - {{ action_ }}
include_tasks: "{{ item }}" include_tasks: "{{ item }}"
with_first_found: with_first_found:
+2
View File
@@ -51,7 +51,9 @@
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
with_items: with_items:
- "{{ systemd_dir }}/k3s.service.d/http_proxy.conf"
- "{{ systemd_dir }}/k3s.service.d" - "{{ systemd_dir }}/k3s.service.d"
- "{{ systemd_dir }}/k3s-node.service.d/http_proxy.conf"
- "{{ systemd_dir }}/k3s-node.service.d" - "{{ systemd_dir }}/k3s-node.service.d"
when: proxy_env is defined when: proxy_env is defined