arillso.container.k3s role – Install and configure K3s lightweight Kubernetes
Note
This role is part of the arillso.container collection (version 2.1.0).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it use: ansible-galaxy collection install arillso.container.
To use it in a playbook, specify: arillso.container.k3s.
Entry point agent – K3s agent entry point
Synopsis
Entry point for K3s worker nodes (agents). Automatically sets k3s_role=agent.
Parameters
Parameter |
Comments |
|---|---|
Node labels to apply Default: |
|
K3s node name |
|
Node taints to apply Default: |
|
K3s server URL to connect to |
|
K3s cluster token |
|
K3s version to install |
Entry point main – Install and configure K3s lightweight Kubernetes
Synopsis
Main entry point for K3s installation with full configuration options. Supports both server and agent roles with manual configuration.
Parameters
Parameter |
Comments |
|---|---|
Allow anonymous requests to the kube-apiserver. When false and k3s_security_hardening is enabled, anonymous-auth=false is passed to the apiserver. Choices:
|
|
Deploy and load the K3s AppArmor profile. When false, any existing profile is unloaded and removed, along with a hand-placed /etc/apparmor.d/disable/k3s symlink. Choices:
|
|
Enable kube-apiserver audit logging on servers. Requires k3s_security_hardening to take effect. Choices:
|
|
Audit level for the catch-all rule in the generated audit policy. Secrets and configmaps are always capped at Metadata regardless of this setting. Choices:
|
|
Retention in days for rotated audit log files Default: |
|
Enable automatic facts collection Choices:
|
|
Expected checksum of the K3s binary Default: |
|
K3s API server bind address Default: |
|
K3s release channel (e.g., stable, latest, testing) Default: |
|
CIDR range for pod IPs Default: |
|
Cluster DNS service IP address Default: |
|
Kubernetes cluster domain Default: |
|
K3s configuration directory path Default: |
|
Maximum number of container log files kept per container, passed to kubelet as container-log-max-files. Set to 0 to omit the flag and leave the kubelet default in place. Default: |
|
Maximum size of a container log file before it is rotated, passed to kubelet as container-log-max-size. An empty string omits the flag and leaves the kubelet default in place. Default: |
|
Create bash completion for kubectl Choices:
|
|
Create K3s killall script Choices:
|
|
Create symlinks for kubectl, crictl, ctr Choices:
|
|
Create K3s uninstall script Choices:
|
|
Deploy and load the cri-containerd AppArmor profile. When false, any existing profile is unloaded and removed (e.g. workaround for kernel 6.17 profile-stacking bugs). Choices:
|
|
K3s data directory path Default: |
|
Enable debug logging in the facts collection script Choices:
|
|
Enable security debugging output Choices:
|
|
Disable built-in cloud controller manager Choices:
|
|
Disable built-in Helm controller Choices:
|
|
Disable built-in local storage provisioner Choices:
|
|
Disable built-in metrics server Choices:
|
|
Disable K3s default network policy controller Choices:
|
|
Disable built-in service load balancer Choices:
|
|
Disable built-in Traefik ingress controller Choices:
|
|
Detect Helm installation and version in facts output Choices:
|
|
Environment variables for K3s service Default: |
|
Expose etcd metrics (`etcd-expose-metrics`). Omitted when undefined. Choices:
|
|
Enable uploading etcd snapshots to an S3-compatible store (`etcd-s3`). Passed through `| bool`, so a string value such as “False” is treated correctly. Omitted when undefined. Choices:
|
|
Access key for the S3-compatible etcd snapshot store (`etcd-s3-access-key`). Rendered into the server config (mode 0600). Omitted when undefined. |
|
S3 bucket for etcd snapshot uploads (`etcd-s3-bucket`). Omitted when undefined. |
|
S3 endpoint host for etcd snapshot uploads (`etcd-s3-endpoint`), without scheme. Omitted when undefined. |
|
Folder/prefix within the S3 bucket for etcd snapshots (`etcd-s3-folder`). Omitted when undefined. |
|
S3 region for etcd snapshot uploads (`etcd-s3-region`, e.g. `auto` for Cloudflare R2). Omitted when undefined. |
|
Secret key for the S3-compatible etcd snapshot store (`etcd-s3-secret-key`). Rendered into the server config (mode 0600). Omitted when undefined. |
|
Directory for local etcd snapshots (`etcd-snapshot-dir`). Omitted when undefined (K3s default location). |
|
Number of etcd snapshots to retain (`etcd-snapshot-retention`). Applies to both local and S3 snapshots. Omitted when undefined. |
|
Cron schedule for automatic etcd snapshots (`etcd-snapshot-schedule-cron`, e.g. `0 */6 * * *`). Omitted when undefined. |
|
Additional arguments for K3s agent Default: |
|
Additional arguments for K3s server Default: |
|
Enable caching of collected K3s facts Choices:
|
|
Cache time-to-live in seconds for K3s facts Default: |
|
Collect cluster state in facts (initialization, health, node counts) Choices:
|
|
Collect health check metrics in facts (duration, timestamps) Choices:
|
|
Collect Ansible inventory group information in facts Choices:
|
|
Collect K3s service status in facts (active, enabled, version) Choices:
|
|
Timeout in seconds for API calls during facts collection Default: |
|
Timeout in seconds for health check commands Default: |
|
Allow fallback mode on errors (outputs error JSON instead of failing) Choices:
|
|
Flannel backend type Choices:
|
|
Pre-sleep before the server API readiness probe (wait_for). Set to 0 to skip the idle wait when running against an already-converged server; timeout/sleep still cover the cold-bootstrap race. Default: |
|
Poll interval for the server API readiness probe (wait_for) Default: |
|
Timeout for the server API readiness probe (wait_for) Default: |
|
K3s HTTPS API server listen port Default: |
|
Install required system packages Choices:
|
|
Group ownership of kubeconfig Default: |
|
File permissions for kubeconfig Default: |
|
Owner of kubeconfig file Default: |
|
Disable the unauthenticated kubelet read-only port 10255. Requires k3s_security_hardening to take effect. Choices:
|
|
Maximum number of pods per node Default: |
|
K3s node IP address Default: |
|
Node labels to apply (format: key=value) Default: |
|
K3s node name (usually inventory_hostname) |
|
Enable the NodeRestriction admission plugin. Requires k3s_security_hardening to take effect. Choices:
|
|
Node taints to apply (format: key=value:effect) Default: |
|
Cluster-wide default Pod Security Admission profile. Empty disables the admission configuration. Requires k3s_security_hardening to take effect. Choices:
|
|
Private container registry configurations Default: |
|
Fail K3s startup when kernel sysctls differ from the kubelet defaults. Off by default because the role does not set those sysctls. Requires k3s_security_hardening. Choices:
|
|
Required system packages for K3s. The NFS client entry defaults to nfs-utils on RedHat and nfs-common elsewhere. Default: |
|
K3s node role - server (control plane) or agent (worker) Choices:
|
|
Enable at-rest encryption of Kubernetes secrets on servers. Requires k3s_security_hardening to take effect. Choices:
|
|
Enable K3s security hardening Choices:
|
|
Apply custom SELinux policy for K3s Choices:
|
|
Initialize K3s cluster (only for first server node) Choices:
|
|
K3s server URL for agents and joining servers Default: |
|
CIDR range for service IPs Default: |
|
Enable K3s service on boot Choices:
|
|
Desired state of K3s service Choices:
|
|
List of commands to create symlinks for Default: |
|
Force overwrite existing symlinks Choices:
|
|
Additional TLS SANs for API server certificate Default: |
|
K3s cluster token for authentication Default: |
|
Set by the role when the token was read from this node’s own node-token file. Such a token is redundant in config.yaml and is left out of the server config, which keeps the file stable across runs. A token fetched from another host is a join credential and is always written. Not intended to be set manually. Choices:
|
|
Path to the K3s node token file Default: |
|
Validate facts output is valid JSON before caching Choices:
|
|
K3s version to install (e.g., v1.35.2+k3s1) |
|
File mode k3s writes the kubeconfig with |
Authors
Simon Bärlocher
Entry point server_init – K3s server initialization entry point
Synopsis
Entry point for initializing a new K3s cluster. Automatically sets k3s_role=server and k3s_server_init=true.
Parameters
Parameter |
Comments |
|---|---|
K3s API server bind address Default: |
|
K3s HTTPS API server listen port Default: |
|
K3s node name |
|
Additional TLS SANs for API server Default: |
|
K3s version to install |
Authors
Simon Bärlocher
Entry point server_join – K3s server join entry point
Synopsis
Entry point for joining additional servers to existing K3s cluster. Automatically sets k3s_role=server and k3s_server_init=false.
Parameters
Parameter |
Comments |
|---|---|
K3s API server bind address Default: |
|
K3s HTTPS API server listen port Default: |
|
K3s node name |
|
K3s server URL to join |
|
K3s cluster token |
|
K3s version to install |
Authors
Simon Bärlocher