Improve k3s config template rendering

This commit is contained in:
Khue Doan 2021-09-01 04:58:47 +07:00
parent 92387435c8
commit 713631587c
3 changed files with 3 additions and 18 deletions

View File

@ -39,26 +39,11 @@
content: "{{ k3s_token_base64.content | b64decode }}"
dest: "{{ k3s_token_file }}"
- name: Copy k3s config files to master nodes
- name: Copy k3s config files
when: "'masters' in group_names"
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
vars:
node_role: server
loop:
- src: config.yaml.j2
dest: "{{ k3s_config_file }}"
- src: k3s.service.j2
dest: "{{ k3s_service_file }}"
- name: Copy k3s config files to worker nodes
when: "'workers' in group_names"
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
vars:
node_role: agent
loop:
- src: config.yaml.j2
dest: "{{ k3s_config_file }}"

View File

@ -1 +1 @@
{{ node_role }}
{{ 'server' if 'masters' in group_names else 'agent' }}

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 {{ node_role }}
ExecStart=/usr/local/bin/k3s {{ 'server' if 'masters' in group_names else 'agent' }}
KillMode=process
Delegate=yes
# Having non-zero Limit*s causes performance problems due to accounting overhead