Skip to content

Fix etcd cert secrets owner in remote host cluster mode#1258

Merged
apedriza merged 1 commit intok0sproject:mainfrom
kahirokunn:fix/etcd-certs-ownerref
Oct 22, 2025
Merged

Fix etcd cert secrets owner in remote host cluster mode#1258
apedriza merged 1 commit intok0sproject:mainfrom
kahirokunn:fix/etcd-certs-ownerref

Conversation

@kahirokunn
Copy link
Contributor

@kahirokunn kahirokunn commented Oct 22, 2025

Fixes #1259

Problem

  • ensureEtcdCertificates saved *-etcd-server, *-etcd-peer, and *-apiserver-etcd-client Secrets with an ownerReference pointing to k0smotron.io/Cluster.

Result

The following Secrets are now correctly created and persist in the hosting cluster:

  • <cluster>-etcd-server
  • <cluster>-etcd-peer
  • <cluster>-apiserver-etcd-client

Verified with:

kubectl -n mgmt get secret showing the three Secrets present
CleanShot 2025-10-22 at 15 07 49@2x
pod is running on external cluster
CleanShot 2025-10-22 at 15 08 20@2x
CleanShot 2025-10-22 at 15 08 44@2x

Cluster status progressing to Provisioned with ControlPlaneReady = True
CleanShot 2025-10-22 at 15 12 47@2x

cluster works good 👍
CleanShot 2025-10-22 at 15 11 33@2x

When K0smotronCluster uses spec.kubeconfigRef, etcd leaf certs (server/peer/apiserver-etcd-client) were generated but not persisted in the hosting cluster due to an incorrect OwnerReference.
Use the external owner when present (same as the control-plane certs path) to ensure secrets are created/retained and etcd pods can start.

Signed-off-by: kahirokunn <okinakahiro@gmail.com>
@kahirokunn kahirokunn requested a review from a team as a code owner October 22, 2025 06:13
@kahirokunn kahirokunn changed the title Fix etcd cert secrets owner in hosting cluster mode Fix etcd cert secrets owner in remote host cluster mode Oct 22, 2025
Copy link
Contributor

@apedriza apedriza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, but wondering if we should add some checks in the remote HCP e2e checking the proper garbage collection of the cluster resources. WDYT?

@kahirokunn
Copy link
Contributor Author

That could be a good addition from a different perspective than the bug fix currently being worked on.
Therefore, I think it would be better to address that in a separate PR.

@apedriza apedriza merged commit 5504fd4 into k0sproject:main Oct 22, 2025
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Etcd certificate Secrets immediately GC'd in remote host mode due to incorrect ownerReferences

2 participants