Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/actions/upload-a…
Browse files Browse the repository at this point in the history
…rtifact-4.3.1
  • Loading branch information
timothystewart6 committed Feb 6, 2024
2 parents a0f5eed + e4146b4 commit d8145fb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
4 changes: 2 additions & 2 deletions roles/k3s_agent/tasks/http_proxy.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
---

- name: Create k3s-node.service.d directory
file:
path: '{{ systemd_dir }}/k3s-node.service.d'
state: directory
owner: root
group: root
mode: '0755'

when: proxy_env is defined

- name: Copy K3s http_proxy conf file
template:
Expand All @@ -16,3 +15,4 @@
owner: root
group: root
mode: '0755'
when: proxy_env is defined
26 changes: 21 additions & 5 deletions roles/k3s_agent/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
---
- 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
ansible.builtin.set_fact:
is_pxe_booted: "{{ 'root=/dev/nfs' in boot_cmdline.stdout }}"
when: boot_cmdline.stdout is defined

- name: Include http_proxy configuration tasks
ansible.builtin.include_tasks: http_proxy.yml

- name: Deploy K3s http_proxy conf
include_tasks: http_proxy.yml
when: proxy_env is defined

- name: Copy K3s service file
template:
- name: Configure the k3s service
ansible.builtin.template:
src: "k3s.service.j2"
dest: "{{ systemd_dir }}/k3s-node.service"
owner: root
group: root
mode: 0755
mode: '0755'

- name: Enable and check K3s service
systemd:
- name: Manage k3s service
ansible.builtin.systemd:
name: k3s-node
daemon_reload: true
state: restarted
Expand Down
9 changes: 6 additions & 3 deletions roles/k3s_agent/templates/k3s.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ After=network-online.target
Type=notify
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
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("") }}
# Conditional snapshotter based on PXE boot status
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
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
LimitNPROC=infinity
LimitCORE=infinity
Expand Down

0 comments on commit d8145fb

Please sign in to comment.