bodsch
ansible-k0s
Python

Install and configure a kubernetes cluster using ansible and the vanilla upstream Kubernetes distro k0s.

Last updated Dec 17, 2025
26
Stars
7
Forks
0
Issues
0
Stars/day
Attention Score
4
Language breakdown
Python 95.6%
Jinja 3.0%
Shell 1.3%
Makefile 0.2%
Files click to expand
README

Ansible Role: bodsch.k0s

Create a Kubernetes Cluster using Ansible.

Use vanilla upstream Kubernetes distro k0s.

Similar to movd/k0s-ansible, but better (i think so ;) )

I am currently unable to find a sensible use for a local Kubernetes installation.
I will therefore stop maintaining this repository due to lack of time.

[GitHub Workflow Status][ci] [GitHub issues][issues] [GitHub release (latest by date)][releases] [Ansible Downloads][galaxy]

[ci]: https://github.com/bodsch/ansible-k0s/actions [issues]: https://github.com/bodsch/ansible-k0s/issues?q=is%3Aopen+is%3Aissue [releases]: https://github.com/bodsch/ansible-k0s/releases [galaxy]: https://galaxy.ansible.com/bodsch/k0s

If latest is set for k0s_version, the role tries to install the latest release version. Please use this with caution, as incompatibilities between releases may occur!

The binaries are installed below /usr/local/bin/k0s/${k0s_version} and later linked to /usr/bin. This should make it possible to downgrade relatively safely.

The k0s archive is stored on the Ansible controller, unpacked and then the binaries are copied to the target system. The cache directory can be defined via the environment variable CUSTOMLOCALTMP_DIRECTORY. By default it is ${HOME}/.cache/ansible/k0s. If this type of installation is not desired, the download can take place directly on the target system. However, this must be explicitly activated by setting k0sdirectdownload to true.

Requirements & Dependencies

Ansible Collections

ansible-galaxy collection install bodsch.core
ansible-galaxy collection install bodsch.scm
or
ansible-galaxy collection install --requirements-file collections.yml

Why better?

This Ansible role can be used atomically. If no changes are necessary, none will be made.

Avoid command calls. Wherever possible, separate Ansible modules are used for this.

One role for all cases.

supported Operating systems

Tested on

  • ArchLinux
  • Debian based
- Debian 10 / 11 / 12 - Ubuntu 20.04 / 22.04 / 24.04

working implementation

The example of a working implementation can be viewed at GitLab. A suitable infrastructure based on KVM and Terraform can be created in the repository.

There are some tests in molecule that could be used. For reasons that are not clear to me, the tests in a docker container are not very meaningful. I have therefore extended the tests with the Vagrant driver.

There is a Makefile to start the tests:

make test -e TOX_SCENARIO=multi-worker
make test -e TOX_SCENARIO=vagrant-multi-worker

Contribution

Please read Contribution

Development, Branches (Git Tags)

The master Branch is my Working Horse includes the "latest, hot shit" and can be complete broken!

If you want to use something stable, please use a Tagged Version!

usage

k0s_version: 1.25.2+k0s.0
k0sreleasedownload_url: https://github.com/k0sproject/k0s/releases

k0ssystemuser: k0s k0ssystemgroup: k0s

k0sconfigdir: /etc/k0s k0sdatadir: /var/lib/k0s k0slibexecdir: /usr/libexec/k0s

k0sdirectdownload: false

k0sworkeron_controller: false k0snotaints: false

k0s_force: false k0s_debug: false k0s_verbose: false

k0sclusternodes: initial_controller: "" controllers: [] workers: []

k0sextraarguments: controller: - --enable-metrics-scraper

k0sconfigoverwrites: {}

k0stokenexpiry: "15m"

k0sartifactsdir: "{{ inventory_dir }}/artifacts"

k0sconfigoverwrites

Extension of the automatically created k0s.yaml The structure must correspond to the created configuration. An example file can be viewed here.

single controller

k0sclusternodes:
  initial_controller: controller-1.k0s.local
  controllers: []
  workers: []

one controller with multi workers

k0sclusternodes:
  initial_controller: controller-1.k0s.local
  controllers: []
  workers:
    - worker-1.k0s.local
    - worker-2.k0s.local
    - worker-3.k0s.local

multi controllers with multi workers

k0sclusternodes:
  initial_controller: controller-1.k0s.local
  controllers:
    - controller-2.k0s.local
    - controller-3.k0s.local
  workers:
    - worker-1.k0s.local
    - worker-2.k0s.local
    - worker-3.k0s.local

Credits

other dokumentaions

Upgrading a k0s cluster in-place from single-master to HA

🔗 More in this category

© 2026 GitRepoTrend · bodsch/ansible-k0s · Updated daily from GitHub