Timeline from 06:20 to 06:45: the first node down from 06:28:11 to 06:31:55, the second at 06:39, the third moved to r2 at an unknown time
|

dnf-automatic upgraded my Kubernetes: why cluster packages must be excluded from unattended updates

One Monday morning, looking at my small Kubernetes cluster’s state for an entirely different reason, I notice a detail in the version column. I had installed RKE2 as v1.36.6+rke2r1 four days earlier. All three nodes showed rke2r2, including the third, which failed at 13:28 that day for an unrelated hardware reason. Nobody had upgraded the…

One Monday morning, looking at my small Kubernetes cluster’s state for an entirely different reason, I notice a detail in the version column. I had installed RKE2 as v1.36.6+rke2r1 four days earlier. All three nodes showed rke2r2, including the third, which failed at 13:28 that day for an unrelated hardware reason. Nobody had upgraded the cluster, and yet it had been upgraded, overnight, without draining nodes, without an etcd snapshot and without my knowing.

$ kubectl get nodes
NAME     STATUS   ROLES                AGE     VERSION
node-a   Ready    control-plane,etcd   5d17h   v1.36.6+rke2r2
node-b   Ready    etcd                 5d17h   v1.36.6+rke2r2
node-c   NotReady control-plane,etcd   5d20h   v1.36.6+rke2r2

The culprit is a tool I’ve used for years on all my machines and gladly recommend: dnf-automatic. The story isn’t that it did its job badly. It did it exactly as designed, and that’s precisely the problem.

What dnf-automatic did, minute by minute

The RPM transaction log leaves no doubt. /var/log/dnf.rpm.log keeps every install and upgrade, with the time. RKE2 was installed on 20 November as revision r1, then replaced on the 24th at 06:28 by revision r2.

$ grep rke2 /var/log/dnf.rpm.log
2026-11-20T16:13:15+0100 SUBDEBUG Installed: rke2-server-1.36.6~rke2r1-0.el10.x86_64
2026-11-24T06:28:09+0100 SUBDEBUG Upgrade: rke2-server-1.36.6~rke2r2-0.el10.x86_64
2026-11-24T06:28:09+0100 SUBDEBUG Upgraded: rke2-server-1.36.6~rke2r1-0.el10.x86_64

RKE2 ships as RPM packages for Red Hat family distributions, from a Rancher repository. That repository follows a version branch, 1.36 here, and publishes fixes as they come. When Rancher released revision r2, a rebuild of the same Kubernetes version with updated components, the repository offered it like any other update. And dnf-automatic, configured to install everything, installed it.

# /etc/dnf/automatic.conf (excerpt)
[commands]
upgrade_type = default     # every update, not only security ones
random_sleep = 360         # up to 6 minutes of random delay per machine
download_updates = yes
apply_updates = yes        # install, not just download
reboot = never

Every setting matters. upgrade_type = default installs every available update, not only those fixing security issues, which the security value would do. apply_updates = yes actually installs, instead of just downloading. random_sleep adds a random delay, up to six minutes here, so all machines don’t hit the mirrors at the same second. And the [base] section accepts an exclude line: I had already listed Wazuh and MariaDB there, two programs I upgrade by hand, but not RKE2, which I had just installed.

The package restarts its own service

Upgrading a package doesn’t necessarily restart the service. Many daemons keep running the old binary until the next restart. So I wanted to know whether the control plane had really restarted, or only the files on disk had changed. The scripts embedded in an RPM are read with rpm -q --scripts.

$ rpm -q --scripts rke2-server | sed -n '/postuninstall/,$p'
postuninstall scriptlet (using /bin/sh):
if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
    # Package upgrade, not uninstall
    /usr/lib/systemd/systemd-update-helper mark-restart-system-units rke2-server.service || :
fi

The script run after the upgrade marks rke2-server.service for a restart. systemd-update-helper is Fedora and Red Hat’s tool that collects those requests and runs them at the end of the transaction. In other words, it’s intended: the package makes sure the new version runs. The system log confirms what followed.

Nov 24 06:28:09 rpm[935752]: upgrade: rke2-server-1.36.6~rke2r2 (from: rke2-server-1.36.6~rke2r1): success
Nov 24 06:28:11 systemd[1]: Stopping rke2-server.service - Rancher Kubernetes Engine v2 (server)...
Nov 24 06:28:11 systemd[1]: rke2-server.service: Unit process 9417 (containerd-shim) remains running after unit stopped.
Nov 24 06:28:11 systemd[1]: Starting rke2-server.service - Rancher Kubernetes Engine v2 (server)...
Nov 24 06:31:55 systemd[1]: Started rke2-server.service - Rancher Kubernetes Engine v2 (server).

The service stopped at 06:28:11 and was only ready again at 06:31:55, almost four minutes. The remains running after unit stopped lines are normal for RKE2: the containerd-shim processes carrying the containers survive the service stop, so applications weren’t killed. But for those four minutes, the Kubernetes API and that machine’s etcd member were gone. Eleven minutes later, at 06:39, the second machine did the same. The third did too, necessarily, since it reports version r2 itself; but it was powered off when I investigated, and I don’t know when it restarted.

Why it’s dangerous, even when all goes well

This time there was no damage. Revision r2 was a simple fix, every node came back, and the Kubernetes API answered when I looked. I know the two restarts I can date didn’t overlap; for the third, I don’t know. That’s exactly what worries me. My cluster has three etcd members. etcd works as long as a majority answers, two out of three here. If two machines draw close random delays, two members are gone at once, etcd loses quorum, and the Kubernetes API stops answering until one comes back. If it didn’t happen, chance protected me, not design.

Timeline from 06:20 to 06:45: the first node down from 06:28:11 to 06:31:55, the second at 06:39, the third moved to r2 at an unknown time
The dated restarts don’t overlap, but nothing in the configuration prevented it.

There’s also what a deliberate upgrade would have done and this one didn’t. RKE2’s procedure recommends upgrading one node at a time, servers first, taking an etcd snapshot beforehand, and draining the node to move its workloads. None of that happened. And the next update could be a minor version with removed APIs, or one requiring a specific order between servers and agents. A tool that installs whatever the repository offers knows nothing of those constraints.

Finally, my Ansible role declared rke2_version: 1.36.6~rke2r1. It only enforced that version at install time, with state: present, and never went back. Code and reality diverged without any signal: the source of truth was lying.

The fix: exclude in the repository, install knowingly

Several options exist. You can add rke2-* to dnf-automatic’s exclude line, but that only protects against dnf-automatic: a manual dnf upgrade run for something else would take RKE2 along. You can use dnf’s versionlock plugin, which pins an exact version, but then you have to unlock and relock it for every deliberate upgrade. I chose to put the exclusion on Rancher’s repositories themselves: for dnf, and so for dnf-automatic as for me, RKE2 packages no longer exist. Only the Ansible role sees them, thanks to disable_excludes: all in the install task.

# roles/rke2/tasks/main.yml (excerpt): the repositories hide rke2-* from dnf
- name: RKE2 repositories
  ansible.builtin.yum_repository:
    name: "{{ item.name }}"
    description: "{{ item.desc }}"
    baseurl: "{{ item.url }}"
    gpgcheck: true
    enabled: true
    # dnf-automatic upgraded rke2-server r1 -> r2 by itself and restarted the
    # control plane. RKE2 only moves through rke2_version and this role.
    exclude: "rke2-*"
  loop: "{{ rke2_repos }}"

# ...and the role itself is the only thing allowed to look past the exclude
- name: Install RKE2
  ansible.builtin.dnf:
    name: "rke2-{{ rke2_role }}-{{ rke2_version }}"
    state: present
    disable_excludes: all

This split has one advantage: RKE2 only moves when I change rke2_version and run the role. The version written in the Ansible repository becomes the truth again. I also aligned that variable with what actually runs, r2, since going back would have gained nothing.

dnf-automatic and a manual dnf upgrade go through the rancher-rke2 repositories, which exclude rke2-*, and find no package; only the Ansible role, with disable_excludes all, installs the chosen version, node by node
RKE2 packages no longer exist for dnf; only the Ansible role sees them.

The verification

An exclusion is tested by asking dnf the question dnf-automatic would ask. Without options, repoquery finds no rke2-server package, and check-update returns 0, meaning nothing to update there. With --disableexcludes=all, the three published versions reappear: the repository works, it’s only hidden.

# the packages are invisible to dnf, so to dnf-automatic too
$ dnf -q repoquery rke2-server
$ dnf -q check-update rke2-server; echo rc=$?
rc=0                                  # 0 = nothing to update
# ...but still there for whoever asks explicitly
$ dnf -q repoquery --disableexcludes=all rke2-server
rke2-server-0:1.36.5~rke2r1-0.el10.x86_64
rke2-server-0:1.36.6~rke2r1-0.el10.x86_64
rke2-server-0:1.36.6~rke2r2-0.el10.x86_64

The role was applied to the two running nodes; the third, down with a hardware fault at the time, will get it before rejoining the cluster. The next morning dnf-automatic ran as usual on both machines: a new kernel on one, Grafana and rsync on the other, and no RKE2 line in dnf.rpm.log. That second observation proves little as long as Rancher hasn’t released a new revision; the real proof is the query above, which shows dnf no longer sees the packages.

And the next upgrade

A deliberate upgrade becomes a separate operation, done in daytime and node by node. Drain the node, take an etcd snapshot, run the role with the new version, wait for the node to come back with the right version, then put it back in service before moving to the next.

# a deliberate upgrade, one node at a time
kubectl drain node-a --ignore-daemonsets --delete-emptydir-data
rke2 etcd-snapshot save --name pre-upgrade-$(date +%Y%m%d)
ansible-playbook site.yml -l node-a --tags rke2 -e rke2_version=1.36.7~rke2r1
kubectl get node node-a -o wide        # wait for Ready and the new version
kubectl uncordon node-a

What I take away

Automatic updates remain good practice for the vast majority of packages: the TLS library, the SSH server, the kernel that will load at the next reboot. They become dangerous for software forming a distributed system, where each machine depends on the others’ state, and for software whose package restarts the service itself. Kubernetes, etcd, a replicated database, a storage cluster: anything with a quorum or an upgrade order deserves an explicit exclusion.

The reflex to keep, every time you add software to a machine that updates itself, is one question: if this package is replaced at 06:00 with nobody watching, what happens? For RKE2, the answer was a control plane restarted three times unattended. The answer is now: nothing.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *