Skip to content

Commit c640904

Browse files
deepakm-ntnxjimmidyson
authored andcommitted
now added subnet settings in cre
1 parent 82e8bac commit c640904

File tree

9 files changed

+49
-12
lines changed

9 files changed

+49
-12
lines changed

api/v1alpha1/nutanix_clusterconfig_types.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ func (NutanixSpec) VariableSchema() clusterv1.VariableSchema {
2828
}
2929

3030
type NutanixPrismCentralEndpointSpec struct {
31-
Host string `json:"host,omitempty"`
32-
Port int32 `json:"port,omitempty"`
33-
Insecure bool `json:"insecure,omitempty"`
31+
Host string `json:"host"`
32+
Port int32 `json:"port"`
33+
Insecure bool `json:"insecure"`
3434
AdditionalTrustBundle string `json:"additionalTrustBundle,omitempty"`
35+
CredentialSecret string `json:"credentialSecret"`
3536
}
3637

3738
func (NutanixPrismCentralEndpointSpec) VariableSchema() clusterv1.VariableSchema {
@@ -53,7 +54,11 @@ func (NutanixPrismCentralEndpointSpec) VariableSchema() clusterv1.VariableSchema
5354
Type: "boolean",
5455
},
5556
"additionalTrustBundle": {
56-
Description: "Certificate trust bundle used for Prism Central connection",
57+
Description: "Name of configMap with certificate trust bundle used for Prism Central connection",
58+
Type: "string",
59+
},
60+
"credentialSecret": {
61+
Description: "Name of a Credential information secret for the target Prism instance",
5762
Type: "string",
5863
},
5964
},

examples/capi-quick-start/nutanix-cluster-calico-crs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ spec:
335335
host: ${CONTROL_PLANE_ENDPOINT_IP}
336336
port: ${CONTROL_PLANE_ENDPOINT_PORT}
337337
prismCentralEndpoint:
338-
additionalTrustBundle: trust-bundle-root-ca
338+
additionalTrustBundle: ${CLUSTER_NAME}-pc-trusted-ca-bundle
339339
credentialSecret: ${CLUSTER_NAME}-pc-creds
340340
host: ${NUTANIX_ENDPOINT}
341341
insecure: ${NUTANIX_INSECURE}

examples/capi-quick-start/nutanix-cluster-calico-helm-addon.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ spec:
335335
host: ${CONTROL_PLANE_ENDPOINT_IP}
336336
port: ${CONTROL_PLANE_ENDPOINT_PORT}
337337
prismCentralEndpoint:
338-
additionalTrustBundle: trust-bundle-root-ca
338+
additionalTrustBundle: ${CLUSTER_NAME}-pc-trusted-ca-bundle
339339
credentialSecret: ${CLUSTER_NAME}-pc-creds
340340
host: ${NUTANIX_ENDPOINT}
341341
insecure: ${NUTANIX_INSECURE}

examples/capi-quick-start/nutanix-cluster-cilium-crs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ spec:
335335
host: ${CONTROL_PLANE_ENDPOINT_IP}
336336
port: ${CONTROL_PLANE_ENDPOINT_PORT}
337337
prismCentralEndpoint:
338-
additionalTrustBundle: trust-bundle-root-ca
338+
additionalTrustBundle: ${CLUSTER_NAME}-pc-trusted-ca-bundle
339339
credentialSecret: ${CLUSTER_NAME}-pc-creds
340340
host: ${NUTANIX_ENDPOINT}
341341
insecure: ${NUTANIX_INSECURE}

examples/capi-quick-start/nutanix-cluster-cilium-helm-addon.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ spec:
335335
host: ${CONTROL_PLANE_ENDPOINT_IP}
336336
port: ${CONTROL_PLANE_ENDPOINT_PORT}
337337
prismCentralEndpoint:
338-
additionalTrustBundle: trust-bundle-root-ca
338+
additionalTrustBundle: ${CLUSTER_NAME}-pc-trusted-ca-bundle
339339
credentialSecret: ${CLUSTER_NAME}-pc-creds
340340
host: ${NUTANIX_ENDPOINT}
341341
insecure: ${NUTANIX_INSECURE}

hack/examples/base/nutanix/cluster-topology/kustomization.yaml.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ patches:
5959
host: $${CONTROL_PLANE_ENDPOINT_IP}
6060
port: $${CONTROL_PLANE_ENDPOINT_PORT}
6161
prismCentralEndpoint:
62-
additionalTrustBundle: trust-bundle-root-ca
62+
additionalTrustBundle: $${CLUSTER_NAME}-pc-trusted-ca-bundle
6363
host: $${NUTANIX_ENDPOINT}
6464
insecure: $${NUTANIX_INSECURE}
6565
port: 9440

pkg/handlers/nutanix/mutation/machinedetails/inject_control_plane.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,20 @@ func (h *nutanixMachineDetailsControlPlanePatchHandler) Mutate(
127127
obj.Spec.Template.Spec.SystemDiskSize = resource.MustParse(
128128
nutanixMachineDetailsVar.SystemDiskSize,
129129
)
130+
131+
subnets := make([]capxv1.NutanixResourceIdentifier, len(nutanixMachineDetailsVar.Subnets))
132+
for _, subnetCRE := range nutanixMachineDetailsVar.Subnets {
133+
subnet := capxv1.NutanixResourceIdentifier{Type: capxv1.NutanixIdentifierType(subnetCRE.Type)}
134+
if subnetCRE.Type == v1alpha1.NutanixIdentifierName {
135+
subnet.Name = subnetCRE.Name
136+
} else {
137+
subnet.UUID = subnetCRE.UUID
138+
}
139+
subnets = append(subnets, subnet)
140+
}
141+
142+
obj.Spec.Template.Spec.Subnets = subnets
130143
// TODO
131-
// obj.Spec.Template.Spec.Subnets = nutanixMachineDetailsVar.Subnets
132144
// obj.Spec.Template.Spec.Project = nutanixMachineDetailsVar.Project
133145
// obj.Spec.Template.Spec.AdditionalCategories = nutanixMachineDetailsVar.AdditionalCategories
134146
// obj.Spec.Template.Spec.GPUs = nutanixMachineDetailsVar.GPUs

pkg/handlers/nutanix/mutation/machinedetails/inject_worker.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,20 @@ func (h *nutanixMachineDetailsWorkerPatchHandler) Mutate(
121121
obj.Spec.Template.Spec.SystemDiskSize = resource.MustParse(
122122
nutanixMachineDetailsVar.SystemDiskSize,
123123
)
124+
125+
subnets := make([]capxv1.NutanixResourceIdentifier, len(nutanixMachineDetailsVar.Subnets))
126+
for _, subnetCRE := range nutanixMachineDetailsVar.Subnets {
127+
subnet := capxv1.NutanixResourceIdentifier{Type: capxv1.NutanixIdentifierType(subnetCRE.Type)}
128+
if subnetCRE.Type == v1alpha1.NutanixIdentifierName {
129+
subnet.Name = subnetCRE.Name
130+
} else {
131+
subnet.UUID = subnetCRE.UUID
132+
}
133+
subnets = append(subnets, subnet)
134+
}
135+
136+
obj.Spec.Template.Spec.Subnets = subnets
124137
// TODO
125-
// obj.Spec.Template.Spec.Subnets = nutanixMachineDetailsVar.Subnets
126138
// obj.Spec.Template.Spec.Project = nutanixMachineDetailsVar.Project
127139
// obj.Spec.Template.Spec.AdditionalCategories = nutanixMachineDetailsVar.AdditionalCategories
128140
// obj.Spec.Template.Spec.GPUs = nutanixMachineDetailsVar.GPUs

pkg/handlers/nutanix/mutation/prismcentralendpoint/inject.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/d2iq-labs/capi-runtime-extensions/common/pkg/capi/clustertopology/patches/selectors"
1919
"github.com/d2iq-labs/capi-runtime-extensions/common/pkg/capi/clustertopology/variables"
2020
"github.com/d2iq-labs/capi-runtime-extensions/pkg/handlers/generic/clusterconfig"
21+
"github.com/nutanix-cloud-native/prism-go-client/environment/credentials"
2122
)
2223

2324
const (
@@ -96,7 +97,14 @@ func (h *nutanixPrismCentralEndpoint) Mutate(
9697
obj.Spec.Template.Spec.PrismCentral.Address = prismCentralEndpointVar.Host
9798
obj.Spec.Template.Spec.PrismCentral.Port = prismCentralEndpointVar.Port
9899
obj.Spec.Template.Spec.PrismCentral.Insecure = prismCentralEndpointVar.Insecure
99-
// TODO obj.Spec.Template.Spec.PrismCentral.AdditionalTrustBundle = prismCentralEndpointVar.AdditionalTrustBundle
100+
obj.Spec.Template.Spec.PrismCentral.AdditionalTrustBundle = &credentials.NutanixTrustBundleReference{
101+
Kind: credentials.NutanixTrustBundleKindConfigMap,
102+
Name: prismCentralEndpointVar.AdditionalTrustBundle,
103+
}
104+
obj.Spec.Template.Spec.PrismCentral.CredentialRef = &credentials.NutanixCredentialReference{
105+
Kind: credentials.SecretKind,
106+
Name: prismCentralEndpointVar.CredentialSecret,
107+
}
100108

101109
return nil
102110
},

0 commit comments

Comments
 (0)