diff --git a/README.md b/README.md index 62a9516..cefd65f 100644 --- a/README.md +++ b/README.md @@ -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 ``` @@ -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: diff --git a/internal/config/config.go b/internal/config/config.go index 89db6b1..fb4bd5d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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:"-"` diff --git a/internal/k3s/cluster.go b/internal/k3s/cluster.go index 67513cf..100eabc 100644 --- a/internal/k3s/cluster.go +++ b/internal/k3s/cluster.go @@ -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 diff --git a/internal/k3s/hetzner.go b/internal/k3s/hetzner.go index cd095c5..de6821e 100644 --- a/internal/k3s/hetzner.go +++ b/internal/k3s/hetzner.go @@ -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 --- @@ -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: diff --git a/sonar-project.properties b/sonar-project.properties index 934cf21..7a830be 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -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=.