From b146798affdab1629dccb28b3bccbd72ff7b189a Mon Sep 17 00:00:00 2001 From: Sid Shukla Date: Fri, 14 Jan 2022 19:41:54 +0530 Subject: [PATCH] Add Nutanix-specific customizations to manifests - Update templates in data/data/manifests - Add nutanix platform customizations in pkg/asset/manifests --- .../openshift/cloud-creds-secret.yaml.template | 7 +++++++ .../role-cloud-creds-secret-reader.yaml.template | 4 ++++ pkg/asset/manifests/cloudproviderconfig.go | 3 ++- pkg/asset/manifests/dns.go | 3 ++- pkg/asset/manifests/infrastructure.go | 9 +++++++++ pkg/asset/manifests/openshift.go | 12 +++++++++++- pkg/asset/manifests/template.go | 9 +++++++++ 7 files changed, 44 insertions(+), 3 deletions(-) diff --git a/data/data/manifests/openshift/cloud-creds-secret.yaml.template b/data/data/manifests/openshift/cloud-creds-secret.yaml.template index 20b0908468b..0a1f10dd29c 100644 --- a/data/data/manifests/openshift/cloud-creds-secret.yaml.template +++ b/data/data/manifests/openshift/cloud-creds-secret.yaml.template @@ -16,6 +16,8 @@ metadata: name: vsphere-creds {{- else if .CloudCreds.Ovirt}} name: ovirt-credentials +{{- else if .CloudCreds.Nutanix}} + name: nutanix-credentials {{- end}} data: {{- if .CloudCreds.AWS}} @@ -45,4 +47,9 @@ data: ovirt_password: {{.CloudCreds.Ovirt.Base64encodePassword}} ovirt_insecure: {{.CloudCreds.Ovirt.Base64encodeInsecure}} ovirt_ca_bundle: {{.CloudCreds.Ovirt.Base64encodeCABundle}} +{{- else if .CloudCreds.Nutanix}} + NUTANIX_ENDPOINT: {{.CloudCreds.Nutanix.Base64encodeEndpoint}} + NUTANIX_PORT: {{.CloudCreds.Nutanix.Base64encodePort}} + NUTANIX_USER: {{.CloudCreds.Nutanix.Base64encodeUsername}} + NUTANIX_PASSWORD: {{.CloudCreds.Nutanix.Base64encodePassword}} {{- end}} diff --git a/data/data/manifests/openshift/role-cloud-creds-secret-reader.yaml.template b/data/data/manifests/openshift/role-cloud-creds-secret-reader.yaml.template index 29537a33be8..58440cd6a16 100644 --- a/data/data/manifests/openshift/role-cloud-creds-secret-reader.yaml.template +++ b/data/data/manifests/openshift/role-cloud-creds-secret-reader.yaml.template @@ -16,6 +16,8 @@ metadata: name: vsphere-creds-secret-reader {{- else if .CloudCreds.Ovirt}} name: ovirt-creds-secret-reader +{{- else if .CloudCreds.Nutanix}} + name: nutanix-creds-secret-reader {{- end}} rules: - apiGroups: [""] @@ -34,5 +36,7 @@ rules: resourceNames: ["vsphere-creds"] {{- else if .CloudCreds.Ovirt}} resourceNames: ["ovirt-credentials"] +{{- else if .CloudCreds.Nutanix}} + resourceNames: ["nutanix-credentials"] {{- end}} verbs: ["get"] diff --git a/pkg/asset/manifests/cloudproviderconfig.go b/pkg/asset/manifests/cloudproviderconfig.go index bd57f5a4596..f91f4d7def6 100644 --- a/pkg/asset/manifests/cloudproviderconfig.go +++ b/pkg/asset/manifests/cloudproviderconfig.go @@ -30,6 +30,7 @@ import ( ibmcloudtypes "github.com/openshift/installer/pkg/types/ibmcloud" libvirttypes "github.com/openshift/installer/pkg/types/libvirt" nonetypes "github.com/openshift/installer/pkg/types/none" + nutanixtypes "github.com/openshift/installer/pkg/types/nutanix" openstacktypes "github.com/openshift/installer/pkg/types/openstack" ovirttypes "github.com/openshift/installer/pkg/types/ovirt" powervstypes "github.com/openshift/installer/pkg/types/powervs" @@ -92,7 +93,7 @@ func (cpc *CloudProviderConfig) Generate(dependencies asset.Parents) error { } switch installConfig.Config.Platform.Name() { - case libvirttypes.Name, nonetypes.Name, baremetaltypes.Name, ovirttypes.Name: + case libvirttypes.Name, nonetypes.Name, baremetaltypes.Name, ovirttypes.Name, nutanixtypes.Name: return nil case awstypes.Name: // Store the additional trust bundle in the ca-bundle.pem key if the cluster is being installed on a C2S region. diff --git a/pkg/asset/manifests/dns.go b/pkg/asset/manifests/dns.go index c25efd2e5a7..696818319b8 100644 --- a/pkg/asset/manifests/dns.go +++ b/pkg/asset/manifests/dns.go @@ -26,6 +26,7 @@ import ( ibmcloudtypes "github.com/openshift/installer/pkg/types/ibmcloud" libvirttypes "github.com/openshift/installer/pkg/types/libvirt" nonetypes "github.com/openshift/installer/pkg/types/none" + nutanixtypes "github.com/openshift/installer/pkg/types/nutanix" openstacktypes "github.com/openshift/installer/pkg/types/openstack" ovirttypes "github.com/openshift/installer/pkg/types/ovirt" powervstypes "github.com/openshift/installer/pkg/types/powervs" @@ -159,7 +160,7 @@ func (d *DNS) Generate(dependencies asset.Parents) error { config.Spec.PrivateZone = &configv1.DNSZone{ ID: zoneID, } - case libvirttypes.Name, openstacktypes.Name, baremetaltypes.Name, nonetypes.Name, vspheretypes.Name, ovirttypes.Name: + case libvirttypes.Name, openstacktypes.Name, baremetaltypes.Name, nonetypes.Name, vspheretypes.Name, ovirttypes.Name, nutanixtypes.Name: default: return errors.New("invalid Platform") } diff --git a/pkg/asset/manifests/infrastructure.go b/pkg/asset/manifests/infrastructure.go index 29038b55a4e..7ef22a9638b 100644 --- a/pkg/asset/manifests/infrastructure.go +++ b/pkg/asset/manifests/infrastructure.go @@ -21,6 +21,7 @@ import ( "github.com/openshift/installer/pkg/types/ibmcloud" "github.com/openshift/installer/pkg/types/libvirt" "github.com/openshift/installer/pkg/types/none" + "github.com/openshift/installer/pkg/types/nutanix" "github.com/openshift/installer/pkg/types/openstack" "github.com/openshift/installer/pkg/types/ovirt" "github.com/openshift/installer/pkg/types/powervs" @@ -224,6 +225,14 @@ func (i *Infrastructure) Generate(dependencies asset.Parents) error { Zone: installConfig.Config.Platform.PowerVS.Zone, CISInstanceCRN: cisInstanceCRN, } + case nutanix.Name: + config.Spec.PlatformSpec.Type = configv1.NutanixPlatformType + if installConfig.Config.Nutanix.APIVIP != "" { + config.Status.PlatformStatus.Nutanix = &configv1.NutanixPlatformStatus{ + APIServerInternalIP: installConfig.Config.Nutanix.APIVIP, + IngressIP: installConfig.Config.Nutanix.IngressVIP, + } + } default: config.Spec.PlatformSpec.Type = configv1.NonePlatformType } diff --git a/pkg/asset/manifests/openshift.go b/pkg/asset/manifests/openshift.go index 0bfb3b107e5..0591703df4e 100644 --- a/pkg/asset/manifests/openshift.go +++ b/pkg/asset/manifests/openshift.go @@ -31,6 +31,7 @@ import ( baremetaltypes "github.com/openshift/installer/pkg/types/baremetal" gcptypes "github.com/openshift/installer/pkg/types/gcp" ibmcloudtypes "github.com/openshift/installer/pkg/types/ibmcloud" + nutanixtypes "github.com/openshift/installer/pkg/types/nutanix" openstacktypes "github.com/openshift/installer/pkg/types/openstack" ovirttypes "github.com/openshift/installer/pkg/types/ovirt" vspheretypes "github.com/openshift/installer/pkg/types/vsphere" @@ -211,6 +212,15 @@ func (o *Openshift) Generate(dependencies asset.Parents) error { Base64encodeCABundle: base64.StdEncoding.EncodeToString([]byte(conf.CABundle)), }, } + case nutanixtypes.Name: + cloudCreds = cloudCredsSecretData{ + Nutanix: &NutanixCredsSecretData{ + Base64encodeEndpoint: base64.StdEncoding.EncodeToString([]byte(installConfig.Config.Nutanix.PrismCentral)), + Base64encodePort: base64.StdEncoding.EncodeToString([]byte(installConfig.Config.Nutanix.Port)), + Base64encodeUsername: base64.StdEncoding.EncodeToString([]byte(installConfig.Config.Nutanix.Username)), + Base64encodePassword: base64.StdEncoding.EncodeToString([]byte(installConfig.Config.Nutanix.Password)), + }, + } } templateData := &openshiftTemplateData{ @@ -236,7 +246,7 @@ func (o *Openshift) Generate(dependencies asset.Parents) error { } switch platform { - case awstypes.Name, openstacktypes.Name, vspheretypes.Name, azuretypes.Name, gcptypes.Name, ibmcloudtypes.Name, ovirttypes.Name: + case awstypes.Name, openstacktypes.Name, vspheretypes.Name, azuretypes.Name, gcptypes.Name, ibmcloudtypes.Name, ovirttypes.Name, nutanixtypes.Name: if installConfig.Config.CredentialsMode != types.ManualCredentialsMode { assetData["99_cloud-creds-secret.yaml"] = applyTemplateData(cloudCredsSecret.Files()[0].Data, templateData) } diff --git a/pkg/asset/manifests/template.go b/pkg/asset/manifests/template.go index b817a2a9d3e..bdd9326a444 100644 --- a/pkg/asset/manifests/template.go +++ b/pkg/asset/manifests/template.go @@ -54,6 +54,14 @@ type OvirtCredsSecretData struct { Base64encodeCABundle string } +// NutanixCredsSecretData holds encoded credentials and is used to generate cloud-creds secret +type NutanixCredsSecretData struct { + Base64encodeEndpoint string + Base64encodePort string + Base64encodeUsername string + Base64encodePassword string +} + type cloudCredsSecretData struct { AWS *AwsCredsSecretData Azure *AzureCredsSecretData @@ -62,6 +70,7 @@ type cloudCredsSecretData struct { OpenStack *OpenStackCredsSecretData VSphere *VSphereCredsSecretData Ovirt *OvirtCredsSecretData + Nutanix *NutanixCredsSecretData } type bootkubeTemplateData struct {