Skip to content

Commit

Permalink
Fix comments and rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
adiantum committed Oct 11, 2024
1 parent c515b67 commit 2a8bf41
Show file tree
Hide file tree
Showing 18 changed files with 1,283 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ spec:
required:
- type
type: object
gpus:
description: List of GPU devices that should be added to the VMs.
items:
description: NutanixGPUIdentifier holds VM GPU device configuration.
properties:
deviceID:
description: deviceID is the device ID of the GPU device.
format: int64
type: integer
name:
description: vendorID is the vendor ID of the GPU device.
type: string
type:
description: type is the type of the GPU device.
enum:
- deviceID
- name
type: string
required:
- type
type: object
type: array
image:
description: image is to identify the OS image uploaded to the Prism
Central (PC) The image identifier (uuid or name) can be obtained
Expand Down
7 changes: 4 additions & 3 deletions pkg/providers/nutanix/config/md-template.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .failureDomains }}{{- range $index, $fd := .failureDomains }}
{{- if $.failureDomains -}}{{ range $fd := $.failureDomains -}}
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
Expand Down Expand Up @@ -99,7 +99,8 @@ spec:
{{- end }}
{{- end }}
---
{{- end }}{{- else }}
{{ end -}}
{{- else -}}
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
Expand Down Expand Up @@ -209,7 +210,7 @@ spec:
{{- end }}
{{- end }}
---
{{- end }}
{{ end -}}
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
Expand Down
54 changes: 41 additions & 13 deletions pkg/providers/nutanix/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,29 +729,54 @@ func TestTemplateBuilderFailureDomains(t *testing.T) {

func TestTemplateBuilderWorkersFailureDomains(t *testing.T) {
for _, tc := range []struct {
Input string
OutputCP string
OutputMD string
Input string
OutputCP string
OutputMD string
workloadTemplateNames map[string]string
kubeadmconfigTemplateNames map[string]string
}{
{
Input: "testdata/eksa-cluster-worker-fds.yaml",
OutputCP: "testdata/expected_results_worker_fds.yaml",
OutputMD: "testdata/expected_results_worker_fds_md.yaml",
workloadTemplateNames: map[string]string{
"eksa-unit-test": "eksa-unit-test",
},
kubeadmconfigTemplateNames: map[string]string{
"eksa-unit-test": "eksa-unit-test",
},
},
{
Input: "testdata/eksa-cluster-multi-worker-fds.yaml",
OutputCP: "testdata/expected_results_multi_worker_fds.yaml",
OutputMD: "testdata/expected_results_multi_worker_fds_md.yaml",
workloadTemplateNames: map[string]string{
"eksa-unit-test-1": "eksa-unit-test-1",
"eksa-unit-test-2": "eksa-unit-test-2",
"eksa-unit-test-3": "eksa-unit-test-3",
},
kubeadmconfigTemplateNames: map[string]string{
"eksa-unit-test-1": "eksa-unit-test",
"eksa-unit-test-2": "eksa-unit-test",
"eksa-unit-test-3": "eksa-unit-test",
},
},
} {
clusterSpec := test.NewFullClusterSpec(t, tc.Input)
machineConf := clusterSpec.NutanixMachineConfig(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.MachineGroupRef.Name)
workerConfs := make(map[string]anywherev1.NutanixMachineConfigSpec)
workerConfSpecs := make(map[string]anywherev1.NutanixMachineConfigSpec)
for _, worker := range clusterSpec.Cluster.Spec.WorkerNodeGroupConfigurations {
workerConf := clusterSpec.NutanixMachineConfig(worker.MachineGroupRef.Name)
workerConfs[worker.MachineGroupRef.Name] = workerConf.Spec
workerConfSpecs[worker.MachineGroupRef.Name] = workerConf.Spec
}
dcConf := clusterSpec.NutanixDatacenter

// workerMachineConfigs := clusterSpec.NutanixMachineConfigs

t.Setenv(constants.EksaNutanixUsernameKey, "admin")
t.Setenv(constants.EksaNutanixPasswordKey, "password")
creds := GetCredsFromEnv()
builder := NewNutanixTemplateBuilder(&dcConf.Spec, &machineConf.Spec, &machineConf.Spec, workerConfs, creds, time.Now)
builder := NewNutanixTemplateBuilder(&dcConf.Spec, &machineConf.Spec, &machineConf.Spec, workerConfSpecs, creds, time.Now)
assert.NotNil(t, builder)

buildSpec := test.NewFullClusterSpec(t, tc.Input)
Expand All @@ -761,13 +786,16 @@ func TestTemplateBuilderWorkersFailureDomains(t *testing.T) {
assert.NotNil(t, cpSpec)
test.AssertContentToFile(t, string(cpSpec), tc.OutputCP)

workloadTemplateNames := map[string]string{
"eksa-unit-test": "eksa-unit-test",
}
kubeadmconfigTemplateNames := map[string]string{
"eksa-unit-test": "eksa-unit-test",
}
workerSpec, err := builder.GenerateCAPISpecWorkers(buildSpec, workloadTemplateNames, kubeadmconfigTemplateNames)
// workloadTemplateNames, kubeadmconfigTemplateNames := getTemplateNames(clusterSpec, builder, workerMachineConfigs)
// workloadTemplateNames := map[string]string{
// "eksa-unit-test-1": "eksa-unit-test-1",
// "eksa-unit-test-2": "eksa-unit-test-2",
// "eksa-unit-test-3": "eksa-unit-test-3",
// }
// kubeadmconfigTemplateNames := map[string]string{
// "eksa-unit-test": "eksa-unit-test",
// }
workerSpec, err := builder.GenerateCAPISpecWorkers(buildSpec, tc.workloadTemplateNames, tc.kubeadmconfigTemplateNames)
assert.NoError(t, err)
assert.NotNil(t, workerSpec)
test.AssertContentToFile(t, string(workerSpec), tc.OutputMD)
Expand Down
177 changes: 177 additions & 0 deletions pkg/providers/nutanix/testdata/eksa-cluster-multi-worker-fds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
apiVersion: anywhere.eks.amazonaws.com/v1alpha1
kind: Cluster
metadata:
name: eksa-unit-test
namespace: default
spec:
kubernetesVersion: "1.19"
controlPlaneConfiguration:
name: eksa-unit-test
count: 3
endpoint:
host: test-ip
machineGroupRef:
name: eksa-unit-test
kind: NutanixMachineConfig
workerNodeGroupConfigurations:
- count: 4
name: eksa-unit-test-1
machineGroupRef:
name: eksa-unit-test-1
kind: NutanixMachineConfig
- count: 3
name: eksa-unit-test-2
machineGroupRef:
name: eksa-unit-test-2
kind: NutanixMachineConfig
- count: 2
name: eksa-unit-test-3
machineGroupRef:
name: eksa-unit-test-3
kind: NutanixMachineConfig
datacenterRef:
kind: NutanixDatacenterConfig
name: eksa-unit-test
clusterNetwork:
cni: "cilium"
pods:
cidrBlocks:
- 192.168.0.0/16
services:
cidrBlocks:
- 10.96.0.0/12
---
apiVersion: anywhere.eks.amazonaws.com/v1alpha1
kind: NutanixDatacenterConfig
metadata:
name: eksa-unit-test
namespace: default
spec:
endpoint: "prism.nutanix.com"
port: 9440
credentialRef:
kind: Secret
name: "nutanix-credentials"
failureDomains:
- name: "pe1"
workerMachineGroups:
- eksa-unit-test-1
- eksa-unit-test-2
- eksa-unit-test-3
cluster:
type: name
name: "prism-cluster"
subnets:
- type: uuid
uuid: "2d166190-7759-4dc6-b835-923262d6b497"
- name: "pe2"
workerMachineGroups:
- eksa-unit-test-1
- eksa-unit-test-2
cluster:
type: uuid
uuid: "4d69ca7d-022f-49d1-a454-74535993bda4"
subnets:
- type: name
name: "prism-subnet"
---
apiVersion: anywhere.eks.amazonaws.com/v1alpha1
kind: NutanixMachineConfig
metadata:
name: eksa-unit-test
namespace: default
spec:
vcpusPerSocket: 1
vcpuSockets: 4
memorySize: 8Gi
image:
type: "name"
name: "prism-image"
cluster:
type: "name"
name: "prism-cluster"
subnet:
type: "name"
name: "prism-subnet"
systemDiskSize: 40Gi
osFamily: "ubuntu"
users:
- name: "mySshUsername"
sshAuthorizedKeys:
- "mySshAuthorizedKey"
---
apiVersion: anywhere.eks.amazonaws.com/v1alpha1
kind: NutanixMachineConfig
metadata:
name: eksa-unit-test-1
namespace: default
spec:
vcpusPerSocket: 1
vcpuSockets: 4
memorySize: 8Gi
image:
type: "name"
name: "prism-image"
cluster:
type: "name"
name: "prism-cluster"
subnet:
type: "name"
name: "prism-subnet"
systemDiskSize: 40Gi
osFamily: "ubuntu"
users:
- name: "mySshUsername"
sshAuthorizedKeys:
- "mySshAuthorizedKey"
---
apiVersion: anywhere.eks.amazonaws.com/v1alpha1
kind: NutanixMachineConfig
metadata:
name: eksa-unit-test-2
namespace: default
spec:
vcpusPerSocket: 1
vcpuSockets: 2
memorySize: 16Gi
image:
type: "name"
name: "prism-image"
cluster:
type: "name"
name: "prism-cluster"
subnet:
type: "name"
name: "prism-subnet"
systemDiskSize: 40Gi
osFamily: "ubuntu"
users:
- name: "mySshUsername"
sshAuthorizedKeys:
- "mySshAuthorizedKey"
---
apiVersion: anywhere.eks.amazonaws.com/v1alpha1
kind: NutanixMachineConfig
metadata:
name: eksa-unit-test-3
namespace: default
spec:
vcpusPerSocket: 2
vcpuSockets: 4
memorySize: 4Gi
image:
type: "name"
name: "prism-image"
cluster:
type: "name"
name: "prism-cluster"
subnet:
type: "name"
name: "prism-subnet"
systemDiskSize: 40Gi
osFamily: "ubuntu"
users:
- name: "mySshUsername"
sshAuthorizedKeys:
- "mySshAuthorizedKey"
---
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
Expand Down
Loading

0 comments on commit 2a8bf41

Please sign in to comment.