-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Controller manager args for clusterapi (#2387)
- Loading branch information
1 parent
c96cc72
commit 20ab30a
Showing
8 changed files
with
121 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package clusterapi | ||
|
||
import ( | ||
"github.com/aws/eks-anywhere/pkg/cluster" | ||
) | ||
|
||
func ControllerManagerArgs(clusterSpec *cluster.Spec) ExtraArgs { | ||
return SecureTlsCipherSuitesExtraArgs(). | ||
Append(NodeCIDRMaskExtraArgs(&clusterSpec.Cluster.Spec.ClusterNetwork)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package clusterapi_test | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/aws/eks-anywhere/internal/test" | ||
"github.com/aws/eks-anywhere/pkg/api/v1alpha1" | ||
"github.com/aws/eks-anywhere/pkg/cluster" | ||
"github.com/aws/eks-anywhere/pkg/clusterapi" | ||
) | ||
|
||
func TestSetControllerManagerArgs(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
clusterSpec *cluster.Spec | ||
want clusterapi.ExtraArgs | ||
}{ | ||
{ | ||
name: "without Node CIDR mask", | ||
clusterSpec: givenClusterSpec(), | ||
want: map[string]string{"tls-cipher-suites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"}, | ||
}, | ||
{ | ||
name: "with Node CIDR mask", | ||
clusterSpec: givenClusterSpecWithNodeCIDR(), | ||
want: map[string]string{"node-cidr-mask-size": "28", "tls-cipher-suites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := clusterapi.ControllerManagerArgs(tt.clusterSpec) | ||
if !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("ControllerManagerArgs()/%s got = %v, want %v", tt.name, got, tt.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func givenClusterSpecWithNodeCIDR() *cluster.Spec { | ||
cluster := givenClusterSpec() | ||
nodeCidrMaskSize := new(int) | ||
*nodeCidrMaskSize = 28 | ||
cluster.Cluster.Spec.ClusterNetwork = v1alpha1.ClusterNetwork{ | ||
Nodes: &v1alpha1.Nodes{CIDRMaskSize: nodeCidrMaskSize}, | ||
} | ||
return cluster | ||
} | ||
|
||
func givenClusterSpec() *cluster.Spec { | ||
return test.NewClusterSpec(func(s *cluster.Spec) { | ||
s.Cluster = &v1alpha1.Cluster{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "snow-test", | ||
Namespace: "test-namespace", | ||
}, | ||
Spec: v1alpha1.ClusterSpec{ | ||
ClusterNetwork: v1alpha1.ClusterNetwork{ | ||
CNI: v1alpha1.Cilium, | ||
Pods: v1alpha1.Pods{ | ||
CidrBlocks: []string{ | ||
"10.1.0.0/16", | ||
}, | ||
}, | ||
Services: v1alpha1.Services{ | ||
CidrBlocks: []string{ | ||
"10.96.0.0/12", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
}) | ||
} | ||
|
||
func tlsCipherSuitesArgs() map[string]string { | ||
return map[string]string{"tls-cipher-suites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters