Skip to content

Support rotating certs in running pods instead of restarting them #769

Description

@soenkeliebau

Description

Right now, when a cert from the secret-operator gets close to expiring, the restarter just kills the pod based on the annotation set by secret-op (I think). That works, but it’s annoying for things that are slow to come back up or don't handle restarts well (looking at you, NiFi!), and it means short cert lifetimes come with a lot of restarts.

Some products can already reload certs from disk on their own. For example NiFi does this with nifi.security.autoreload.enabled. For products like that, it’d be nice if we could swap the cert in the volume and let the product take it from there, without forcing an unneeded restart on the pod.

The CSI lifecyle in Kubernetes has a hook for this: if we set requiresRepublish: true on our CSIDriver, the kubelet keeps calling NodePublishVolume for volumes that are already mounted. We can use that to check whether the cert is past its replace time and, if so, issue a new one and write it into the existing volume. We already compute that time for the restarter annotation, so we’d mainly need to keep it somewhere cheap to check, for example in memory with a small file in the volume as a fallback after the driver restarts.

This would have to be opt-in per volume, since products that don’t reload would just keep using the old cert until it expires. We’d probably also keep the restarter annotation as a safety net in case reissuing fails.

Bit of file handling to investigate since we don't want half-written certs being read, so probably need to come up with some symlink or mv magic, but that should be doable.

Activity

  1. soenkeliebau commented on Nov 5, 2026

    @soenkeliebau
    MemberAuthor

    Sidequest for #620: we could add a check to the republish hook to see if the cert contains podips and if not and the pod was assigned ips, reissue the cert.
    For tools that support reloading certs that'd "just work" - for other tools we'd need to delay the start until this has happened somehow if we want to use this.

    This should be fairly simple .. have secret op touch a ips_present file in the secret-op volume after it ran again and generated certs with ips, and the operator adds until [ -e /stackable/tls/ips_present ]; do sleep 1; done in the list of commands somewhere after starting containerdebug probably, that'll cause the real process to only start once ips are in the cert..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions