Skip to content

Conversation

@twz123
Copy link
Member

@twz123 twz123 commented Nov 26, 2025

Description

Follow-up to #6739.

Instead of writing the chart manifests to disk, apply them directly from in-memory data. For historical reasons, the CRD and Helm chart resources generated from the k0s configuration reside in the same stack. Therefore, only apply the stack if all the chart resources can be rendered successfully. This ensures that charts are not accidentally removed because the initial config reconciliation is late.

Remove the CRD detection loop and start the controller-runtime manager only after the first successful stack application so CRDs are guaranteed to exist before informers come up.

  • Use the standard client factory and remove the custom kubeconfig bootstrapping.
  • Introduce an iterator function for embedded CRDs that allows for reading the CRDs without using the CRD component.
  • Hardcode the dummy leader elector to always lead. A non-leading leader elector was only required during testing, when a simple function was sufficient.
  • Patch the cluster config to modify the charts in the addons inttest instead of fiddling with the filesystem, which was an implementation detail.
  • Drop the filesystem-based CRD component component. It's no longer in use. All CRDs are now applied in-memory.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

Checklist

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

It was erroneously assigned to a local variable, instead to the one of
the outer scope.

Fixes: 7b1c25b ("Apply the bootstraprbac stack directly")
Signed-off-by: Tom Wieczorek <[email protected]>
The system RBAC component fed an io.Reader into a resource builder to
extract unstructured objects and apply them as a stack in a retry loop.
This is a pattern that is reusable across components: Move this into its
own function in the applier package.

Signed-off-by: Tom Wieczorek <[email protected]>
There's no need to write them to the filesystem. Moreover, we can be
sure that whenever the CRD component is initialized, the CRDs have been
applied successfully, so we don't need to wait for the applier manager
to pick things up.

Add the etcd member reconciler as a cluster component, just as its CRD
stack. This ensures that the CRDs get applied before the reconciler
is started.

Leave out the Helm stack for now, as this is intertwined with the
extensions controller. Both need to be changed in lockstep.

Signed-off-by: Tom Wieczorek <[email protected]>
The CRDs are now guaranteed to be applied before it's started.

Signed-off-by: Tom Wieczorek <[email protected]>
The CRDs are now guaranteed to be applied before it's started.

Signed-off-by: Tom Wieczorek <[email protected]>
…directory

This prevents a nil pointer panic from occurring whenever an error
happens during directory traversal.

Fixes: c1f8c75 ("Cleanup unknown Helm chart manifest files")
Signed-off-by: Tom Wieczorek <[email protected]>
Allows for reading the CRDs without using the CRD component.

Signed-off-by: Tom Wieczorek <[email protected]>
Remove the custom kubeconfig bootstrapping.

Signed-off-by: Tom Wieczorek <[email protected]>
Hardcode the dummy leader elector to always lead. A non-leading leader
elector was only required during testing, when a simple function was
sufficient.

Use a factory function to create the dummy leader elector and make the
never channel a private field of it instead of using a global variable.
In k0s, there will only ever be one dummy leader elector, if any.
Sharing the channel seemed like a good idea, but global state always
comes back to bite you. When using testing/synctest, that channel was
never associated with a bubble. This made synctest unusable with the
dummy elector.

Signed-off-by: Tom Wieczorek <[email protected]>
Instead of fiddling with the file system, which is an implementation
detail.

Signed-off-by: Tom Wieczorek <[email protected]>
Instead of writing the chart manifests to disk, apply them directly
from in-memory data. For historical reasons, the CRD and Helm chart
resources generated from the k0s configuration reside in the same
stack. Therefore, only apply the stack if all the chart resources can
be rendered successfully. This ensures that charts are not accidentally
removed because the initial config reconciliation is late.

Remove the CRD detection loop and start the controller-runtime manager
only after the first successful stack application so CRDs are guaranteed
to exist before informers come up.

Signed-off-by: Tom Wieczorek <[email protected]>
It's no longer in use. All CRDs are now applied in-memory.

Signed-off-by: Tom Wieczorek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant