Install and configure a kubernetes cluster using ansible and the vanilla upstream Kubernetes distro k0s.
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.
[][ci] [
][issues] [
][releases] [
][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
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