Skip to content

Commit

Permalink
Add api server extra args map to cluster spec
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1999 committed Mar 2, 2024
1 parent 57c91bc commit aff6a39
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 3 deletions.
6 changes: 6 additions & 0 deletions config/crd/bases/anywhere.eks.amazonaws.com_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ spec:
type: object
controlPlaneConfiguration:
properties:
apiServerExtraArgs:
additionalProperties:
type: string
description: ApiServerExtraArgs defines the flags to configure
for the API server.
type: object
certSans:
description: CertSANs is a slice of domain names or IPs to be
added as Subject Name Alternatives of the Kube API Servers Certificate.
Expand Down
6 changes: 6 additions & 0 deletions config/manifest/eksa-components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3854,6 +3854,12 @@ spec:
type: object
controlPlaneConfiguration:
properties:
apiServerExtraArgs:
additionalProperties:
type: string
description: ApiServerExtraArgs defines the flags to configure
for the API server.
type: object
certSans:
description: CertSANs is a slice of domain names or IPs to be
added as Subject Name Alternatives of the Kube API Servers Certificate.
Expand Down
4 changes: 3 additions & 1 deletion pkg/api/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ type ControlPlaneConfiguration struct {
CertSANs []string `json:"certSans,omitempty"`
// MachineHealthCheck is a control-plane level override for the timeouts and maxUnhealthy specified in the top-level MHC configuration. If not configured, the defaults in the top-level MHC configuration are used.
MachineHealthCheck *MachineHealthCheck `json:"machineHealthCheck,omitempty"`
// ApiServerExtraArgs defines the flags to configure for the API server.
ApiServerExtraArgs map[string]string `json:"apiServerExtraArgs,omitempty"`
}

// MachineHealthCheck allows to configure timeouts for machine health checks. Machine Health Checks are responsible for remediating unhealthy Machines.
Expand Down Expand Up @@ -363,7 +365,7 @@ func (n *ControlPlaneConfiguration) Equal(o *ControlPlaneConfiguration) bool {
}
return n.Count == o.Count && n.MachineGroupRef.Equal(o.MachineGroupRef) &&
TaintsSliceEqual(n.Taints, o.Taints) && MapEqual(n.Labels, o.Labels) &&
SliceEqual(n.CertSANs, o.CertSANs)
SliceEqual(n.CertSANs, o.CertSANs) && MapEqual(n.ApiServerExtraArgs, o.ApiServerExtraArgs)
}

type Endpoint struct {
Expand Down
7 changes: 7 additions & 0 deletions pkg/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions pkg/clusterapi/extraargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ func EtcdEncryptionExtraArgs(config *[]v1alpha1.EtcdEncryption) ExtraArgs {
return args
}

func ApiServerExtraArgs(apiServerExtraArgs map[string]string) ExtraArgs {
args := ExtraArgs{}
for k, v := range apiServerExtraArgs {
args.AddIfNotEmpty(k, v)
}
return args
}

func PodIAMAuthExtraArgs(podIAMConfig *v1alpha1.PodIAMConfig) ExtraArgs {
if podIAMConfig == nil {
return nil
Expand Down
33 changes: 33 additions & 0 deletions pkg/clusterapi/extraargs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,39 @@ func TestExtraArgsToPartialYaml(t *testing.T) {
}
}

func TestApiServerExtraArgs(t *testing.T) {
tests := []struct {
testName string
apiServerExtraArgs map[string]string
want clusterapi.ExtraArgs
}{
{
testName: "no args",
apiServerExtraArgs: map[string]string{},
want: clusterapi.ExtraArgs{},
},
{
testName: "with args",
apiServerExtraArgs: map[string]string{
"service-account-issuer": "https://my-custom-issuer-url",
"service-account-jwks-uri": "http://my-custom-jwks-uri/openid/v1/jwks",
},
want: clusterapi.ExtraArgs{
"service-account-issuer": "https://my-custom-issuer-url",
"service-account-jwks-uri": "http://my-custom-jwks-uri/openid/v1/jwks",
},
},
}

for _, tt := range tests {
t.Run(tt.testName, func(t *testing.T) {
if got := clusterapi.ApiServerExtraArgs(tt.apiServerExtraArgs); !reflect.DeepEqual(got, tt.want) {
t.Errorf("ApiServerExtraArgs() = %v, want %v", got, tt.want)
}
})
}
}

func TestAwsIamAuthExtraArgs(t *testing.T) {
tests := []struct {
testName string
Expand Down
1 change: 1 addition & 0 deletions pkg/providers/cloudstack/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func buildTemplateMapCP(clusterSpec *cluster.Spec) (map[string]interface{}, erro
Append(clusterapi.AwsIamAuthExtraArgs(clusterSpec.AWSIamConfig)).
Append(clusterapi.PodIAMAuthExtraArgs(clusterSpec.Cluster.Spec.PodIAMConfig)).
Append(clusterapi.EtcdEncryptionExtraArgs(clusterSpec.Cluster.Spec.EtcdEncryption)).
Append(clusterapi.ApiServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.ApiServerExtraArgs)).
Append(sharedExtraArgs)

controllerManagerExtraArgs := clusterapi.SecureTlsCipherSuitesExtraArgs().
Expand Down
1 change: 1 addition & 0 deletions pkg/providers/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ func buildTemplateMapCP(clusterSpec *cluster.Spec) (map[string]interface{}, erro
apiServerExtraArgs := clusterapi.OIDCToExtraArgs(clusterSpec.OIDCConfig).
Append(clusterapi.AwsIamAuthExtraArgs(clusterSpec.AWSIamConfig)).
Append(clusterapi.PodIAMAuthExtraArgs(clusterSpec.Cluster.Spec.PodIAMConfig)).
Append(clusterapi.ApiServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.ApiServerExtraArgs)).
Append(sharedExtraArgs)
controllerManagerExtraArgs := clusterapi.SecureTlsCipherSuitesExtraArgs().
Append(clusterapi.NodeCIDRMaskExtraArgs(&clusterSpec.Cluster.Spec.ClusterNetwork))
Expand Down
3 changes: 2 additions & 1 deletion pkg/providers/nutanix/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ func buildTemplateMapCP(
apiServerExtraArgs := clusterapi.OIDCToExtraArgs(clusterSpec.OIDCConfig).
Append(clusterapi.AwsIamAuthExtraArgs(clusterSpec.AWSIamConfig)).
Append(clusterapi.PodIAMAuthExtraArgs(clusterSpec.Cluster.Spec.PodIAMConfig)).
Append(clusterapi.EtcdEncryptionExtraArgs(clusterSpec.Cluster.Spec.EtcdEncryption))
Append(clusterapi.EtcdEncryptionExtraArgs(clusterSpec.Cluster.Spec.EtcdEncryption)).
Append(clusterapi.ApiServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.ApiServerExtraArgs))
kubeletExtraArgs := clusterapi.SecureTlsCipherSuitesExtraArgs().
Append(clusterapi.ResolvConfExtraArgs(clusterSpec.Cluster.Spec.ClusterNetwork.DNS.ResolvConf)).
Append(clusterapi.ControlPlaneNodeLabelsExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration))
Expand Down
3 changes: 2 additions & 1 deletion pkg/providers/tinkerbell/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ func buildTemplateMapCP(

apiServerExtraArgs := clusterapi.OIDCToExtraArgs(clusterSpec.OIDCConfig).
Append(clusterapi.AwsIamAuthExtraArgs(clusterSpec.AWSIamConfig)).
Append(clusterapi.PodIAMAuthExtraArgs(clusterSpec.Cluster.Spec.PodIAMConfig))
Append(clusterapi.PodIAMAuthExtraArgs(clusterSpec.Cluster.Spec.PodIAMConfig)).
Append(clusterapi.ApiServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.ApiServerExtraArgs))

kubeletExtraArgs := clusterapi.SecureTlsCipherSuitesExtraArgs().
Append(clusterapi.ResolvConfExtraArgs(clusterSpec.Cluster.Spec.ClusterNetwork.DNS.ResolvConf)).
Expand Down
1 change: 1 addition & 0 deletions pkg/providers/vsphere/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func buildTemplateMapCP(
Append(clusterapi.AwsIamAuthExtraArgs(clusterSpec.AWSIamConfig)).
Append(clusterapi.PodIAMAuthExtraArgs(clusterSpec.Cluster.Spec.PodIAMConfig)).
Append(clusterapi.EtcdEncryptionExtraArgs(clusterSpec.Cluster.Spec.EtcdEncryption)).
Append(clusterapi.ApiServerExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.ApiServerExtraArgs)).
Append(sharedExtraArgs)
controllerManagerExtraArgs := clusterapi.SecureTlsCipherSuitesExtraArgs().
Append(clusterapi.NodeCIDRMaskExtraArgs(&clusterSpec.Cluster.Spec.ClusterNetwork))
Expand Down

0 comments on commit aff6a39

Please sign in to comment.