Skip to content

Commit daad3ce

Browse files
authored
Merge pull request #18135 from bjornharrtell/hetzner-fix-cluster-autoscaler-addon
hetzner: add cluster-autoscaler addon for Hetzner cloud provider
2 parents 8ced3d1 + 9a22111 commit daad3ce

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,18 @@ spec:
374374
env:
375375
- name: AWS_REGION
376376
value: "{{ Region }}"
377+
{{ else if (eq GetCloudProvider "hetzner") }}
378+
env:
379+
- name: HCLOUD_TOKEN
380+
valueFrom:
381+
secretKeyRef:
382+
name: hcloud
383+
key: token
384+
- name: HCLOUD_NETWORK
385+
valueFrom:
386+
secretKeyRef:
387+
name: hcloud
388+
key: network
377389
{{ end }}
378390
livenessProbe:
379391
failureThreshold: 3

upup/pkg/fi/cloudup/template_functions.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,12 @@ func (tf *TemplateFunctions) GetClusterAutoscalerNodeGroups() map[string]Cluster
989989
cloud := tf.cloud.(gce.GCECloud)
990990
format := "https://www.googleapis.com/compute/v1/projects/%s/zones/%s/instanceGroups/%s"
991991
group.Other = fmt.Sprintf(format, cloud.Project(), ig.Spec.Zones[0], gce.NameForInstanceGroupManager(cluster.ObjectMeta.Name, ig.ObjectMeta.Name, ig.Spec.Zones[0]))
992+
} else if cluster.GetCloudProvider() == kops.CloudProviderHetzner {
993+
// Hetzner autoscaler expects --nodes=min:max:instanceType:region:name.
994+
// The subnet name for Hetzner is the location (e.g. "hel1"), which is
995+
// also used as the region argument by the Hetzner cloud provider.
996+
region := ig.Spec.Subnets[0]
997+
group.Other = fmt.Sprintf("%s:%s:%s", ig.Spec.MachineType, region, ig.Name)
992998
} else {
993999
group.Other = ig.Name + "." + cluster.Name
9941000
}

0 commit comments

Comments
 (0)