@@ -306,11 +306,32 @@ func (p *Puppet) writeHieraData(puppetPath string, cluster interfaces.Cluster) e
306306 return fmt .Errorf ("error writing global hiera config: %s" , err )
307307 }
308308
309+ // retrieve details for first worker instance pool
310+ workerMinCount := 0
311+ workerMaxCount := 0
312+ workerInstancePoolName := ""
313+ if cluster .Config ().Kubernetes .ClusterAutoscaler != nil && cluster .Config ().Kubernetes .ClusterAutoscaler .Enabled {
314+ for _ , instancePool := range cluster .InstancePools () {
315+ if instancePool .Role ().Name () == clusterv1alpha1 .KubernetesWorkerRoleName {
316+ workerMinCount = instancePool .MinCount ()
317+ workerMaxCount = instancePool .MaxCount ()
318+ workerInstancePoolName = instancePool .Name ()
319+ break
320+ }
321+ }
322+ }
323+
309324 // loop through instance pools
310325 for _ , instancePool := range cluster .InstancePools () {
311326
312327 classes , variables := contentInstancePoolConfig (cluster .Config (), instancePool .Config (), instancePool .Role ().Name ())
313328
329+ if instancePool .Role ().Name () == clusterv1alpha1 .KubernetesMasterRoleName && cluster .Config ().Kubernetes .ClusterAutoscaler != nil && cluster .Config ().Kubernetes .ClusterAutoscaler .Enabled {
330+ variables = append (variables , fmt .Sprintf (`kubernetes_addons::cluster_autoscaler::min_instances: %d` , workerMinCount ))
331+ variables = append (variables , fmt .Sprintf (`kubernetes_addons::cluster_autoscaler::max_instances: %d` , workerMaxCount ))
332+ variables = append (variables , fmt .Sprintf (`kubernetes_addons::cluster_autoscaler::instance_pool_name: "%s"` , workerInstancePoolName ))
333+ }
334+
314335 // classes
315336 err = p .writeLines (
316337 filepath .Join (hieraPath , "instance_pools" , fmt .Sprintf ("%s_classes.yaml" , instancePool .Name ())), classes ,
0 commit comments