@@ -52,6 +52,7 @@ type ApplyAutoscalerToWorkloadClusterInput struct {
52
52
InfrastructureMachineTemplateKind string
53
53
InfrastructureMachinePoolTemplateKind string
54
54
InfrastructureMachinePoolKind string
55
+ InfrastructureAPIGroup string
55
56
// WorkloadYamlPath should point the yaml that will be applied on the workload cluster.
56
57
// The YAML file should:
57
58
// - Be creating the autoscaler deployment in the workload cluster
@@ -90,11 +91,15 @@ func ApplyAutoscalerToWorkloadCluster(ctx context.Context, input ApplyAutoscaler
90
91
workloadYamlTemplate , err := os .ReadFile (input .WorkloadYamlPath )
91
92
Expect (err ).ToNot (HaveOccurred (), "failed to load %s" , workloadYamlTemplate )
92
93
94
+ if input .InfrastructureAPIGroup == "" {
95
+ input .InfrastructureAPIGroup = "infrastructure.cluster.x-k8s.io"
96
+ }
97
+
93
98
// Get a server address for the Management Cluster.
94
99
// This address should be accessible from the workload cluster.
95
100
serverAddr , mgtClusterCA := getServerAddrAndCA (ctx , input .ManagementClusterProxy )
96
101
// Generate a token with the required permission that can be used by the autoscaler.
97
- token := getAuthenticationTokenForAutoscaler (ctx , input .ManagementClusterProxy , input .Cluster .Namespace , input .Cluster .Name , input .InfrastructureMachineTemplateKind , input .InfrastructureMachinePoolTemplateKind , input .InfrastructureMachinePoolKind )
102
+ token := getAuthenticationTokenForAutoscaler (ctx , input .ManagementClusterProxy , input .Cluster .Namespace , input .Cluster .Name , input .InfrastructureAPIGroup , input . InfrastructureMachineTemplateKind , input .InfrastructureMachinePoolTemplateKind , input .InfrastructureMachinePoolKind )
98
103
99
104
workloadYaml , err := ProcessYAML (& ProcessYAMLInput {
100
105
Template : workloadYamlTemplate ,
@@ -502,7 +507,7 @@ func EnableAutoscalerForMachinePoolTopologyAndWait(ctx context.Context, input En
502
507
503
508
// getAuthenticationTokenForAutoscaler returns a bearer authenticationToken with minimal RBAC permissions that will be used
504
509
// by the autoscaler running on the workload cluster to access the management cluster.
505
- func getAuthenticationTokenForAutoscaler (ctx context.Context , managementClusterProxy ClusterProxy , namespace string , cluster string , infraMachineTemplateKind , infraMachinePoolTemplateKind , infraMachinePoolKind string ) string {
510
+ func getAuthenticationTokenForAutoscaler (ctx context.Context , managementClusterProxy ClusterProxy , namespace string , cluster string , infraAPIGroup , infraMachineTemplateKind , infraMachinePoolTemplateKind , infraMachinePoolKind string ) string {
506
511
name := fmt .Sprintf ("cluster-%s" , cluster )
507
512
sa := & corev1.ServiceAccount {
508
513
ObjectMeta : metav1.ObjectMeta {
@@ -525,7 +530,7 @@ func getAuthenticationTokenForAutoscaler(ctx context.Context, managementClusterP
525
530
},
526
531
{
527
532
Verbs : []string {"get" , "list" },
528
- APIGroups : []string {"infrastructure.cluster.x-k8s.io" },
533
+ APIGroups : []string {infraAPIGroup },
529
534
Resources : []string {infraMachineTemplateKind , infraMachinePoolTemplateKind , infraMachinePoolKind },
530
535
},
531
536
},
0 commit comments