Commit Graph
358 Commits
Author SHA1 Message Date
Kris b1f5388471 feat: roll the servers one at a time and wait for each to serve again (#562)
* feat: allow the server and agent plays to roll one node at a time

The server and agent roles restart their k3s service on every run, and
the plays run against the whole group at once. On a cluster with three
or more servers that restarts every etcd member together, which costs
the cluster its quorum and its API server.

k3s_server_serial and k3s_agent_serial set the serial of the two plays.
Both default to 100%, the whole group in one batch, so a run that does
not set them behaves as before. The HA integration test now rolls the
servers with the variable instead of --forks=1, which serialises the
role rather than the individual tasks.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* feat: hold each node until it serves again during a rolling run

Setting k3s_server_serial to 1 rolls the servers one at a time, but the role
returns as soon as the service manager reports k3s started, which is before the
node serves again. On an embedded etcd cluster the next restart can then land
while the previous member is still a learner, and a learner does not count
towards the quorum.

k3s_wait_ready holds each node at the end of its role until the API server
reports it Ready. k3s_server_wait_etcd_voters holds each server until every
server the run has already started carries EtcdIsVoter=True. Both default to
false, are independent of each other, are skipped in check mode, and the upgrade
role honors them as well.

The new voter gate and the existing join barrier both wait only for the servers
the run has reached, taken from the play's host list up to the end of the current
batch: a whole-group count never completes on a fresh HA install rolled one node
at a time. They match nodes by name rather than by count, so a re-run against a
cluster that already holds more nodes also completes, and the comparison ignores
case.

k3s_node_name carries the name K3s registers the node under. It defaults to the
lower-cased hostname and has to be set when a node is installed with --node-name.

The HA integration job installs through tests/serial.yml, which imports site.yml
with the serial variables in its vars, and the external job gives its server a
node name that differs from its host name.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* docs: say why the node name is recorded as a fact

A role default is not reachable through hostvars, so the barriers read a fact
that each host sets for itself.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* docs: describe what upgrade.yml does rather than that it is unchanged

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* Tolerate a host that left the play when listing started servers

Extracting a key from hostvars raises when the key is missing. A host that
went unreachable earlier in the play never recorded its node name, so the
list comprehension that both barriers read failed the whole batch rather
than the one host that dropped out. Select the hosts that carry the fact
instead.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* Count the servers started so far in the server join barrier

The barrier that confirms the servers joined matched the node names the
run had recorded against the names the API server returned. Counting is
enough for what the barrier is for, and it keeps the check independent of
the node name: at the default serial it waits for the whole server group,
which is what it waited for before, and under a serialised run it waits
for the servers the run has started. Name matching stays in the two
opt-in gates, which need it.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* Take the node name default from the OS nodename

The kubelet registers a node under the name the operating system reports,
which on a host with a search domain is the fully qualified name, not the
short host name the default used. The server and agent plays gather no
facts of their own, so the default also falls back to the inventory host
name rather than requiring a gathered fact.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* Show the node name as a per-host setting in the sample inventory

k3s_node_name names one node, so the sample carries it under a host entry
rather than in the group vars every node reads. The sample also says where
the serial variables are set, since a reader who meets them in the group
vars block would reasonably try to set them there.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* State what the etcd voter gate checks and how to read a gate timeout

The voter gate was described as the thing that keeps a rolling run from
taking the quorum down, which overstates it: it checks one condition on
the servers the run has started, and a quorum lost some other way is
outside what it sees. Say that, say which check counts nodes and which
match by name, and give the reader the two failure modes worth knowing
before a gate times out on them.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* Install the HA test cluster at the default serial and give it an agent

The HA job installed through tests/serial.yml, which left no coverage of a
fresh multi-server install at the default serial, the setting a cluster
that passes no serial variable actually runs. Put that back as the install
step and move tests/serial.yml to the version-bump re-run, where rolling
one node at a time is what the step is testing.

The inventory had no agent, so the agent play never batched and the agent
readiness gate never ran. Adding one covers both, and the job's container
loops and assertions follow it.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* feat: roll the servers one at a time with an etcd voter wait

k3s_server_serial sets the serial of the server play. It defaults to
100%, the whole group in one batch, so a run that does not set it behaves
as before. Set it to 1 to restart the servers one at a time, and pass it
through extra vars or import_playbook vars, since serial is templated
before any inventory variable is bound.

The join check waits for the servers started so far rather than the whole
group, so a fresh HA install rolled one server at a time completes. A
multi-server cluster on embedded etcd waits until every server reports
EtcdIsVoter=True before the next batch starts. The agent play is
unchanged.

The HA integration job re-runs site.yml with k3s_server_serial=1 in place
of --forks=1.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* docs: clarify the serial server rollout in the README

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* docs: describe the etcd voter wait precisely

Signed-off-by: Kristofer <kristofer@atlascloud.is>

---------

Signed-off-by: Kristofer <kristofer@atlascloud.is>
2026-10-05 11:10:49 -07:00
Kris 1a600b60d3 feat: make the server config file mode configurable (#561)
* feat: make the server config file mode configurable

/etc/rancher/k3s/config.yaml holds the cluster token. The server and
upgrade roles write it at 0644, so every local account on a server node
can read the credential that joins a node to the cluster.

k3s_server_config_mode sets the mode of that file in both roles. It
defaults to 0644, so behaviour is unchanged unless it is set.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* docs: describe the server config file contents accurately

/etc/rancher/k3s/config.yaml does not always carry the cluster token. A
first server that lets K3s generate one writes the file without it, so the
file can contain the token rather than always holding it. Correct that
claim in the README, the inventory sample and the role default, and use
the US spelling of "honors".

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* Name the floor the config file mode can be narrowed to

Saying any mode root can read works leaves the reader to work out what
that means in practice. The file is read only by k3s, running as root, so
0600 is the tightest mode that still works.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

* Run the basic integration job with a non-default config file mode

The templated mode was only ever rendered with its default in CI, which
is the one value that cannot tell a working template from a broken one.
The basic inventory sets 0640 and the job reads the mode back off the
installed file.

Signed-off-by: Kristofer <kristofer@atlascloud.is>

---------

Signed-off-by: Kristofer <kristofer@atlascloud.is>
2026-09-16 11:55:02 -07:00
dependabot[bot] 281554e252 Bump actions/setup-python from 6.3.0 to 7.0.0 in the action-deps group (#553)
Bumps the action-deps group with 1 update: [actions/setup-python](https://github.com/actions/setup-python).


Updates `actions/setup-python` from 6.3.0 to 7.0.0
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/ece7cb06caefa5fff74198d8649806c4678c61a1...5fda3b95a4ea91299a34e894583c3862153e4b97)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: action-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-08-14 12:10:59 -07:00
Derek Nola 165062c410 Publish 1.2.2 tag (#555)
Signed-off-by: Derek Nola <derek.nola@suse.com>
1.2.2
2026-08-14 09:45:25 -07:00
Derek Nola 8a2d1e2e2d Add agent logs on failure (#556)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-08-13 15:33:30 -07:00
Stéphane Este-Gracias 445cecb423 Wrap api_endpoint with ansible.utils.ipwrap for IPv6 compatibility (#550)
* Add IPv6 support for api_endpoint

Signed-off-by: Stéphane Este-Gracias <sestegra@gmail.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>

* Add ansible.utils requirement

Signed-off-by: Stéphane Este-Gracias <sestegra@gmail.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>

* Add netaddr dependency

Signed-off-by: Stéphane Este-Gracias <sestegra@gmail.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>

---------

Signed-off-by: Stéphane Este-Gracias <sestegra@gmail.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Stéphane Este-Gracias <sestegra@gmail.com>
2026-08-13 12:11:08 -07:00
mbathe19 cb38fd92e3 feat: add firewall variable (#552)
* feat: add firewall variable

Signed-off-by: Michel Bathe <michel.bathe.1996@googlemail.com>

* feat: put manage_firewall dafault in defaults/main.yml

Signed-off-by: Michel Bathe <michel.bathe.1996@googlemail.com>

* fix: lint

Signed-off-by: Michel Bathe <michel.bathe.1996@googlemail.com>

* fix: lint

Signed-off-by: Michel Bathe <michel.bathe.1996@googlemail.com>

---------

Signed-off-by: Michel Bathe <michel.bathe.1996@googlemail.com>
2026-08-13 11:56:16 -07:00
Derek Nola 5f98ca7a23 Increase wait time for upgrades in testing (#554)
* Increase wait time for upgrades in testing

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Cleanup GHA runners

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Expand and fix test server logs

Signed-off-by: Derek Nola <derek.nola@suse.com>

---------

Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-08-13 11:54:46 -07:00
Ian Lewis 35b8377f74 fix(roles): fix check mode on clean install (#547)
Signed-off-by: Ian Lewis <ian@ianlewis.org>
2026-08-10 14:55:08 -07:00
Archy 9cdd1dd47c fix: read hostname from ansible_facts in the TLS SAN condition (#548)
Signed-off-by: Artem Muterko <artem@sopho.tech>
2026-08-10 14:53:20 -07:00
Aleksei Sviridkin e5ec2f07b4 fix: apply k3s version bumps declaratively through site.yml (#544)
Re-running site.yml with a raised k3s_version replaced the on-disk
binary but left agents and joined servers running the old runtime,
because the install script skips the service start and the roles only
restarted the service on a config change. A version-only bump was
therefore not applied until the services were restarted by hand.

Always restart the k3s service in the server and agent roles on a
site.yml run, so the cluster reliably picks up a new config or runtime
without any logic to detect whether the binary changed. On a
multi-server cluster, run the playbook with --forks=1 so the servers
restart one at a time and the etcd quorum is preserved; document this
in the README.

Keep the dedicated upgrade.yml integration test and add a second
upgrade through site.yml, asserting the running version the kubelet
reports rather than the on-disk binary, so the tests fail if the
restart regresses.



Assisted-By: Claude <noreply@anthropic.com>

Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-07-14 16:24:42 -07:00
dependabot[bot] 66883771ba Bump actions/setup-python from 6.2.0 to 6.3.0 in the action-deps group (#545)
---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 6.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: action-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-07-14 10:27:34 -07:00
Archy 6f87b64f1d fix: use failed_when instead of ignore_errors for version detection (#543)
Signed-off-by: Artem Muterko <artem@sopho.tech>
2026-07-06 09:42:35 -07:00
Archy 33b0ca9fa0 fix(raspberrypi): run detection commands in check mode (#542)
Signed-off-by: Artem Muterko <artem@sopho.tech>
2026-07-06 09:38:25 -07:00
dependabot[bot] de30fcd06c Bump the action-deps group across 1 directory with 3 updates (#539)
Bumps the action-deps group with 3 updates in the / directory: [actions/checkout](https://github.com/actions/checkout), [actions/setup-python](https://github.com/actions/setup-python) and [actions/upload-artifact](https://github.com/actions/upload-artifact).


Updates `actions/checkout` from 4.3.1 to 7.0.0
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4.3.1...9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0)

Updates `actions/setup-python` from 4.9.1 to 6.2.0
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/7f4fc3e22c37d6ff65e88745f38bd3157c663f7c...a309ff8b426b58ec0e2a45f0f869d46889d02405)

Updates `actions/upload-artifact` from 4.6.2 to 7.0.1
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/ea165f8d65b6e75b540449e92b4886f43607fa02...043fb46d1a93c77aae656e7c1c64a875d1fc6a0a)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: action-deps
- dependency-name: actions/setup-python
  dependency-version: 6.2.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: action-deps
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: action-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-22 09:26:45 -07:00
Derek Nola e8af759240 Remove N/A label
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-06-18 09:29:54 -07:00
Derek Nola 278b6bbbfe Add dependabot bumps for GHA versions
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-06-18 09:27:53 -07:00
Derek Nola 36de65e2c1 Publish 1.2.1 tag
Signed-off-by: Derek Nola <derek.nola@suse.com>
1.2.1
2026-06-08 10:07:05 -07:00
Rémi Paulmier a05f5b5dce Invert directives when importing ref. playbook (#524)
there was like a typo, where instructions in case of imported playbook were inverted.

Signed-off-by: Rémi Paulmier <remi.paulmier@gmail.com>
2026-05-27 14:44:58 -07:00
Jonathan Cremin 611ca0bbaf Fix existing token retrieval for k3s server (#534)
Signed-off-by: Jonathan Cremin <jonathan@crem.in>
2026-05-27 14:44:42 -07:00
shadow1runnerandHelmut Wolf d1aab4d8b8 Feature/oracle linux11 (#532)
* fix: handle Oracle Linux UEK kernel package name for br_netfilter

Oracle Linux uses the Unbreakable Enterprise Kernel (UEK) instead of the
standard RHEL kernel. The `kernel-modules-extra` package does not exist
on Oracle Linux — the equivalent is `kernel-uek-modules-extra`.

Without this fix, the prereq role fails on Oracle Linux 10 with:
  "No package kernel-modules-extra available."

Signed-off-by: Helmut Wolf <3902045+shadow1runner@users.noreply.github.com>

* chore: update README to include Oracle Linux

Signed-off-by: Helmut Wolf <3902045+shadow1runner@users.noreply.github.com>

---------

Signed-off-by: Helmut Wolf <3902045+shadow1runner@users.noreply.github.com>
Co-authored-by: Helmut Wolf <3902045+shadow1runner@users.noreply.github.com>
2026-05-27 14:44:06 -07:00
Chris Wayne 26245771fd Merge pull request #525 from cwayne18/pin-actions-to-sha
Pin GH Actions to commit sha
2026-03-27 10:24:35 -04:00
Chris Wayne 4acc4c718b Pin GH Actions to commit sha
Signed-off-by: Chris Wayne <cwayne18@gmail.com>
2026-03-27 09:21:19 -04:00
Derek Nola 2c3f3773c7 Publish 1.2.0 tag
Signed-off-by: Derek Nola <derek.nola@suse.com>
1.2.0
2026-03-11 11:43:58 -07:00
Derek Nola 8cbdb48d6d Move k3s version control into testing CI (#523)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-03-11 11:37:36 -07:00
Ionut CiocoiuandDerek Nola 1f1228f3e8 Add nftables configuration for K3s on Arch Linux (#511)
* Do not enable nftables by default
* If nftables is enables, configure exceptions for k3s service

Signed-off-by: Ionut Ciocoiu <ionutnciocoiu@gmail.com>
Co-authored-by: Derek Nola <derek.nola@suse.com>
2026-03-11 10:09:14 -07:00
Derek Nola e9e0978a47 Simplify logic on K3s service start
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-02-28 10:34:04 -08:00
Derek Nola de7c3ed894 Fix missing extra_server_args on k3s_upgrade
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-02-28 10:34:04 -08:00
Derek Nola acba8e9b4d Add support for openrc to k3s_server role
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-02-28 10:34:04 -08:00
Derek Nola 65a3b5f6ac Remove service template from k3s_upgrade role (#519)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-02-27 15:35:12 -08:00
Derek Nola a8784f41c4 Fix getting random token for agents
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-02-27 14:54:41 -08:00
Derek Nola be3b0f4d54 Add a notoken test
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-02-27 14:54:41 -08:00
Derek Nola c10c6e8c31 Add airgap test
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-02-27 13:07:40 -08:00
Derek Nola 6f44cf312f Fix airgap agent install
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-02-27 13:07:40 -08:00
Derek Nola 1eca3a1ab8 Remove server role template, utilize config.yaml to configure k3s
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-02-27 11:52:47 -08:00
Derek Nola 68a410fb4b Add external database integration test
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-02-27 11:52:47 -08:00
Derek Nola 5299941270 Switch to systemd image that works (#516)
- Use rancher/systemd-node which doesn't cause k3s to crash
- Expand requirements for testing, ensure deployments become ready at each playbook
- Add logging on failure for debugging

Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-02-27 09:38:38 -08:00
Pavlo 9650436585 fix: use correct variable for k3s old token for agents in upgrade.yml playbook (#513)
Signed-off-by: paulkarabilo <582643+paulkarabilo@users.noreply.github.com>
2026-02-26 12:04:16 -08:00
Jon S. Stumpf a3bf02f069 fix: skip redundant fact gathering in server and agent plays
Signed-off-by: Jon S. Stumpf <jon.stumpf@gmail.com>
2026-02-26 12:03:56 -08:00
Jon S. Stumpf 6fcd4d3748 fix: wait for control plane to be ready before agents join
Signed-off-by: Jon S. Stumpf <jon.stumpf@gmail.com>
2026-02-26 12:03:56 -08:00
laszlojau 77b49f76ce Fix the 'Save the existing K3s token if needed' task (#503)
Signed-off-by: laszlojau <49835454+laszlojau@users.noreply.github.com>
2026-02-05 11:23:26 -08:00
Derek Nola bc3f66be7b Add HA Server test (#491)
* Add HA Server test
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-01-26 09:15:58 -08:00
Derek Nola 1172805585 Install airgap selinux rpms when avaliable (#500)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-01-23 09:59:21 -08:00
Gilles H. 34073379ce Fix regex archlinux boot.txt (cgroup) (#499)
Update the regular expression to have a more specific match search term
for cgroup flags

Issue #495

Signed-off-by: Gilles Habran <gilleshabran@protonmail.com>
2026-01-20 12:19:20 -08:00
Derek Nola 2a0c43182b Provide configurable server/agent group names for airgap role (#497)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-01-20 10:21:32 -08:00
Derek Nola f6491bb524 Support openrc systems on agent nodes, added openrc test matrix (#489)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-01-20 09:29:40 -08:00
Derek Nola 67ca2bfd1c Ensure agents are upgraded correctly, pass token (#484)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-01-13 09:41:29 -08:00
Derek Nola a2a36f1fe5 Don't run yamlint on the GHA
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-01-12 13:32:23 -08:00
Derek Nola 6d6b0b9218 Enforce similar cgroup replacement pattern across OSes, fix lint naming
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-01-12 13:32:23 -08:00
Derek Nola e4f8d8d737 k3s-upgrade lint naming
Signed-off-by: Derek Nola <derek.nola@suse.com>
2026-01-12 13:32:23 -08:00