Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finished k3s-ha implementation; Add three (3) cluster VIP methods implemented via ansible #166

Closed
wants to merge 109 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
3030e32
Support HA mode with embedded DB
St0rmingBr4in Dec 12, 2020
bb0e3c9
Add custom configuration of the apiserver endpoint for HA mode
St0rmingBr4in Feb 14, 2021
dce6849
Fix and improve master registration verification
St0rmingBr4in Mar 13, 2021
5816c03
Rename kubectl set-cluster task
St0rmingBr4in Mar 13, 2021
59b20d4
Hint for k3s-init.service if initialization fails
St0rmingBr4in Mar 23, 2021
4ed5599
Fix k3s_token default value
St0rmingBr4in Mar 29, 2021
21a4ba9
FIX #159: Updated roles/reset to perform all actions as does k3s-unin…
jon-stumpf Dec 13, 2021
99e8b38
FIX #160: Moved k3s_server_location to group_vars/all.yml so roles/re…
jon-stumpf Dec 14, 2021
b3e2df8
FIX #161: Updated pkill to use k3s_server_location in roles/reset/tas…
jon-stumpf Dec 14, 2021
0196954
Addressed errors introduced in last two commits due to k3s_server_loc…
jon-stumpf Dec 15, 2021
4357ad9
FIX #162: Fixed errors with symlink'd commands when k3s_server_locati…
jon-stumpf Dec 15, 2021
a67e52d
FIX #163: Removed ~/.kube/config on reset
jon-stumpf Dec 15, 2021
03b8468
Fixed name for task
jon-stumpf Dec 15, 2021
86bb515
Replace name: labels with path:
jon-stumpf Dec 15, 2021
244e6a5
Refactored roles/download/tasks/main.yml and implemented feature to u…
jon-stumpf Dec 14, 2021
97830ee
Added support to change the bin directory; Fixed same bug as in PR#14…
jon-stumpf Dec 14, 2021
a187676
Implemented install_k3s_symlink and install_k3s_bin_dir_read_only
jon-stumpf Dec 14, 2021
90efdd0
Renamed k3s_server_location to data_dir to be consistent; Added insta…
jon-stumpf Dec 15, 2021
600a375
Reorder roles/k3s/master/tasks/main.yml and add comments
jon-stumpf Dec 16, 2021
33c71de
Made data_dir apply to all cluster hosts, not just master hosts
jon-stumpf Dec 16, 2021
d28c72a
Not implementing INSTALL_K3S_SKIP_DOWNLOAD, INSTALL_K3S_FORCE_RESTART…
jon-stumpf Dec 16, 2021
3b8842f
Added capability to download the version from a channel (e.g., 'stable')
jon-stumpf Dec 19, 2021
588c17e
Changed option install_k3s_symlink to 'skip'
jon-stumpf Dec 19, 2021
91a189e
Moved site.yml and reset.yml to new playbook directory
jon-stumpf Dec 19, 2021
7b76442
Added k3s_commit so that install_k3s_commit is only used in playbook/…
jon-stumpf Dec 20, 2021
9630975
Updated roles/download/tasks/main.yml to use blocks, for clarity
jon-stumpf Dec 20, 2021
6915b5f
Added capability to copy the master kubeconfig to the localhost in pl…
jon-stumpf Dec 21, 2021
355e3d3
Fixed some comments
jon-stumpf Dec 21, 2021
f961f76
Removed install_bin_dir_read_only flag
jon-stumpf Dec 21, 2021
dd73c1f
Removed install_k3s_symlink flag
jon-stumpf Dec 21, 2021
ca445ef
In inventory/sample/group_vars, simplified all.yml and added README.m…
jon-stumpf Dec 21, 2021
ae2b55f
Moved cluster_config from playbook/group_vars/all.yml to inventory/sa…
jon-stumpf Dec 21, 2021
f62942b
Created shorter, simpler inventory/sample/group_vars/all.yml
jon-stumpf Dec 21, 2021
f60e947
Replace shell call to 'curl' with ansible.builtin.uri
jon-stumpf Dec 21, 2021
c163579
node-token does not need to be executable
jon-stumpf Dec 21, 2021
d43772e
Moved roles/download/vars to roles/download/defaults
jon-stumpf Dec 21, 2021
3c072a4
Renamed roles k3s/master and k3s/node to k3s/server and k3s/agent, re…
jon-stumpf Dec 16, 2021
b740fc2
Renamed host groups master and node to k3s_server and k3s_agent, resp…
jon-stumpf Dec 16, 2021
b307aeb
Renamed k3s-node service to k3s-agent
jon-stumpf Dec 16, 2021
13026c8
Renamed master_ip to server_ip
jon-stumpf Dec 19, 2021
2e39548
Only reload k3s service when service file(s) have changed
jon-stumpf Dec 21, 2021
be9855c
Only forward ipv6 when there are ipv6 interfaces
jon-stumpf Dec 21, 2021
99fa0c1
Some check_mode tweaks
jon-stumpf Dec 21, 2021
dafce83
Reduced differences in OS prereq task files
jon-stumpf Dec 22, 2021
3a6b0aa
Mitigated bug with ip-netns
jon-stumpf Dec 22, 2021
a319afa
Merge remote-tracking branch 'k3s-io/k3s-ha'
jon-stumpf Dec 24, 2021
8849726
Added --tls-san with --cluster-init
jon-stumpf Dec 4, 2021
b9487df
Replaced octal modes with symbolic modes
jon-stumpf Dec 25, 2021
e0b8385
Added {{ bin_dir }} to command line in k3s-init
jon-stumpf Dec 25, 2021
58a0b4c
Fixed hardcoded path with {{ bin_dir }}
jon-stumpf Dec 25, 2021
86c6caf
Added new variable, first_server
jon-stumpf Dec 25, 2021
7523ce8
Fixed bug where verification would run once per server in k3s_servers…
jon-stumpf Dec 26, 2021
284cf4f
Fixed verification to not run in check_mode
jon-stumpf Dec 26, 2021
63318f2
k3s_token must be defined
jon-stumpf Dec 26, 2021
6a9a02b
Added roles/config-check
jon-stumpf Dec 26, 2021
5db0830
Added ha_enabled flag to specifically ask for an HA embedded database…
jon-stumpf Dec 26, 2021
4a27b19
Moved k3s-init tasks to a separate file
jon-stumpf Dec 27, 2021
7b43a57
Added cluster VIP method: externally provided cluster VIP
jon-stumpf Dec 27, 2021
daf2dd2
Cherry-Picked: Fixed download task names
jon-stumpf Dec 27, 2021
72aefe3
Cherry-Picked: Added option to keep the downloaded binaries after reset
jon-stumpf Dec 27, 2021
b24490a
Ensure that all files under inventory/sample are stored in git
jon-stumpf Dec 27, 2021
808bb14
Added cluster VIP method: kube-vip
jon-stumpf Dec 27, 2021
2968d28
Some fixes in inventory/sample/group_vars/README.md
jon-stumpf Dec 27, 2021
b702f62
Added reference to inventory/sample/group_vars/README.md
jon-stumpf Dec 27, 2021
86e20ae
Added comments to playbook/site.yml
jon-stumpf Dec 27, 2021
c139d76
Added wait for control-plane before configuring agents
jon-stumpf Dec 27, 2021
b59c37d
Updated text in README.md
jon-stumpf Dec 27, 2021
f42d11e
Handled the case of an empty group_vars/all.yml file
jon-stumpf Dec 27, 2021
494f36f
Create simpler inventory/sample/group_vars/all.yml
jon-stumpf Dec 27, 2021
1b5278f
Added configuration checks for 'ha_cluster_vip' and 'ha_cluster_method'
jon-stumpf Dec 28, 2021
5ccaad4
Increased wait time for control-plane to 60 seconds
jon-stumpf Dec 28, 2021
1ed9386
Added cleanup to the install as well for kube-vip
jon-stumpf Dec 28, 2021
2394e06
Remove cluster VIP from interface during reset
jon-stumpf Dec 28, 2021
dc91550
Eliminated unnecessary/redundant fact gathering
jon-stumpf Dec 28, 2021
c946167
Renamed keep_binaries to remove_packages; Applied it to k3s-selinux p…
jon-stumpf Dec 28, 2021
1577aa2
Implemented keepalived cluster method as a role
jon-stumpf Dec 29, 2021
5041688
Turned kube-vip cluster method into roles
jon-stumpf Dec 29, 2021
50d28e5
Converted kube-vip cluster method to a role
jon-stumpf Dec 29, 2021
fd9dce4
Fixed roles k3s/server and reset to use HA cluster method roles
jon-stumpf Dec 29, 2021
93184c9
Converted k3s-init.yml to a role, ha/etcd
jon-stumpf Dec 29, 2021
12b7b3f
Fixed tasks that reported changes when there weren't
jon-stumpf Dec 29, 2021
ef262fe
Only remove command files from groups['k3s_server']
jon-stumpf Dec 29, 2021
1f7b031
Removed unnecessary task that always threw an error
jon-stumpf Dec 29, 2021
309e5d7
Added check if architecture isn't supported
jon-stumpf Dec 30, 2021
de0fd8c
Fixed name: string to be consistent with others
jon-stumpf Dec 30, 2021
c2cb97e
Removed ~{{ ansible_user }}/.kube directory, not just the config
jon-stumpf Dec 30, 2021
4a8adcf
Ensured remove_packages is treated as a boolean
jon-stumpf Dec 30, 2021
db52cc9
Remove unnecessary node-token tasks
jon-stumpf Dec 30, 2021
6790e39
Broke up reset role in reset/download and reset/k3s
jon-stumpf Dec 30, 2021
38162f6
Split out k3s-killall tasks into a separate task file
jon-stumpf Dec 30, 2021
69a39f3
Cosmetic changes to README.md
jon-stumpf Dec 30, 2021
aa0d4d3
Moved update to cluster config to localhost
jon-stumpf Dec 30, 2021
6d94a87
Made playbook/site.yml reentrant (for non-HA) and it only reports cha…
jon-stumpf Dec 30, 2021
8ece296
First draft of TODO.md
jon-stumpf Dec 30, 2021
d9ed773
Updated TODO and added comments to roles where appropriate
jon-stumpf Dec 30, 2021
7cb174d
Fixed typo in inventory/sample/group_vars/README.md
jon-stumpf Dec 30, 2021
107e74d
Added Turing Pi HA example.
jon-stumpf Dec 30, 2021
a76c8d9
Removed stray whitespace
jon-stumpf Dec 30, 2021
094176c
Added ha_k3s_token to inventory/sample/group_vars/all.yml
jon-stumpf Dec 30, 2021
1f04cff
Fixed typo in README.md
jon-stumpf Dec 30, 2021
765f6a5
Made cluster_config and ha_cluster_method optional, with defaults
jon-stumpf Dec 30, 2021
7ffd298
Added more content to README.md
jon-stumpf Dec 30, 2021
54c6f8b
Updated progress report in TODO.md
jon-stumpf Dec 30, 2021
9cd3b96
Replaced 'by ref' with 'by reference'
jon-stumpf Dec 30, 2021
6d1cf85
Restore turingpi config
jon-stumpf Dec 30, 2021
1ecdd8f
Restore original turingpi hosts.ini
jon-stumpf Dec 30, 2021
a258460
Added Caveats
jon-stumpf Dec 30, 2021
74f07e0
Fixed formatting inconsistencies in README.md
jon-stumpf Dec 30, 2021
b15fb8b
Changed default HA cluster method to kube-vip
jon-stumpf Jan 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 58 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,95 @@
# Build a Kubernetes cluster using k3s via Ansible
# Build a Kubernetes cluster using *k3s* with *ansible*

Author: <https://github.com/itwars>

## K3s Ansible Playbook
## Introduction to *k3s-ansible*

Build a Kubernetes cluster using Ansible with k3s. The goal is easily install a Kubernetes cluster on machines running:
The goal of *k3s-ansible* is to easily install a Kubernetes cluster on a variety of
operating systems running on machines with different architectures.
In general, users of *k3s-ansible* should only need to edit two files:
- `inventory/sample/group_vars/all.yml`
- `inventory/sample/hosts.ini`

- [X] Debian
- [X] Ubuntu
- [X] CentOS
All you need to get started is a list of IP addresses for the hosts that you want to
participate in the cluster and a username that has password-less *ssh* access to all
those hosts. That's it!
No need to futz with lots of settings and variables (unless you like that sort of thing;
then, have at it).

on processor architecture:
And, to setup an HA cluster, you need one more IP address - not of a host,
but for your cluster virtual IP address.
You don't need to know how to setup a clustering solution since *k3s-ansible* does it for you.
But, for HA, you just need at least three hosts.

- [X] x64
- [X] arm64
- [X] armhf
The intention is for *k3s-ansible* to support what *k3s* supports.\
Here is what has been tested (:heavy_check_mark:) with *k3s-ansible*.

| Operating System | amd64 | arm64 | armhf |
| :--------------- | :---: | :---: | :---: |
| Debian | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Ubuntu | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| CentOS | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |

## System requirements

Deployment environment must have Ansible 2.4.0+
Master and nodes must have passwordless SSH access
- The deployment environment must have *ansible* v2.4.0+.
- Hosts in the cluster must have password-less *ssh* access.
- HA requires at least three hosts.

## Caveats

- *k3s-ansible* will overwrite an existing *k3s* installation on the hosts.
- *k3s-ansible* will overwrite the `.kube` directory of the `ansible_user` specified on each server.
- An HA configuration using *keepalived* will overwrite an existing *keepalived* configuration.

## Usage

First create a new directory based on the `sample` directory within the `inventory` directory:
1. Create a new cluster definition based on the `inventory/sample` directory.

```bash
cp -R inventory/sample inventory/my-cluster
```

Second, edit `inventory/my-cluster/hosts.ini` to match the system information gathered above. For example:
2. Edit `inventory/my-cluster/hosts.ini` to include the hosts that will make up your new cluster.\
For example:

```bash
[master]
[k3s_server]
192.16.35.12

[node]
[k3s_agent]
192.16.35.[10:11]

[k3s_cluster:children]
master
node
k3s_server
k3s_agent
```

If needed, you can also edit `inventory/my-cluster/group_vars/all.yml` to match your environment.
3. Edit `inventory/my-cluster/group_vars/all.yml` to best match your environment.\
See, `inventory/sample/group_vars/README.md` for more details.

Start provisioning of the cluster using the following command:
4. Provision your new cluster.

```bash
ansible-playbook site.yml -i inventory/my-cluster/hosts.ini
ansible-playbook playbook/site.yml -i inventory/my-cluster/hosts.ini
```

## Kubeconfig

To get access to your **Kubernetes** cluster just
To get access to your new **Kubernetes** cluster, just use the generated kube configuration file.

```bash
scp debian@master_ip:~/.kube/config ~/.kube/config
kubectl --kubeconfig playbook/cluster.conf ...
```

## High Availability
*k3s-ansible* can now configure a high-availability (HA) cluster.
If you enable HA (**ha_enabled**), the playbook will setup an embedded database using *etcd*.
HA requires at least version **v1.19.5+k3s1** and an odd number of servers (minimum of three).
See the [HA-embedded documentation](https://rancher.com/docs/k3s/latest/en/installation/ha-embedded/) for more details.

HA expects that there is a virtual IP (**ha_cluster_vip**) in front of the *control-plane* servers.
A few methods have been implemented to provide and manage this VIP.
See `inventory/turingpi` for my example HA setup on my Turing Pi v1.
See `inventory/sample/group_vars/README.md` for more details on variables.

78 changes: 78 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Update

Author: [https://github.com/jon-stumpf](https://github.com/jon-stumpf)

I came across *k3s-ansible* looking for an easy why to create a highly-available cluster
on my [Turing Pi 1](https://turingpi.com/v1/).
I saw *k3s-ansible* could easily configure my hosts but was missing the HA component.
Further research led me to the [k3s-ha](https://github.com/k3s-io/k3s-ansible/tree/k3s-ha)
branch but found that it still was incomplete for my needs.
In developing the needed additions, I discovered issues in the
[master](https://github.com/k3s-io/k3s-ansible/tree/master) branch and spent a month
reviewing the yaml files of *k3s-ansible* and the shell scripts from
[https://get.k3s.io](https://get.k3s.io).
In the end, I brought *k3s-ansible* to be at near parity with https://get.k3s.io and
I believe I have addressed some open issues as referenced in
[my pull requests](https://github.com/k3s-io/k3s-ansible/pulls/jon-stumpf).

Once I completed my changes to the *master* branch, I got back to work on *k3s-ha*.
Building on the
[work of St0rmingBr4in](https://github.com/k3s-io/k3s-ansible/commits?author=St0rmingBr4in),
I implemented the HA embedded database using *etcd* and three cluster VIP methods:
1. **external**: uses an externally provided cluster VIP
2. **kube-vip**: uses [kube-vip](https://kube-vip.io/) with arp arbitration
3. **keepalived**: uses [keepalived](https://www.redhat.com/sysadmin/keepalived-basics) to implement VRRP

I have reached out to
[itwars](https://github.com/itwars) and
[St0rmingBr4in](https://github.com/St0rmingBr4in) to get their feedback on this work and
to collaborate on closing the open issues and pull requests.
In the meantime, I would like others to provide feedback on my
[k3s-ha](https://github.com/jon-stumpf/k3s-ansible/tree/k3s-ha) branch.
This is now stable and incorporates all my previous work on *k3s-ansible* except for a few commits.
Please, try it out.

# TODO

1. Make all roles *idempotent* and not report changes when none, in fact, are needed or material.
2. Add *keepalived*' label to servers when using keepalived; Add the following annotations:
- `keepalived/vrrp_instance=<name>`
- `keepalived/master=[true|false]`
- `keepalived/version=<version>`
- `keepalived/vip=<ipaddr>/<cidr>`
3. Add the ability to download the latest version of *kube-vip*
- Currently, uses a static version (v0.4.0) that can be manually changed
4. Make sure all roles have defaults defined
5. Make HA not require `k3s_token` to be defined
- i.e., use the `node-token` from the first server
6. Replace `command` and `shell` tasks with *ansible* equivalents (where appropriate)
- `ip`
- `kubectl`
- etc.
7. Is the `raspberrypi` role a NO-OP?
- It does not appear to execute any tasks that induce change
- Should it be deleted?
8. From where does *k3s-selinux* get installed?
- The `reset/download` role deletes it.
9. Document lesser switches to control behavior of roles (e.g., remove_packages)
10. Create playbooks for other common operations beyond install/uninstall

# Progress Report

| Role | Role Type | Idempotent | Only Real Changes | Defaults | commands | TODOs | BUGs |
| :-------------------- | :--------: | :---: | :---: | :---: | :---: | :---: | :---: |
| cluster-config | install | :heavy_check_mark: | :heavy_check_mark: | | - | - | - |
| config-check | install | :heavy_check_mark: | :heavy_check_mark: | *under review* | - | - | - |
| prereq | install | :heavy_check_mark: | :heavy_check_mark: | **n/a** | - | - | - |
| download | install | :heavy_check_mark: | :heavy_check_mark: | *under review* | - | - | - |
| raspberrypi | install | :heavy_check_mark: | :heavy_check_mark: | **n/a** | 2 | 1 | - |
| ha/etcd | HA-only | | unknown | *under review* | 3 | 1 | - |
| ha/keepalived | HA-only | :heavy_check_mark: | :heavy_check_mark: | *under review* | 1 | 1 | - |
| ha/kube-vip | HA-only | :heavy_check_mark: | :heavy_check_mark: | *under review* | 2 | 3 | - |
| k3s/server | install | :heavy_check_mark: | :heavy_check_mark: | *under review* | - | - | - |
| k3s/agent | install | :heavy_check_mark: | :heavy_check_mark: | | - | - | - |
| reset/download | uninstall | :heavy_check_mark: | :heavy_check_mark: | *under review* | 2 | 1 | - |
| reset/ha/keepalived | uninstall | :heavy_check_mark: | :heavy_check_mark: | *by reference* | - | - | - |
| reset/ha/kube-vip | uninstall | :heavy_check_mark: | :heavy_check_mark: | *by reference* | 3 | 1 | - |
| reset/k3s | uninstall | :heavy_check_mark: | :heavy_check_mark: | *under review* | 9 | 1 | 2 |

5 changes: 4 additions & 1 deletion inventory/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*
!.gitignore
!sample/
!sample/
!sample/**
!turingpi/
!turingpi/**
108 changes: 108 additions & 0 deletions inventory/sample/group_vars/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@

# Introduction

`inventory/x/group_vars/all.yml` is meant to be modified appropriately for your environment.

*ansible* variables that were previously here have moved to `playbook/group_vars/all.yml`.
Those variables are used within the playbooks and roles are not meant to be changed by a user of *k3s-ansible*.
When adding a new _install_ variable, a corresponding variable is added to `playbook/group_vars/all.yml`
which is then used throughout *k3s-ansible*.

## General Variables

- **ansible_user**: specifies the username that has *ssh* password-less access to configure your hosts.
The default is `debian`.

- **cluster_config**: specifies the location of where to capture the kube configuration file for the new cluster.
The default is `playbook/cluster.conf`.

## High-Availability (HA) Variables

- **ha_enabled**: specifies if the cluster will have an HA embedded database using *etcd*.
The default is `false`.

- **ha_cluster_vip**: specifies the virtual IP (VIP) address in front of the control-plane servers for
agent configuration as well as cluster definition in `.kube/config`.
Note: This is an IP address different than those of the cluster nodes.
Today, this is a static IP address provided in this file.
It is possible to get an IP address dynamically but that is not implemented here.

- **ha_cluster_method**: specifies the method of clustering to use for the virtual IP.
The methods implemented today are:
1. `external` - requires a load-balancer external to the cluster
2. `kube-vip` - [https://kube-vip.io](https://kube-vip.io), arp-based daemonset using leader election
3. `keepalived` - all *k3s* servers are configured with [keepalived](https://www.redhat.com/sysadmin/keepalived-basics) to manage a VRRP instance

- **ha_k3s_token**: specifies k3s token used by hosts to join the cluster

## Install Variables

If you have installed *k3s* from [https://get.k3s.io](https://get.k3s.io), these variables will be familiar.
*Install* variables are meant to duplicate the install flags and environment variables found in the install script
(see [Installation Options](https://rancher.com/docs/k3s/latest/en/installation/install-options/#options-for-installation-with-script)).
Each variable has a prefix of `install_` and implements, to the extent possible, the actions of the shell script as documented below.

### Variables that control the version of *k3s* downloaded

There are four (4) variables that control which version of *k3s* is installed on your hosts.

- **install_k3s_commit**: specifies the commit of *k3s* to download from temporary cloud storage.
The default is to leave this `undefined` as this variable is for developers and QA use.

- **install_k3s_version**: specifies the version of *k3s* to download from Github.
If left `undefined` (the default), *ansible* will attempt to download from a channel.

- **install_k3s_channel_url**: specifies the URL for the channels.
The default is [https://update.k3s.io/v1-release/channels](https://update.k3s.io/v1-release/channels).
It is not something typically changed but is implemented for completeness sake.

- **install_k3s_channel**: specifies the channel from which to get the version.
The default is the `stable` channel. A typical channel used is `latest`.

### Variables that change the location of binaries and data

There are three (3) variables that change the default location of files.

- **install_k3s_bin_dir**: specifies the directory to install the *k3s* binary and links.
The default is `/usr/local/bin`.

- **install_k3s_systemd_dir**: specifies the directory to install *systemd*
service and environment files. The default is `/etc/systemd/system`.

- **install_k3s_data_dir**: specifies the data directory for the *k3s* service.
This defaults to `/var/lib/rancher/k3s`.
Note: this is not (yet) an option in *k3s-io/k3s*.

### Variables for the *k3s* executable

The install script from [https://get.k3s.io/](https://get.k3s.io/) has one flag (**INSTALL_K3S_EXEC**) to
provide extra arguments to the *k3s* executable. *k3s-ansible* uses two variables:
one for servers and one for agents. These are:

- **install_k3s_server_args**: the default is `''`.
- **install_k3s_agent_args**: the default is `''`.

### Install Flags not yet implemented

The install flags that have yet to be implemented are:

| Install Flag | What it does |
| :--- | :--- |
| **INSTALL_K3S_SKIP_SELINUX_RPM** | If set to true, *ansible* will skip automatic installation of the *k3s* RPM.
| **INSTALL_K3S_SELINUX_WARN** | If set to true, *ansible* will continue if the *k3s-selinux* policy is not found.
| **INSTALL_K3S_NAME** | specifies the name of *systemd* service to create.
| **INSTALL_K3S_TYPE** | specifies the type of *systemd* service to create.

Currently, nothing will happen if these are set.

### Install Flags that will not be implemented

Lastly, some install flags did not make sense to implement with *k3s-ansible*:

| Install Flag | What *k3s-ansible* does |
| :--- | :--- |
| **INSTALL_K3S_SKIP_DOWNLOAD** | *k3s-ansible* always downloads the *k3s* binary and its hash. |
| **INSTALL_K3S_FORCE_RESTART** | *k3s-ansible* always restarts the service. |
| **INSTALL_K3S_SKIP_ENABLE** | *k3s-ansible* always enables the service. |
| **INSTALL_K3S_SKIP_START** | *k3s-ansible* always starts the service. |

17 changes: 12 additions & 5 deletions inventory/sample/group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
---
k3s_version: v1.22.3+k3s1
# See inventory/sample/group_vars/README.md for more options.
# If this file is empty, default values will be used for all mandatory fields.

# The user that has password-less ssh access to configure your hosts
ansible_user: debian
systemd_dir: /etc/systemd/system
master_ip: "{{ hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0]) }}"
extra_server_args: ""
extra_agent_args: ""

# The location of where to capture the kube config of the new cluster
# Relative paths are relative to the playbook directory.
cluster_config: cluster.conf

# Use the latest k3s version instead of 'stable'
install_k3s_channel: 'latest'

8 changes: 4 additions & 4 deletions inventory/sample/hosts.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[master]
[k3s_server]
192.168.1.26

[node]
[k3s_agent]
192.168.1.34
192.168.1.39
192.168.1.16
192.168.1.32

[k3s_cluster:children]
master
node
k3s_server
k3s_agent
1 change: 1 addition & 0 deletions inventory/turingpi/group_vars/README.md
19 changes: 19 additions & 0 deletions inventory/turingpi/group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---

# See inventory/sample/group_vars/README.md for more options.
# If this file is empty, default values will be used for all mandatory fields.

# The user that has password-less ssh access to configure your hosts
ansible_user: pirate

# The location of where to capture the kube config of the new cluster
# Relative paths are relative to the playbook directory.
cluster_config: cluster.conf

ha_enabled: true
ha_cluster_vip: 192.168.140.127
ha_cluster_method: kube-vip

# Use the latest k3s version instead of 'stable'
install_k3s_channel: 'latest'

14 changes: 14 additions & 0 deletions inventory/turingpi/hosts.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[k3s_server]
192.168.140.120
192.168.140.123
192.168.140.126

[k3s_agent]
192.168.140.121
192.168.140.122
192.168.140.124
192.168.140.125

[k3s_cluster:children]
k3s_server
k3s_agent
1 change: 1 addition & 0 deletions playbook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cluster.conf
Loading