Skip to content

Commit

Permalink
Add labels support in apibuilder (#2408)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayiwang7 authored Jun 14, 2022
1 parent 19348d0 commit 5063b92
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 14 deletions.
12 changes: 7 additions & 5 deletions pkg/clusterapi/apibuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,16 @@ func KubeadmControlPlane(clusterSpec *cluster.Spec, infrastructureObject APIObje
},
InitConfiguration: &bootstrapv1.InitConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: SecureTlsCipherSuitesExtraArgs(),
Taints: clusterSpec.Cluster.Spec.ControlPlaneConfiguration.Taints,
KubeletExtraArgs: SecureTlsCipherSuitesExtraArgs().
Append(ControlPlaneNodeLabelsExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration)),
Taints: clusterSpec.Cluster.Spec.ControlPlaneConfiguration.Taints,
},
},
JoinConfiguration: &bootstrapv1.JoinConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: SecureTlsCipherSuitesExtraArgs(),
Taints: clusterSpec.Cluster.Spec.ControlPlaneConfiguration.Taints,
KubeletExtraArgs: SecureTlsCipherSuitesExtraArgs().
Append(ControlPlaneNodeLabelsExtraArgs(clusterSpec.Cluster.Spec.ControlPlaneConfiguration)),
Taints: clusterSpec.Cluster.Spec.ControlPlaneConfiguration.Taints,
},
},
PreKubeadmCommands: []string{},
Expand Down Expand Up @@ -194,7 +196,7 @@ func KubeadmConfigTemplate(clusterSpec *cluster.Spec, workerNodeGroupConfig v1al
},
JoinConfiguration: &bootstrapv1.JoinConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: map[string]string{},
KubeletExtraArgs: WorkerNodeLabelsExtraArgs(workerNodeGroupConfig),
Taints: workerNodeGroupConfig.Taints,
},
},
Expand Down
21 changes: 18 additions & 3 deletions pkg/clusterapi/apibuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ func newApiBuilerTest(t *testing.T) apiBuilerTest {
TimeAdded: nil,
},
},
Labels: map[string]string{
"key1": "val1",
"key2": "val2",
},
},
KubernetesVersion: "1.21",
},
Expand Down Expand Up @@ -110,6 +114,9 @@ func newApiBuilerTest(t *testing.T) apiBuilerTest {
TimeAdded: nil,
},
},
Labels: map[string]string{
"key3": "val3",
},
}

kubeadmConfigTemplate := &bootstrapv1.KubeadmConfigTemplate{
Expand Down Expand Up @@ -246,7 +253,10 @@ func wantKubeadmControlPlane() *controlplanev1.KubeadmControlPlane {
},
InitConfiguration: &bootstrapv1.InitConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: tlsCipherSuitesArgs(),
KubeletExtraArgs: map[string]string{
"tls-cipher-suites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"node-labels": "key1=val1,key2=val2",
},
Taints: []v1.Taint{
{
Key: "key1",
Expand All @@ -259,7 +269,10 @@ func wantKubeadmControlPlane() *controlplanev1.KubeadmControlPlane {
},
JoinConfiguration: &bootstrapv1.JoinConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: tlsCipherSuitesArgs(),
KubeletExtraArgs: map[string]string{
"tls-cipher-suites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"node-labels": "key1=val1,key2=val2",
},
Taints: []v1.Taint{
{
Key: "key1",
Expand Down Expand Up @@ -314,7 +327,9 @@ func wantKubeadmConfigTemplate() *bootstrapv1.KubeadmConfigTemplate {
},
JoinConfiguration: &bootstrapv1.JoinConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: map[string]string{},
KubeletExtraArgs: map[string]string{
"node-labels": "key3=val3",
},
Taints: []v1.Taint{
{
Key: "key2",
Expand Down
30 changes: 24 additions & 6 deletions pkg/clusterapi/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ func TestConfigureAWSIAMAuthInKubeadmControlPlane(t *testing.T) {
},
InitConfiguration: &bootstrapv1.InitConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: tlsCipherSuitesArgs(),
KubeletExtraArgs: map[string]string{
"tls-cipher-suites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"node-labels": "key1=val1,key2=val2",
},
Taints: []v1.Taint{
{
Key: "key1",
Expand All @@ -123,7 +126,10 @@ func TestConfigureAWSIAMAuthInKubeadmControlPlane(t *testing.T) {
},
JoinConfiguration: &bootstrapv1.JoinConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: tlsCipherSuitesArgs(),
KubeletExtraArgs: map[string]string{
"tls-cipher-suites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"node-labels": "key1=val1,key2=val2",
},
Taints: []v1.Taint{
{
Key: "key1",
Expand Down Expand Up @@ -294,7 +300,10 @@ func TestConfigureOIDCInKubeadmControlPlane(t *testing.T) {
},
InitConfiguration: &bootstrapv1.InitConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: tlsCipherSuitesArgs(),
KubeletExtraArgs: map[string]string{
"tls-cipher-suites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"node-labels": "key1=val1,key2=val2",
},
Taints: []v1.Taint{
{
Key: "key1",
Expand All @@ -307,7 +316,10 @@ func TestConfigureOIDCInKubeadmControlPlane(t *testing.T) {
},
JoinConfiguration: &bootstrapv1.JoinConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: tlsCipherSuitesArgs(),
KubeletExtraArgs: map[string]string{
"tls-cipher-suites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"node-labels": "key1=val1,key2=val2",
},
Taints: []v1.Taint{
{
Key: "key1",
Expand Down Expand Up @@ -405,7 +417,10 @@ func TestConfigurePodIamAuthInKubeadmControlPlane(t *testing.T) {
},
InitConfiguration: &bootstrapv1.InitConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: tlsCipherSuitesArgs(),
KubeletExtraArgs: map[string]string{
"tls-cipher-suites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"node-labels": "key1=val1,key2=val2",
},
Taints: []v1.Taint{
{
Key: "key1",
Expand All @@ -418,7 +433,10 @@ func TestConfigurePodIamAuthInKubeadmControlPlane(t *testing.T) {
},
JoinConfiguration: &bootstrapv1.JoinConfiguration{
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
KubeletExtraArgs: tlsCipherSuitesArgs(),
KubeletExtraArgs: map[string]string{
"tls-cipher-suites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"node-labels": "key1=val1,key2=val2",
},
Taints: []v1.Taint{
{
Key: "key1",
Expand Down

0 comments on commit 5063b92

Please sign in to comment.