Skip to content

Commit

Permalink
Block settings for provider id and cloud provider
Browse files Browse the repository at this point in the history
  • Loading branch information
mitalipaygude committed Jun 10, 2024
1 parent 560fbf4 commit 92bceac
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/api/v1alpha1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ func validateKubeletConfiguration(eksakubeconfig *unstructured.Unstructured) err
return fmt.Errorf("unmarshaling KubeletConfiguration for %v", err)
}

if _, ok := eksakubeconfig.Object["providerID"]; ok {
return errors.New("can not override providerID and cloudProvider (set by EKS Anywhere)")
}

return nil
}

Expand Down
48 changes: 47 additions & 1 deletion pkg/api/v1alpha1/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ func TestValidateClusterConfigContent(t *testing.T) {
}
c.Spec.WorkerNodeGroupConfigurations[0].KubeletConfiguration = &unstructured.Unstructured{
Object: map[string]interface{}{
"maxPods": 20,
"maxPods": 25,
"apiVersion": "kubelet.config.k8s.io/v1beta1",
"kind": "KubeletConfiguration",
},
Expand Down Expand Up @@ -1213,6 +1213,52 @@ func TestValidateClusterConfigContent(t *testing.T) {
wantErr: true,
err: "unknown field",
},
{
testName: "providerid error",
cluster: baseCluster(func(c *Cluster) {
c.Spec.WorkerNodeGroupConfigurations[0].KubeletConfiguration = &unstructured.Unstructured{
Object: map[string]interface{}{
"maxPods": 20,
"apiVersion": "kubelet.config.k8s.io/v1beta1",
"kind": "KubeletConfiguration",
"providerID": "provider id",
},
}
c.Spec.ControlPlaneConfiguration.KubeletConfiguration = &unstructured.Unstructured{
Object: map[string]interface{}{
"maxPods": 20,
"apiVersion": "kubelet.config.k8s.io/v1beta1",
"kind": "KubeletConfiguration",
"providerID": "provider id",
},
}
}),
wantErr: true,
err: "can not override providerID and cloudProvider",
},
{
testName: "providerid error",
cluster: baseCluster(func(c *Cluster) {
c.Spec.WorkerNodeGroupConfigurations[0].KubeletConfiguration = &unstructured.Unstructured{
Object: map[string]interface{}{
"maxPods": 20,
"apiVersion": "kubelet.config.k8s.io/v1beta1",
"kind": "KubeletConfiguration",
"cloudProvider": "external",
},
}
c.Spec.ControlPlaneConfiguration.KubeletConfiguration = &unstructured.Unstructured{
Object: map[string]interface{}{
"maxPods": 20,
"apiVersion": "kubelet.config.k8s.io/v1beta1",
"kind": "KubeletConfiguration",
"cloudProvider": "external",
},
}
}),
wantErr: true,
err: "unknown field \"cloudProvider\"",
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 92bceac

Please sign in to comment.