Skip to content

Use per hosts SANs for controllers in ConfigureK0S phase - #1128

Open
i-prudnikov wants to merge 2 commits into
k0sproject:mainfrom
i-prudnikov:feat/avoid-cross-controllers-IP-in-SAN
Open

Use per hosts SANs for controllers in ConfigureK0S phase#1128
i-prudnikov wants to merge 2 commits into
k0sproject:mainfrom
i-prudnikov:feat/avoid-cross-controllers-IP-in-SAN

Conversation

@i-prudnikov

Copy link
Copy Markdown
Contributor

This PR introduce dedicate SANs list per controller, rather than union of all CP nodes address.

The rationale behind:

  1. Controller A is never reached by the Controller B address. So we basically not needed other controllers addresses in the in the SANs list of the controller.
  2. Current logic of injecting union leads to the situation, that when new CP node is added to the cluster, all other controllers that are listed in the k0sctl config, would get a different k0s.yaml config file (with new SANs entries) that leads to certificate regeneration and k0scontroller restart , that is not necessary in this case.

This change keep all the same addresses injected into the SANs, but keep the SANs list to be dedicated per controller.

Signed-off-by: I. Prudnikov <22475397+i-prudnikov@users.noreply.github.com>
@i-prudnikov
i-prudnikov force-pushed the feat/avoid-cross-controllers-IP-in-SAN branch from 664bf2a to 3194e04 Compare July 29, 2026 14:11
@kke
kke requested a review from Copilot July 29, 2026 21:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the ConfigureK0s phase to generate controller-specific spec.api.sans lists (base SANs + that controller’s own addresses) instead of injecting a union of all controller addresses into every controller’s config. This aligns with k0sctl’s phase-driven orchestration by reducing unnecessary config churn (and resulting controller restarts) when adding new control-plane nodes.

Changes:

  • Build a per-controller base config (controllerBaseConfig) and inject per-host SANs via the new hostsSans helper.
  • Update configFor to accept a caller-provided base config mapping, enabling per-host configuration inputs.
  • Add unit tests covering per-host SAN composition, deduplication, and non-mutation of shared base inputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
phase/configure_k0s.go Switch SAN injection to per-controller configs; add hostsSans; update configFor signature and call sites.
phase/configure_k0s_test.go Add tests validating per-host SAN behavior and config generation with per-host SANs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread phase/configure_k0s.go Outdated
Comment on lines 120 to 124
defer func() {
if err := h.Sudo().FS().Remove(tempConfigPath); err != nil {
log.Warnf("%s: failed to delete temporary file %s: %s", h, tempConfigPath, err)
if err := c.Sudo().FS().Remove(tempConfigPath); err != nil {
log.Warnf("%s: failed to delete temporary file %s: %s", c, tempConfigPath, err)
}
}()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed (moved to helper function)

Signed-off-by: I. Prudnikov <22475397+i-prudnikov@users.noreply.github.com>
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.

2 participants