Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added template modifications for uuid in machineconfig #4283

Merged
merged 13 commits into from
Dec 6, 2022
Merged
14 changes: 10 additions & 4 deletions cmd/integration_test/build/buildspecs/conformance-eks-a-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,22 @@ env:
T_NUTANIX_PORT: "nutanix_ci:nutanix_port"
T_NUTANIX_MACHINE_BOOT_TYPE: "nutanix_ci:nutanix_machine_boot_type"
T_NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: "nutanix_ci:nutanix_prism_element_cluster_name"
T_NUTANIX_PRISM_ELEMENT_CLUSTER_UUID: "nutanix_ci:nutanix_prism_element_cluster_uuid"
T_NUTANIX_SSH_AUTHORIZED_KEY: "nutanix_ci:nutanix_ssh_authorized_key"
T_NUTANIX_SUBNET_NAME: "nutanix_ci:nutanix_subnet_name"
T_NUTANIX_SUBNET_UUID: "nutanix_ci:nutanix_subnet_uuid"
T_NUTANIX_CONTROL_PLANE_CIDR: "nutanix_ci:nutanix_control_plane_cidr"
T_NUTANIX_POD_CIDR: "nutanix_ci:nutanix_pod_cidr"
T_NUTANIX_SERVICE_CIDR: "nutanix_ci:nutanix_service_cidr"
T_NUTANIX_ADDITIONAL_TRUST_BUNDLE: "nutanix_ci:nutanix_additional_trust_bundle"
T_NUTANIX_TEMPLATE_UBUNTU_1_21: "nutanix_ci:nutanix_template_ubuntu_1_21"
T_NUTANIX_TEMPLATE_UBUNTU_1_22: "nutanix_ci:nutanix_template_ubuntu_1_22"
T_NUTANIX_TEMPLATE_UBUNTU_1_23: "nutanix_ci:nutanix_template_ubuntu_1_23"
T_NUTANIX_TEMPLATE_UBUNTU_1_24: "nutanix_ci:nutanix_template_ubuntu_1_24"
T_NUTANIX_TEMPLATE_NAME_UBUNTU_1_21: "nutanix_ci:nutanix_template_ubuntu_1_21"
T_NUTANIX_TEMPLATE_NAME_UBUNTU_1_22: "nutanix_ci:nutanix_template_ubuntu_1_22"
T_NUTANIX_TEMPLATE_NAME_UBUNTU_1_23: "nutanix_ci:nutanix_template_ubuntu_1_23"
T_NUTANIX_TEMPLATE_NAME_UBUNTU_1_24: "nutanix_ci:nutanix_template_ubuntu_1_24"
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_21: "nutanix_ci:nutanix_template_uuid_ubuntu_1_21"
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_22: "nutanix_ci:nutanix_template_uuid_ubuntu_1_22"
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_23: "nutanix_ci:nutanix_template_uuid_ubuntu_1_23"
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_24: "nutanix_ci:nutanix_template_uuid_ubuntu_1_24"
phases:
pre_build:
commands:
Expand Down
6 changes: 6 additions & 0 deletions cmd/integration_test/build/buildspecs/test-eks-a-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ env:
T_NUTANIX_PORT: "nutanix_ci:nutanix_port"
T_NUTANIX_MACHINE_BOOT_TYPE: "nutanix_ci:nutanix_machine_boot_type"
T_NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: "nutanix_ci:nutanix_prism_element_cluster_name"
T_NUTANIX_PRISM_ELEMENT_CLUSTER_UUID: "nutanix_ci:nutanix_prism_element_cluster_uuid"
T_NUTANIX_SSH_AUTHORIZED_KEY: "nutanix_ci:nutanix_ssh_authorized_key"
T_NUTANIX_SUBNET_NAME: "nutanix_ci:nutanix_subnet_name"
T_NUTANIX_SUBNET_UUID: "nutanix_ci:nutanix_subnet_uuid"
T_NUTANIX_CONTROL_PLANE_CIDR: "nutanix_ci:nutanix_control_plane_cidr"
T_NUTANIX_POD_CIDR: "nutanix_ci:nutanix_pod_cidr"
T_NUTANIX_SERVICE_CIDR: "nutanix_ci:nutanix_service_cidr"
Expand All @@ -131,6 +133,10 @@ env:
T_NUTANIX_TEMPLATE_UBUNTU_1_22: "nutanix_ci:nutanix_template_ubuntu_1_22"
T_NUTANIX_TEMPLATE_UBUNTU_1_23: "nutanix_ci:nutanix_template_ubuntu_1_23"
T_NUTANIX_TEMPLATE_UBUNTU_1_24: "nutanix_ci:nutanix_template_ubuntu_1_24"
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_21: "nutanix_ci:nutanix_template_uuid_ubuntu_1_21"
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_22: "nutanix_ci:nutanix_template_uuid_ubuntu_1_22"
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_23: "nutanix_ci:nutanix_template_uuid_ubuntu_1_23"
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_24: "nutanix_ci:nutanix_template_uuid_ubuntu_1_24"
phases:
pre_build:
commands:
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/v1alpha1/nutanixmachineconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
// NutanixIdentifierType is an enumeration of different resource identifier types.
type NutanixIdentifierType string

func (c NutanixIdentifierType) String() string {
return string(c)
}

const (
// NutanixMachineConfigKind is the kind for a NutanixMachineConfig.
NutanixMachineConfigKind = "NutanixMachineConfig"
Expand Down
15 changes: 15 additions & 0 deletions pkg/providers/nutanix/config/cp-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,26 @@ spec:
memorySize: {{.memorySize}}
systemDiskSize: {{.systemDiskSize}}
image:
{{- if (eq .imageIDType "name") }}
type: name
name: "{{.imageName}}"
{{ else if (eq .imageIDType "uuid") }}
type: uuid
uuid: "{{.imageUUID}}"
{{ end }}
cluster:
{{- if (eq .nutanixPEClusterIDType "name") }}
type: name
name: "{{.nutanixPEClusterName}}"
{{- else if (eq .nutanixPEClusterIDType "uuid") }}
type: uuid
uuid: "{{.nutanixPEClusterUUID}}"
{{ end }}
subnet:
{{- if (eq .subnetIDType "name") }}
- type: name
name: "{{.subnetName}}"
{{- else if (eq .subnetIDType "uuid") }}
- type: uuid
uuid: "{{.subnetUUID}}"
{{ end }}
15 changes: 15 additions & 0 deletions pkg/providers/nutanix/config/md-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,29 @@ spec:
memorySize: {{.memorySize}}
systemDiskSize: {{.systemDiskSize}}
image:
{{- if (eq .imageIDType "name") }}
type: name
name: "{{.imageName}}"
{{ else if (eq .imageIDType "uuid") }}
type: uuid
uuid: "{{.imageUUID}}"
{{ end }}
cluster:
{{- if (eq .nutanixPEClusterIDType "name") }}
type: name
name: "{{.nutanixPEClusterName}}"
{{- else if (eq .nutanixPEClusterIDType "uuid") }}
type: uuid
uuid: "{{.nutanixPEClusterUUID}}"
{{ end }}
subnet:
{{- if (eq .subnetIDType "name") }}
- type: name
name: "{{.subnetName}}"
{{- else if (eq .subnetIDType "uuid") }}
- type: uuid
uuid: "{{.subnetUUID}}"
{{ end }}
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
Expand Down
24 changes: 18 additions & 6 deletions pkg/providers/nutanix/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,15 @@ func buildTemplateMapCP(
"vcpuSockets": controlPlaneMachineSpec.VCPUSockets,
"memorySize": controlPlaneMachineSpec.MemorySize.String(),
"systemDiskSize": controlPlaneMachineSpec.SystemDiskSize.String(),
"imageName": controlPlaneMachineSpec.Image.Name, // TODO(nutanix): pass name or uuid based on type of identifier
"nutanixPEClusterName": controlPlaneMachineSpec.Cluster.Name, // TODO(nutanix): pass name or uuid based on type of identifier
"subnetName": controlPlaneMachineSpec.Subnet.Name, // TODO(nutanix): pass name or uuid based on type of identifier
"imageIDType": controlPlaneMachineSpec.Image.Type,
"imageName": controlPlaneMachineSpec.Image.Name,
"imageUUID": controlPlaneMachineSpec.Image.UUID,
"nutanixPEClusterIDType": controlPlaneMachineSpec.Cluster.Type,
"nutanixPEClusterName": controlPlaneMachineSpec.Cluster.Name,
"nutanixPEClusterUUID": controlPlaneMachineSpec.Cluster.UUID,
"subnetIDType": controlPlaneMachineSpec.Subnet.Type,
"subnetName": controlPlaneMachineSpec.Subnet.Name,
"subnetUUID": controlPlaneMachineSpec.Subnet.UUID,
}

if clusterSpec.Cluster.Spec.ExternalEtcdConfiguration != nil {
Expand Down Expand Up @@ -185,9 +191,15 @@ func buildTemplateMapMD(clusterSpec *cluster.Spec, workerNodeGroupMachineSpec v1
"vcpuSockets": workerNodeGroupMachineSpec.VCPUSockets,
"memorySize": workerNodeGroupMachineSpec.MemorySize.String(),
"systemDiskSize": workerNodeGroupMachineSpec.SystemDiskSize.String(),
"imageName": workerNodeGroupMachineSpec.Image.Name, // TODO(nutanix): pass name or uuid based on type of identifier
"nutanixPEClusterName": workerNodeGroupMachineSpec.Cluster.Name, // TODO(nutanix): pass name or uuid based on type of identifier
"subnetName": workerNodeGroupMachineSpec.Subnet.Name, // TODO(nutanix): pass name or uuid based on type of identifier
"imageIDType": workerNodeGroupMachineSpec.Image.Type,
"imageName": workerNodeGroupMachineSpec.Image.Name,
"imageUUID": workerNodeGroupMachineSpec.Image.UUID,
"nutanixPEClusterIDType": workerNodeGroupMachineSpec.Cluster.Type,
"nutanixPEClusterName": workerNodeGroupMachineSpec.Cluster.Name,
"nutanixPEClusterUUID": workerNodeGroupMachineSpec.Cluster.UUID,
"subnetIDType": workerNodeGroupMachineSpec.Subnet.Type,
"subnetName": workerNodeGroupMachineSpec.Subnet.Name,
"subnetUUID": workerNodeGroupMachineSpec.Subnet.UUID,
"workerNodeGroupName": fmt.Sprintf("%s-%s", clusterSpec.Cluster.Name, workerNodeGroupConfiguration.Name),
}
return values
Expand Down
17 changes: 12 additions & 5 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,22 @@ The format is: `T_VSPHERE_TEMPLATE_{OS}_{EKS-D VERSION}`. For example, for Ubunt
T_NUTANIX_MACHINE_VCPU_PER_SOCKET
T_NUTANIX_MACHINE_VCPU_SOCKET
T_NUTANIX_PRISM_ELEMENT_CLUSTER_NAME
T_NUTANIX_SSH_AUTHORIZED_KEY
T_NUTANIX_PRISM_ELEMENT_CLUSTER_UUID
T_NUTANIX_SUBNET_NAME
T_NUTANIX_SUBNET_UUID
T_NUTANIX_SSH_AUTHORIZED_KEY
T_NUTANIX_CONTROL_PLANE_ENDPOINT_IP
T_NUTANIX_POD_CIDR
T_NUTANIX_SERVICE_CIDR
T_NUTANIX_TEMPLATE_UBUNTU_1_21
T_NUTANIX_TEMPLATE_UBUNTU_1_22
T_NUTANIX_TEMPLATE_UBUNTU_1_23
T_NUTANIX_TEMPLATE_UBUNTU_1_24
T_NUTANIX_TEMPLATE_NAME_UBUNTU_1_21
T_NUTANIX_TEMPLATE_NAME_UBUNTU_1_22
T_NUTANIX_TEMPLATE_NAME_UBUNTU_1_23
T_NUTANIX_TEMPLATE_NAME_UBUNTU_1_24
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_21
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_22
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_23
T_NUTANIX_TEMPLATE_UUID_UBUNTU_1_24

```
## Tinkerbell tests requisites
The following env variables need to be set:
Expand Down
44 changes: 44 additions & 0 deletions test/e2e/simpleflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,3 +549,47 @@ func TestNutanixKubernetes124SimpleFlow(t *testing.T) {
)
runSimpleFlow(test)
}

func TestNutanixKubernetes121SimpleFlowUUID(t *testing.T) {
test := framework.NewClusterE2ETest(
t,
framework.NewNutanix(t, framework.WithUbuntu121NutanixUUID(),
framework.WithPrismElementClusterUUID(),
framework.WithSubnetUUID()),
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube121)),
)
runSimpleFlow(test)
}

func TestNutanixKubernetes122SimpleFlowUUID(t *testing.T) {
test := framework.NewClusterE2ETest(
t,
framework.NewNutanix(t, framework.WithUbuntu122NutanixUUID(),
framework.WithPrismElementClusterUUID(),
framework.WithSubnetUUID()),
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube122)),
)
runSimpleFlow(test)
}

func TestNutanixKubernetes123SimpleFlowUUID(t *testing.T) {
test := framework.NewClusterE2ETest(
t,
framework.NewNutanix(t, framework.WithUbuntu123NutanixUUID(),
framework.WithPrismElementClusterUUID(),
framework.WithSubnetUUID()),
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube123)),
)
runSimpleFlow(test)
}

func TestNutanixKubernetes124SimpleFlowUUID(t *testing.T) {
test := framework.NewClusterE2ETest(
t,
framework.NewNutanix(t, framework.WithUbuntu124NutanixUUID(),
framework.WithPrismElementClusterUUID(),
framework.WithSubnetUUID()),
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube124)),
)
runSimpleFlow(test)
}
Loading