2019-03-09 21:54:44 +01:00
|
|
|
---
|
|
|
|
|
2020-12-21 20:14:52 +01:00
|
|
|
# Minimum supported versions
|
2020-11-29 21:10:42 +01:00
|
|
|
k3s_min_version: 1.19.3
|
2021-01-31 13:39:07 +01:00
|
|
|
k3s_ansible_min_version: 2.9.16
|
2021-06-22 21:47:58 +02:00
|
|
|
k3s_python_min_version: 3.6
|
2020-11-29 21:10:42 +01:00
|
|
|
|
2020-10-17 19:26:30 +02:00
|
|
|
# Valid states for this role
|
|
|
|
k3s_valid_states:
|
|
|
|
- installed
|
|
|
|
- started
|
|
|
|
- stopped
|
|
|
|
- restarted
|
|
|
|
- downloaded
|
|
|
|
- uninstalled
|
|
|
|
- validated
|
|
|
|
|
2022-05-03 20:02:02 +02:00
|
|
|
# Supported init systems
|
|
|
|
k3s_supported_init:
|
|
|
|
- systemd
|
|
|
|
- openrc
|
|
|
|
|
2020-10-17 19:26:30 +02:00
|
|
|
# Map ansible fact gathering architecture to a release name and suffix in github.
|
2019-03-09 21:54:44 +01:00
|
|
|
k3s_arch_lookup:
|
|
|
|
amd64:
|
|
|
|
arch: amd64
|
|
|
|
suffix: ""
|
|
|
|
x86_64:
|
|
|
|
arch: amd64
|
|
|
|
suffix: ""
|
|
|
|
arm64:
|
|
|
|
arch: arm64
|
|
|
|
suffix: "-arm64"
|
|
|
|
aarch64:
|
|
|
|
arch: arm64
|
|
|
|
suffix: "-arm64"
|
|
|
|
arm:
|
|
|
|
arch: arm
|
|
|
|
suffix: "-armhf"
|
2021-01-02 17:14:24 +01:00
|
|
|
arm6l:
|
|
|
|
arch: arm
|
|
|
|
suffix: "-armhf"
|
|
|
|
armv6l:
|
|
|
|
arch: arm
|
|
|
|
suffix: "-armhf"
|
2019-03-09 21:54:44 +01:00
|
|
|
arm7:
|
|
|
|
arch: arm
|
|
|
|
suffix: "-armhf"
|
2019-04-25 01:15:39 +02:00
|
|
|
armv7l:
|
|
|
|
arch: arm
|
|
|
|
suffix: "-armhf"
|
2019-03-09 21:54:44 +01:00
|
|
|
armhf:
|
|
|
|
arch: arm
|
|
|
|
suffix: "-armhf"
|
|
|
|
|
2020-10-17 19:26:30 +02:00
|
|
|
# Always default to stable channel, this will change with k3s_release_version
|
2020-05-18 21:45:48 +02:00
|
|
|
k3s_release_channel: stable
|
2020-10-17 19:26:30 +02:00
|
|
|
|
|
|
|
# K3s updates API
|
2021-11-12 11:23:55 +01:00
|
|
|
k3s_api_releases: "{{ k3s_api_url }}/v1-release/channels"
|
2020-10-17 19:26:30 +02:00
|
|
|
# Download location for releases
|
2019-03-09 21:54:44 +01:00
|
|
|
k3s_github_download_url: "{{ k3s_github_url }}/releases/download"
|
2020-10-17 19:26:30 +02:00
|
|
|
|
2021-06-22 21:47:58 +02:00
|
|
|
# Generate a runtime config dictionary
|
|
|
|
k3s_runtime_config: "{{
|
|
|
|
(k3s_control_node is defined and k3s_control_node)
|
2022-09-01 21:39:17 +02:00
|
|
|
| ternary((k3s_server | default({})) | combine(k3s_agent | default({})),
|
2021-06-22 21:47:58 +02:00
|
|
|
(k3s_agent | default({})),
|
2022-09-01 21:39:17 +02:00
|
|
|
(k3s_server | default({})) | combine(k3s_agent | default({})))
|
2021-06-22 21:47:58 +02:00
|
|
|
}}"
|
|
|
|
|
|
|
|
# Determine if a cluster should be built
|
|
|
|
k3s_conf_build_cluster: "{{
|
|
|
|
not ((ansible_play_hosts_all | length < 2)
|
|
|
|
and k3s_registration_address is not defined)
|
|
|
|
}}"
|
2020-12-21 20:14:52 +01:00
|
|
|
|
2020-10-17 19:26:30 +02:00
|
|
|
# Empty array for counting the number of control plane nodes
|
2020-12-21 20:14:52 +01:00
|
|
|
k3s_controller_list: []
|
2024-01-26 21:15:15 +01:00
|
|
|
k3s_running_controller_list: []
|
2020-12-21 20:14:52 +01:00
|
|
|
|
|
|
|
# Control plane port default
|
2021-06-22 21:47:58 +02:00
|
|
|
k3s_control_plane_port: "{{ k3s_runtime_config['https-listen-port'] | default(6443) }}"
|
2019-12-21 18:11:30 +01:00
|
|
|
|
2020-10-17 19:26:30 +02:00
|
|
|
# Default to the "system" systemd context, this will be "user" when running rootless
|
2019-12-21 18:11:30 +01:00
|
|
|
k3s_systemd_context: system
|
2020-10-17 19:26:30 +02:00
|
|
|
|
|
|
|
# Directory for systemd unit files to be installed. As this role doesn't use package
|
|
|
|
# management, this should live in /etc/systemd, not /lib/systemd
|
2020-12-05 22:56:28 +01:00
|
|
|
k3s_systemd_unit_dir: "/etc/systemd/{{ k3s_systemd_context }}"
|
2020-10-17 19:26:30 +02:00
|
|
|
|
2022-05-03 20:02:02 +02:00
|
|
|
# Directory for installing openrc service file
|
|
|
|
k3s_openrc_service_dir: /etc/init.d
|
|
|
|
|
|
|
|
# Directory for installing logrotate config
|
|
|
|
k3s_logrotate_dir: /etc/logrotate.d
|
|
|
|
|
|
|
|
# Service handler
|
|
|
|
k3s_service_handler:
|
|
|
|
systemd: systemd
|
|
|
|
openrc: service
|
|
|
|
|
2020-12-19 15:02:30 +01:00
|
|
|
# Data directory location for k3s
|
2020-12-21 20:14:52 +01:00
|
|
|
k3s_data_dir: "{{ k3s_runtime_config['data-dir'] | default('/var/lib/rancher/k3s') }}"
|
|
|
|
|
2021-09-06 14:46:49 +02:00
|
|
|
# Config directory location for k3s
|
2020-12-21 20:14:52 +01:00
|
|
|
k3s_config_dir: "{{ k3s_config_file | dirname }}"
|
|
|
|
|
|
|
|
# Directory for gathering the k3s token for clustering. I don't see this changing.
|
|
|
|
k3s_token_location: "{{ k3s_config_dir }}/cluster-token"
|
2020-12-19 15:02:30 +01:00
|
|
|
|
2020-10-18 18:41:00 +02:00
|
|
|
# Path for additional Kubernetes Manifests
|
|
|
|
# https://rancher.com/docs/k3s/latest/en/advanced/#auto-deploying-manifests
|
2020-12-19 15:02:30 +01:00
|
|
|
k3s_server_manifests_dir: "{{ k3s_data_dir }}/server/manifests"
|
2020-10-23 17:31:21 +02:00
|
|
|
|
2021-05-26 09:52:34 +02:00
|
|
|
# Path for static pod manifests that are deployed on the control plane
|
2021-05-26 09:43:07 +02:00
|
|
|
# https://github.com/k3s-io/k3s/pull/1691
|
2021-05-26 09:52:34 +02:00
|
|
|
k3s_server_pod_manifests_dir: "{{ k3s_data_dir }}/agent/pod-manifests"
|
2021-05-26 09:43:07 +02:00
|
|
|
|
2021-12-20 21:18:38 +01:00
|
|
|
# OS formatted strings
|
|
|
|
k3s_os_distribution: "{{ ansible_distribution | replace(' ', '-') | lower }}"
|
|
|
|
k3s_os_version: "{{ ansible_distribution_version | replace([' ', '.'], '-') | lower }}"
|
|
|
|
k3s_os_distribution_version: "{{ k3s_os_distribution }}-{{ k3s_os_version }}"
|
2021-12-20 22:14:23 +01:00
|
|
|
k3s_os_family: "{{ ansible_os_family | replace(' ', '-') | lower }}"
|
2021-12-20 21:18:38 +01:00
|
|
|
|
2020-12-21 20:14:52 +01:00
|
|
|
# Packages that we need to check are installed
|
2021-12-19 22:41:59 +01:00
|
|
|
k3s_check_packages:
|
2021-12-20 21:18:38 +01:00
|
|
|
debian-11:
|
|
|
|
- name: iptables-legacy
|
2021-12-19 22:41:59 +01:00
|
|
|
from: 1.19.2
|
2022-02-15 21:57:43 +01:00
|
|
|
until: 1.22.3
|
2021-12-19 22:41:59 +01:00
|
|
|
documentation: https://rancher.com/docs/k3s/latest/en/advanced/#enabling-legacy-iptables-on-raspbian-buster
|
2020-12-21 20:14:52 +01:00
|
|
|
# - name: dummy
|
|
|
|
# from: 1.19.2
|
|
|
|
# until: 1.21.0
|
|
|
|
# documentation: https://example.com
|
|
|
|
|
|
|
|
# Directories that we need to ensure exist
|
|
|
|
k3s_ensure_directories_exist:
|
|
|
|
- name: Config directory
|
|
|
|
path: "{{ k3s_config_dir }}"
|
2021-09-06 14:46:49 +02:00
|
|
|
- name: Config.yaml.d directory
|
|
|
|
path: "{{ k3s_config_yaml_d_dir }}"
|
2020-12-21 20:14:52 +01:00
|
|
|
- name: Systemd unit file directory
|
|
|
|
path: "{{ k3s_systemd_unit_dir }}"
|
|
|
|
- name: Data directory
|
|
|
|
path: "{{ k3s_data_dir }}"
|
|
|
|
- name: Default local storage path
|
|
|
|
path: "{{ k3s_runtime_config['default-local-storage-path'] | default(omit) }}"
|
2021-01-02 17:14:24 +01:00
|
|
|
- name: Private registry config file
|
2021-01-02 17:22:28 +01:00
|
|
|
path: "{{ (k3s_runtime_config['private-registry'] | default(omit)) | dirname }}"
|
2020-12-21 20:14:52 +01:00
|
|
|
|
2020-11-29 21:10:42 +01:00
|
|
|
# Config items that should not appear in k3s_server or k3s_agent
|
2020-10-23 17:31:21 +02:00
|
|
|
k3s_config_exclude:
|
2020-12-05 22:56:28 +01:00
|
|
|
- setting: server
|
2021-03-14 17:29:14 +01:00
|
|
|
correction: k3s_registration_address
|
2020-12-05 22:56:28 +01:00
|
|
|
- setting: cluster-init
|
|
|
|
correction: k3s_etcd_datastore
|
|
|
|
- setting: token
|
|
|
|
correction: k3s_control_token
|
|
|
|
- setting: token-file
|
|
|
|
correction: k3s_token_location
|
2020-11-29 21:10:42 +01:00
|
|
|
|
|
|
|
# Config items and the versions that they were introduced
|
2021-09-08 20:12:33 +02:00
|
|
|
k3s_config_version_check:
|
|
|
|
- setting: etcd-s3-bucket
|
|
|
|
version: 1.20.6 # Prior to this there was very buggy support!
|
2020-11-29 21:10:42 +01:00
|
|
|
|
|
|
|
# Config items that should be marked as experimental
|
|
|
|
k3s_experimental_config:
|
|
|
|
- setting: selinux
|
|
|
|
until: 1.19.4
|
|
|
|
- setting: rootless
|
|
|
|
- setting: secrets-encryption
|
2023-05-02 21:48:34 +02:00
|
|
|
until: 1.23.15
|
2020-12-05 22:56:28 +01:00
|
|
|
- setting: agent-token
|
|
|
|
- setting: agent-token-file
|
|
|
|
- setting: cluster-reset
|
2020-12-12 15:27:59 +01:00
|
|
|
until: 1.19.5
|
2023-10-27 17:22:57 +02:00
|
|
|
- setting: prefer-bundled-bin
|
2020-12-05 22:56:28 +01:00
|
|
|
|
|
|
|
# Config items that should be marked as deprecated
|
|
|
|
k3s_deprecated_config:
|
|
|
|
- setting: no-flannel
|
|
|
|
correction: "flannel-backend: 'none'"
|
|
|
|
# when: 0.10.2 # Example
|
|
|
|
- setting: cluster-secret
|
|
|
|
correction: token
|
|
|
|
- setting: no-deploy
|
|
|
|
correction: "disable: VALUE"
|
2020-12-12 15:27:59 +01:00
|
|
|
- setting: docker
|
|
|
|
correction: "docker: false"
|
|
|
|
when: 1.20.0
|
2021-04-03 21:42:44 +02:00
|
|
|
|
2021-06-22 21:47:58 +02:00
|
|
|
# cgroup checks
|
2021-04-03 21:42:44 +02:00
|
|
|
k3s_cgroup_subsys:
|
|
|
|
- name: memory
|
|
|
|
documentation: |
|
|
|
|
If you are running on a Raspberry Pi, see:
|
|
|
|
https://rancher.com/docs/k3s/latest/en/advanced/#enabling-cgroups-for-raspbian-buster
|
|
|
|
- name: cpuset
|
|
|
|
documentation: |
|
|
|
|
If you are running Alpine Linux, see:
|
|
|
|
https://rancher.com/docs/k3s/latest/en/advanced/#additional-preparation-for-alpine-linux-setup
|
2021-10-10 15:07:04 +02:00
|
|
|
|
|
|
|
# Drain command
|
|
|
|
k3s_drain_command:
|
|
|
|
true: delete-emptydir-data
|
|
|
|
false: delete-local-data
|