Skip to content

Allow workers to use cached config#7685

Open
azmifarih wants to merge 1 commit into
k0sproject:mainfrom
azmifarih:issue-7379-allow-cached-worker-config
Open

Allow workers to use cached config#7685
azmifarih wants to merge 1 commit into
k0sproject:mainfrom
azmifarih:issue-7379-allow-cached-worker-config

Conversation

@azmifarih

Copy link
Copy Markdown

Fixes #7379

Adds --allow-cached-config for workers. When enabled, k0s still tries to load the worker profile from the Kubernetes API first. If the API server is unavailable, it falls back to the cached worker profile when the cached profile exists and matches the requested profile.

Default behavior is unchanged.

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

Unit tests:

go test ./pkg/component/worker/config ./pkg/config ./cmd/worker ./cmd/controller ./cmd/install
go test ./cmd/... ./pkg/component/worker/... ./pkg/config

Manual bootloose verification:

  1. Started a check-basic bootloose cluster.
  2. Confirmed /var/lib/k0s/worker-profile.yaml exists on worker0.
  3. Stopped the controller.
  4. Restarted worker0 with --allow-cached-config.
  5. Confirmed the worker used the cached profile:
Using cached worker profile "default" because the Kubernetes API is unavailable
  1. Confirmed k0s, containerd, and kubelet were running on the worker.
  2. Started the controller again.
  3. Confirmed both workers returned to Ready and all kube-system pods were Running.

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

Workers currently block startup when the Kubernetes API is unavailable because they must fetch the worker profile ConfigMap before starting local components. This prevents previously joined workers from starting kubelet with their cached configuration during temporary control plane outages.

Add an opt-in worker flag that falls back to the cached worker profile only when the API is unavailable and the cached profile matches the requested profile.

Fixes: k0sproject#7379
Signed-off-by: Muhammad Azmi Farih <muazfa@gmail.com>
@azmifarih azmifarih requested review from a team as code owners May 24, 2026 15:58
@azmifarih azmifarih requested review from kke and twz123 May 24, 2026 15:58
@jnummelin

Copy link
Copy Markdown
Member

@azmifarih What's the use case where you need this functionality?

@azmifarih

Copy link
Copy Markdown
Author

@azmifarih What's the use case where you need this functionality?

The main use case is edge/offline recovery.

If a worker that has already joined the cluster reboots while the control plane is temporarily unreachable, it currently blocks on fetching the worker profile ConfigMap. That means kubelet does not start, so local/static pod workloads on the worker cannot recover.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that need to be resolved.

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.

Support offline worker startup with cached kubelet configuration

2 participants