Skip to content

Commit

Permalink
[feature] rke2-node role: the basics
Browse files Browse the repository at this point in the history
- Install `nfs-common` for the `mount.nfs4` binary
- Disable hardware UDP checksumming, re: flannel-io/flannel#1279
- Make `crictl` work (everywhere), as well as `kubectl` (on control plane nodes only)
  • Loading branch information
Dominique Quatravaux committed Jan 6, 2025
1 parent 21c9000 commit 414b1b6
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
16 changes: 16 additions & 0 deletions roles/rke2-node/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The name of the main interface, to disable UDP checksums on. (See
# ../tasks/no-hardware-udp-checksum.yml)
rancher_rke2_main_network_interface: ens192

# The RKE2 roles. You will probably want to set these separately for
# each node (either explicitly as inventory vars, or using a Jinja
# formula in the `vars:` stanza of the playbook)
rancher_rke2_is_worker: true
rancher_rke2_is_controlplane: true

# True iff the Rancher server *doesn't* provide a globally-valid
# TLS certificate:
rancher_rke2_insecure: true

# ansible_rancher_url doesn't have a default value and must be set; e.g.
#ansible_rancher_url: https://rancher-fsd.epfl.ch
22 changes: 22 additions & 0 deletions roles/rke2-node/tasks/interactive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- name: configure crictl for interactive use
ansible.builtin.blockinfile:
path: /root/.profile
marker: '# {mark} ANSIBLE MANAGED BLOCK - crictl'
block: |
export CRI_CONFIG_FILE=/var/lib/rancher/rke2/agent/etc/crictl.yaml
export CONTAINERD_ADDRESS=unix:///run/k3s/containerd/containerd.sock
export PATH=$PATH:/var/lib/rancher/rke2/bin
# TODO: this assumes recent Ubuntu.
- name: install kubectl
community.general.snap:
name: kubectl
classic: yes
channel: latest/stable

- name: configure kubectl
ansible.builtin.blockinfile:
path: /root/.profile
marker: '# {mark} ANSIBLE MANAGED BLOCK - kubectl'
block: |
export KUBECONFIG=/etc/rancher/rke2/rke2.yaml
29 changes: 29 additions & 0 deletions roles/rke2-node/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
- name: Interactive use / comfort features
tags:
- rke2-node
- rke2-node.interactive
include_tasks:
file: interactive.yml
apply:
tags:
- rke2-node
- rke2-node.interactive

- name: VM platform-specific bugware
tags:
- rke2-node
- rke2-node.udp
- rke2-node.bugware
include_tasks:
file: no-hardware-udp-checksum.yml
apply:
tags:
- rke2-node
- rke2-node.udp
- rke2-node.bugware

- name: Support for NFS volumes
ansible.builtin.apt:
name: nfs-common
state:
present
26 changes: 26 additions & 0 deletions roles/rke2-node/tasks/no-hardware-udp-checksum.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Disable “hardware”-assisted UDP checksumming on VMware VMs to
# work around https://github.com/flannel-io/flannel/issues/1279

- name: udp-checksum-offload-disable.service definition
ansible.builtin.copy:
content: |
; This file is maintained by Ansible
[Unit]
Description=Disable udp checksum offload
Before=rancher-system-agent.service
[Install]
WantedBy=rancher-system-agent.service
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=ethtool --offload {{ rancher_rke2_main_network_interface }} rx off tx off
dest: /etc/systemd/system/udp-checksum-offload-disable.service
register: _ethtool_offload_systemd_definition_file

- name: udp-checksum-offload-disable.service activation
ansible.builtin.systemd_service:
name: udp-checksum-offload-disable.service
state: started
enabled: true
daemon_reload: >
{{ _ethtool_offload_systemd_definition_file | default({}) is changed }}

0 comments on commit 414b1b6

Please sign in to comment.