Skip to content

feat(hetzner): fix cluster-autoscaler addon for Hetzner cloud provider#18135

Open
bjornharrtell wants to merge 1 commit intokubernetes:masterfrom
bjornharrtell:hetzner-fix-cluster-autoscaler-addon
Open

feat(hetzner): fix cluster-autoscaler addon for Hetzner cloud provider#18135
bjornharrtell wants to merge 1 commit intokubernetes:masterfrom
bjornharrtell:hetzner-fix-cluster-autoscaler-addon

Conversation

@bjornharrtell
Copy link
Copy Markdown
Contributor

Summary

Two fixes to make the kops-managed cluster-autoscaler addon work correctly on Hetzner. Without these the addon is completely non-functional: the autoscaler pod cannot authenticate and node groups are never registered.

Fixes #18133
Fixes #18134

Also related to #17543 (original HCLOUD_TOKEN report).

Changes

1. Pass HCLOUD_TOKEN and HCLOUD_NETWORK to the autoscaler pod

File: upup/models/cloudup/resources/addons/cluster-autoscaler.addons.k8s.io/k8s-1.15.yaml.template

The addon template only had an env: block for AWS (AWS_REGION). Added an else if hetzner block that injects HCLOUD_TOKEN and HCLOUD_NETWORK from the hcloud secret in kube-system. This secret already exists because the CCM addon creates it — no new secrets are required.

2. Fix the --nodes flag format for Hetzner

File: upup/pkg/fi/cloudup/template_functions.go

GetClusterAutoscalerNodeGroups() was using ig.Name + "." + cluster.Name as the --nodes suffix for all non-GCE providers. This produces a 3-field format (min:max:name.cluster) that the Hetzner autoscaler cloud provider does not recognise.

Hetzner requires 5 fields: min:max:instanceType:region:name. Added a Hetzner branch that computes:

region := ig.Spec.Subnets[0]   // subnet name == Hetzner location, e.g. "hel1"
group.Other = fmt.Sprintf("%s:%s:%s", ig.Spec.MachineType, region, ig.Name)

Producing e.g. --nodes=1:5:cpx32:hel1:nodes-hel1.

Testing

Manually verified against a live Hetzner kops cluster (kops 1.35, Hetzner hel1). The generated addon manifest now contains the correct env vars and --nodes format, and the autoscaler pod authenticates and registers node groups successfully.

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 30, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @bjornharrtell. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hakman for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Two fixes to make the kops-managed cluster-autoscaler addon work
correctly on Hetzner:

1. Pass HCLOUD_TOKEN and HCLOUD_NETWORK env vars to the autoscaler
   pod. The addon template only had an env block for AWS (AWS_REGION);
   without the Hetzner token the autoscaler cannot authenticate and
   fails immediately on startup. The vars are sourced from the existing
   'hcloud' secret in kube-system, which is already created by the
   CCM addon.

2. Fix the --nodes flag format. GetClusterAutoscalerNodeGroups() was
   producing the generic '<name>.<cluster>' suffix for all non-GCE
   providers, giving a 3-field format (min:max:name.cluster) that the
   Hetzner cloud provider does not recognise. Hetzner requires 5
   fields: min:max:instanceType:region:name. The region argument is
   the Hetzner location name, which equals the subnet name stored in
   ig.Spec.Subnets[0] (e.g. 'hel1').
@bjornharrtell bjornharrtell force-pushed the hetzner-fix-cluster-autoscaler-addon branch from a2218eb to 9a22111 Compare March 30, 2026 16:10
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/addons cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[hetzner] cluster-autoscaler --nodes flag uses wrong format [hetzner] cluster-autoscaler addon missing HCLOUD_TOKEN environment variable

2 participants