Skip to content

Commit

Permalink
vsphere Nutanix defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
mitalipaygude committed Jun 10, 2024
1 parent 5a57ebb commit 2770570
Show file tree
Hide file tree
Showing 9 changed files with 1,575 additions and 5 deletions.
17 changes: 17 additions & 0 deletions pkg/providers/nutanix/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,15 @@ func buildTemplateMapCP(

if clusterSpec.Cluster.Spec.ControlPlaneConfiguration.KubeletConfiguration != nil {
cpKubeletConfig := clusterSpec.Cluster.Spec.ControlPlaneConfiguration.KubeletConfiguration.Object
if _, ok := cpKubeletConfig["tlsCipherSuites"]; !ok {
cpKubeletConfig["tlsCipherSuites"] = crypto.SecureCipherSuiteNames()
}

if _, ok := cpKubeletConfig["resolvConf"]; !ok {
if clusterSpec.Cluster.Spec.ClusterNetwork.DNS.ResolvConf != nil {
cpKubeletConfig["resolvConf"] = clusterSpec.Cluster.Spec.ClusterNetwork.DNS.ResolvConf.Path
}
}
kcString, err := yaml.Marshal(cpKubeletConfig)
if err != nil {
return nil, fmt.Errorf("error marshaling %v", err)
Expand Down Expand Up @@ -405,6 +413,15 @@ func buildTemplateMapMD(clusterSpec *cluster.Spec, workerNodeGroupMachineSpec v1

if workerNodeGroupConfiguration.KubeletConfiguration != nil {
wnKubeletConfig := workerNodeGroupConfiguration.KubeletConfiguration.Object
if _, ok := wnKubeletConfig["tlsCipherSuites"]; !ok {
wnKubeletConfig["tlsCipherSuites"] = crypto.SecureCipherSuiteNames()
}

if _, ok := wnKubeletConfig["resolvConf"]; !ok {
if clusterSpec.Cluster.Spec.ClusterNetwork.DNS.ResolvConf != nil {
wnKubeletConfig["resolvConf"] = clusterSpec.Cluster.Spec.ClusterNetwork.DNS.ResolvConf.Path
}
}
kcString, err := yaml.Marshal(wnKubeletConfig)
if err != nil {
return nil, fmt.Errorf("error marshaling %v", err)
Expand Down
15 changes: 15 additions & 0 deletions pkg/providers/nutanix/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ func TestNewNutanixTemplateBuilderKubeletConfiguration(t *testing.T) {
"maxPods": 20,
},
}
buildSpec.Cluster.Spec.ClusterNetwork.DNS = anywherev1.DNS{
ResolvConf: &anywherev1.ResolvConf{
Path: "test-path",
},
}

buildSpec.Cluster.Spec.WorkerNodeGroupConfigurations[0].KubeletConfiguration = &unstructured.Unstructured{
Object: map[string]interface{}{
Expand All @@ -113,6 +118,11 @@ func TestNewNutanixTemplateBuilderKubeletConfiguration(t *testing.T) {
spec, err := builder.GenerateCAPISpecControlPlane(buildSpec)
assert.NoError(t, err)
assert.NotNil(t, spec)
t.Logf("data\n %v\n", string(spec))

cpSpec, err := os.ReadFile("testdata/expected_cp.yaml")
assert.NoError(t, err)
assert.Equal(t, cpSpec, spec)

workloadTemplateNames := map[string]string{
"eksa-unit-test": "eksa-unit-test",
Expand All @@ -123,6 +133,11 @@ func TestNewNutanixTemplateBuilderKubeletConfiguration(t *testing.T) {
workerSpec, err := builder.GenerateCAPISpecWorkers(buildSpec, workloadTemplateNames, kubeadmconfigTemplateNames)
assert.NoError(t, err)
assert.NotNil(t, workerSpec)
t.Logf("data\n %v\n", string(workerSpec))

wnSpec, err := os.ReadFile("testdata/expected_wn.yaml")
assert.NoError(t, err)
assert.Equal(t, wnSpec, workerSpec)
}

func TestNewNutanixTemplateBuilderGenerateCAPISpecControlPlaneFailure(t *testing.T) {
Expand Down
Loading

0 comments on commit 2770570

Please sign in to comment.