Ansible role for installing k3s as either a standalone server or HA cluster.
Go to file
Xan Manning 8f3b2428c8 Added experimental options to ansible role:
1. Ability to specify control host address, for connecting to a control plane
     provisioned outside of the role.
  2. Ability to specify the control host token, again for connecting to
     a control plane provisioned outside of the role.
  3. Included upstream changes from @nolte to define KubeConfig file
     permissions.
2019-12-04 17:17:15 +00:00
defaults Added a number of extra options to configure K3s in systemd unit file. 2019-11-02 22:19:33 +00:00
handlers Added a number of extra options to configure K3s in systemd unit file. 2019-11-02 22:19:33 +00:00
meta Updated Meta to reflect currently supported platforms 2019-11-03 10:56:42 +00:00
molecule/default Added a number of extra options to configure K3s in systemd unit file. 2019-11-02 22:19:33 +00:00
tasks Added experimental options to ansible role: 2019-12-04 17:17:15 +00:00
templates Added experimental options to ansible role: 2019-12-04 17:17:15 +00:00
vagrant Updated for 0.10.0, adding molecule testing with Travis-CI 2019-10-26 22:23:17 +01:00
vars Add support for armv7l arch 2019-04-24 16:15:39 -07:00
.gitignore Updated for 0.10.0, adding molecule testing with Travis-CI 2019-10-26 22:23:17 +01:00
.travis.yml Added a number of extra options to configure K3s in systemd unit file. 2019-11-02 22:19:33 +00:00
.yamllint Updated for 0.10.0, adding molecule testing with Travis-CI 2019-10-26 22:23:17 +01:00
LICENSE Bugfix variable on Docker install, updated README.md and added LICENSE 2019-03-10 14:53:52 +00:00
README.md Added experimental options to ansible role: 2019-12-04 17:17:15 +00:00

README.md

Ansible Role: k3s

Ansible role for installing Racher Labs k3s ("Lightweight Kubernetes") as either a standalone server or cluster.

Build Status

Requirements

This role has been tested on Ansible 2.6.0+ against the following Linux Distributions:

  • Amazon Linux 2
  • CentOS 8
  • CentOS 7
  • Debian 9
  • Debian 10
  • Fedora 29
  • Fedora 30
  • Fedora 31
  • openSUSE Leap 15
  • Ubuntu 18.04 LTS

Disclaimer

⚠️ Not suitable for production use.

Whilst Rancher Labs are awesome, k3s is a fairly new project and not yet a v1.0 release so extreme caution and operational rigor is recommended before using this role for any serious development.

Role Variables

Group Variables

Below are variables that are set against all of the play hosts for environment consistency.

Variable Description Default Value
k3s_release_version Use a specific version of k3s, eg. v0.2.0. Specify false for latest. false
k3s_github_url Set the GitHub URL to install k3s from. https://github.com/rancher/k3s
k3s_install_dir Installation directory for k3s. /usr/local/bin
k3s_control_workers Are control hosts also workers? true
k3s_control_node_address Use a specific control node address. IP or FQDN. NULL
k3s_control_token Use a specific control token, please read notes below. NULL
k3s_https_port HTTPS port listening port. 6443
k3s_use_docker Use Docker rather than Containerd? false
k3s_no_flannel Do not use Flannel false
k3s_flannel_backend Flannel backend ('none', 'vxlan', 'ipsec', or 'wireguard') vxlan
k3s_no_coredns Do not use CoreDNS false
k3s_cluster_dns Cluster IP for CoreDNS service. Should be in your service-cidr range. NULL
k3s_cluster_domain Cluster Domain. cluster.local
k3s_no_traefik Do not use Traefik false
k3s_no_servicelb Do not use ServiceLB, necessary for using something like MetalLB. false
k3s_disable_scheduler Disable Kubernetes default scheduler false
k3s_disable_cloud_controller Disable k3s default cloud controller manager. false
k3s_disable_network_policy Disable k3s default network policy controller. false
k3s_write_kubeconfig_mode Define the file mode from the generated KubeConfig, eg. 644 NULL

Important note about k3s_release_version

If you do not set a k3s_release_version the latest version of k3s will be installed. If you are developing against a specific version of k3s you must ensure this is set in your Ansible configuration, eg:

k3s_release_version: v0.2.0

Important notes about k3s_control_node_address and k3s_control_token

If you set this, you are explicitly specifying the control host that agents should connect to, the value should be an IP address or FQDN.

If the control host is not configured by this role, then you need to also specify the k3s_control_token.

Please note that this may potentially break setting up agents.

Host Variables

Below are variables that are set against specific hosts in your inventory.

Variable Description Default Value
k3s_control_node Define the host as a control plane node, (True/False). false
k3s_node_name Define the name of this node. $(hostname)
k3s_flannel_interface Define the flannel proxy interface for this node. NULL
k3s_bind_address Define the bind address for this node. localhost
k3s_node_ip_address IP Address to advertise for this node. NULL
k3s_node_external_address External IP Address to advertise for this node. NULL
k3s_node_labels List of node labels. NULL
k3s_node_taints List of node taints. NULL

Important note about k3s_control_node

Currently only one host can be defined as a control node, if multiple hosts are set to true the play will fail.

If you do not set a host as a control node, the role will automatically delegate the first play host as a control node.

Important note about k3s_flannel_interface

If you are running k3s on systems with multiple network interfaces, it is necessary to have the flannel interface on a network interface that is routable to the master node(s).

Notes about k3s_node_labels and k3s_node_taints

Both these variables are lists that will be iterated on. The below example will output the following:

YAML:

k3s_node_labels:
  - foo: bar
  - hello: world

k3s_node_taints:
  - key1: value1:NoExecute

ARGS:

--node-label foo=bar \
--node-label hello=world \
--node-taint key1=value1:NoExecute

Dependencies

No dependencies on other roles.

Example Playbook

Example playbook:

- hosts: k3s_nodes
  roles:
     - { role: xanmanning.k3s, k3s_release_version: v0.10.2 }

License

BSD

Author Information

Xan Manning