Skip to content

Auto-discover kubelet bootstrap token from kube-system secrets#1622

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-kubelet-bootstrap-token
Draft

Auto-discover kubelet bootstrap token from kube-system secrets#1622
Copilot wants to merge 3 commits intomainfrom
copilot/add-kubelet-bootstrap-token

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

KUBELET_BOOTSTRAP_TOKEN is currently a required Helm chart value that users must manually extract and pass. This adds a controller that auto-discovers it from kube-system, matching the logic in configure-values.sh.

New controller: pkg/controllers/bootstraptoken/

Singleton controller that periodically (1h) lists secrets in kube-system with type=bootstrap.kubernetes.io/token, extracts token-id and token-secret fields, and writes the composed token to Options.KubeletClientTLSBootstrapToken.

  • Uses kubernetes.Interface directly — no manager cache, no broad secret watching
  • No-ops entirely (not registered) when the token is provided via options

Options change

kubelet-bootstrap-token is no longer required. If omitted, the controller handles it.

RBAC

New Role/RoleBinding scoped to kube-system namespace with list on secrets only. resourceNames cannot restrict list, so namespace scoping is the tightest bound available.

Tests

6 unit tests covering: happy path, missing secrets, malformed secrets, and token rotation across reconciles.

Copilot AI linked an issue Apr 4, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 4, 2026 02:57
…crets

- Create new singleton controller that reads bootstrap token secrets from
  kube-system namespace and updates options with the token value
- Make kubelet-bootstrap-token no longer a required option; auto-discovered
  from kube-system secrets if not provided via options
- Controller no-ops (not started) when bootstrap token is passed via options
- Uses kubernetes.Interface directly (not manager cache) for tightly scoped
  secret access, only reading from kube-system namespace
- Add RBAC Role and RoleBinding in Helm chart for reading secrets in
  kube-system namespace
- Add comprehensive unit tests for the controller
- Update options validation tests for the now-optional field

Agent-Logs-Url: https://github.com/Azure/karpenter-provider-azure/sessions/9fac1246-8422-4943-93b9-cf3e8805b9d7

Co-authored-by: matthchr <8798850+matthchr@users.noreply.github.com>
…t-only

- Use test context instead of context.Background() in test helper
- Reduce RBAC permissions to only 'list' verb (minimum needed for discovery)
- Add comment explaining why resourceNames cannot be used with list

Agent-Logs-Url: https://github.com/Azure/karpenter-provider-azure/sessions/9fac1246-8422-4943-93b9-cf3e8805b9d7

Co-authored-by: matthchr <8798850+matthchr@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Kubelet Bootstrap Token parameter in Helm chart Auto-discover kubelet bootstrap token from kube-system secrets Apr 4, 2026
Copilot AI requested a review from matthchr April 4, 2026 03:05
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.

Kubelet Bootstrap Token Parameter in Helm Chart

2 participants