Installation of K3s
Tip
We recommend to use the Sandbox to play around with this example.
Tip
All the files from this section are in k3s-installation.zip.
K3s is a lightweight certified Kubernetes distribution. In this section, you will learn one way to install K3s using Ansible.
Note
Please read “Install Script” from K3s’s official documentation for other ways to install K3s.
Inventory
inventories/production.yml
all:
vars:
ansible_user: ansible
k3s:
hosts:
managed_node_01:
Playbook
playbook.yml
- name: Configure K3s
hosts:
- k3s
tasks:
- name: Install K3s
become: true
ansible.builtin.command:
argv:
- apk
- add
- --no-cache
- k3s
Running
cd k3s-installation
ansible-playbook \
--ask-vault-pass \
-i inventories/production.yml \
--extra-vars @vault/production \
playbook.yaml
Note
The password for the vault used in the example is 123. You must use a strong passwords, for example, a minimum of 8 randomly generated characters.
returns
PLAY [Configure K3S] ***********************************************************
TASK [Gathering Facts] *********************************************************
ok: [managed_node_01]
TASK [Install K3S] *************************************************************
changed: [managed_node_01]
PLAY RECAP *********************************************************************
managed_node_01 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0