Skip to content

Commit

Permalink
add support to configure cluster autoscaler version
Browse files Browse the repository at this point in the history
  • Loading branch information
janosmiko committed Apr 25, 2023
1 parent 871876d commit f34a058
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ following from inside the directory where you have the config file for the clust
docker run --rm -it \
-v ${PWD}:/cluster \
-v ${HOME}/.ssh:/tmp/.ssh \
janosmiko/hetzner-k3s:v0.1.8 \
janosmiko/hetzner-k3s:v0.1.9 \
create-cluster \
--config-file /cluster/test.yaml
```
Expand Down Expand Up @@ -181,6 +181,9 @@ autoscaling_node_pools:
# - --ignore-mirror-pods-utilization
# - --v=4

# Specify the version of the Cluster Autoscaler to use.
#cluster_autoscaler_version: "v1.24.1"

additional_packages:
- somepackage
post_create_commands:
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Config struct {
WorkerNodePools []WorkerConfig `mapstructure:"worker_node_pools" validate:"dive"`
AutoscalingNodePools []AutoscalerConfig `mapstructure:"autoscaling_node_pools" validate:"dive"`
ClusterAutoscalerArgs []string `mapstructure:"cluster_autoscaler_args" validate:"-"`
ClusterAutoscalerVersion string `mapstructure:"cluster_autoscaler_version" validate:"-"`
AdditionalPackages []string `mapstructure:"additional_packages" validate:"-"`
PostCreateCommands []string `mapstructure:"post_create_commands" validate:"-"`
DefaultNameservers []string `mapstructure:"default_nameservers" validate:"-"`
Expand Down
8 changes: 8 additions & 0 deletions internal/k3s/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,14 @@ func (c *Client) kubeProxyArgsList() string {
return res
}

func (c *Client) clusterAutoscalerVersion() string {
if c.cluster.ClusterAutoscalerVersion == "" {
c.cluster.ClusterAutoscalerVersion = "v1.24.1"
}

return c.cluster.ClusterAutoscalerVersion
}

func (c *Client) clusterAutoscalerArgs() []string {
stderrThresholdIsDefined := false

Expand Down
3 changes: 2 additions & 1 deletion internal/k3s/hetzner.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ func (c *Client) hetznerClusterAutoscalerData() string { // nolint: funlen
tpldata["Image"] = c.image().Name
tpldata["CloudInit"] = c.autoscalerCloudInit()
tpldata["ClusterAutoscalerArgs"] = c.clusterAutoscalerArgs()
tpldata["ClusterAutoscalerVersion"] = c.clusterAutoscalerVersion()

tpl := `kubectl apply -f - <<-EOF
---
Expand Down Expand Up @@ -539,7 +540,7 @@ spec:
- key: node-role.kubernetes.io/master
operator: Exists
containers:
- image: k8s.gcr.io/autoscaling/cluster-autoscaler:v1.23.0 # or your custom image
- image: k8s.gcr.io/autoscaling/cluster-autoscaler:{{ .ClusterAutoscalerVersion }} # or your custom image
name: cluster-autoscaler
resources:
limits:
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sonar.organization=janosmiko

# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=hetzner-k3s
sonar.projectVersion=0.1.8
sonar.projectVersion=0.1.9

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.
Expand Down

0 comments on commit f34a058

Please sign in to comment.