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

[WIP] MGMT-19741: Add Nutanix support #2550

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apis/hive/v1/clusterdeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1

import (
configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/hive/apis/hive/v1/nutanix"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -663,6 +664,9 @@ type Platform struct {
// IBMCloud is the configuration used when installing on IBM Cloud
IBMCloud *ibmcloud.Platform `json:"ibmcloud,omitempty"`

// Nutanix is the configuration used when installing on Nutanix prism central.
Nutanix *nutanix.Platform `json:"nutanix,omitempty"`

// None indicates platform-agnostic install.
// https://docs.openshift.com/container-platform/4.7/installing/installing_platform_agnostic/installing-platform-agnostic.html
None *none.Platform `json:"none,omitempty"`
Expand Down
14 changes: 14 additions & 0 deletions apis/hive/v1/clusterdeprovision_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1
import (
"github.com/openshift/hive/apis/hive/v1/aws"
"github.com/openshift/hive/apis/hive/v1/azure"
nutanix "github.com/openshift/hive/apis/hive/v1/nutanix"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -50,6 +51,8 @@ type ClusterDeprovisionPlatform struct {
OpenStack *OpenStackClusterDeprovision `json:"openstack,omitempty"`
// VSphere contains VMWare vSphere-specific deprovision settings
VSphere *VSphereClusterDeprovision `json:"vsphere,omitempty"`
// Nutanix contains Nutanix-specific deprovision settings
Nutanix *NutanixClusterDeprovision `json:"nutanix,omitempty"`
// Ovirt contains oVirt-specific deprovision settings
Ovirt *OvirtClusterDeprovision `json:"ovirt,omitempty"`
// IBMCloud contains IBM Cloud specific deprovision settings
Expand Down Expand Up @@ -131,6 +134,17 @@ type VSphereClusterDeprovision struct {
VCenter string `json:"vCenter"`
}

// NutanixClusterDeprovision contains Nutanix-specific configuration for a ClusterDeprovision
type NutanixClusterDeprovision struct {
// CredentialsSecretRef is the Nutanix Prism Central account credentials to use for deprovisioning the cluster
CredentialsSecretRef corev1.LocalObjectReference `json:"credentialsSecretRef"`
// CertificatesSecretRef refers to a secret that contains the vSphere CA certificates
// necessary for communicating with the VCenter.
CertificatesSecretRef corev1.LocalObjectReference `json:"certificatesSecretRef"`
// VCenter is the vSphere vCenter hostname.
PrismCentral nutanix.PrismCentral `json:"prismCentral,omitempty"`
}

// OvirtClusterDeprovision contains oVirt-specific configuration for a ClusterDeprovision
type OvirtClusterDeprovision struct {
// The oVirt cluster ID
Expand Down
3 changes: 3 additions & 0 deletions apis/hive/v1/machinepool_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1

import (
"github.com/openshift/hive/apis/hive/v1/nutanix"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -98,6 +99,8 @@ type MachinePoolPlatform struct {
Ovirt *ovirt.MachinePool `json:"ovirt,omitempty"`
// IBMCloud is the configuration used when installing on IBM Cloud.
IBMCloud *ibmcloud.MachinePool `json:"ibmcloud,omitempty"`
// Nutanix is the configuration used when installing on Nutanix prism central.
Nutanix *nutanix.MachinePool `json:"nutanix,omitempty"`
}

// MachinePoolStatus defines the observed state of MachinePool
Expand Down
3 changes: 3 additions & 0 deletions apis/hive/v1/nutanix/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package nutanix contains API Schema definitions for Nutanix clusters.
// +k8s:deepcopy-gen=package
package nutanix
90 changes: 90 additions & 0 deletions apis/hive/v1/nutanix/machinepools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package nutanix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest adding a nutanix SME to help review this and the CD Platform file, as I don't have the context to know whether these fields are correct and necessary/sufficient.

Also wouldn't be a terrible idea to get an API reviewer's eyes on this. I'm not an expert, but I think it may be best practice to include a +optional/+required tag even when it's the default; and it may be appropriate for some of the fields to be pointers rather than scalars if "unspecified" has different semantics than the nil value.


import (
machinev1 "github.com/openshift/api/machine/v1"
)

// MachinePool stores the configuration for a machine pool installed
// on Nutanix.
type MachinePool struct {
// NumCPUs is the total number of virtual processor cores to assign a vm.
//
// +optional
NumCPUs int64 `json:"cpus,omitempty"`

// NumCoresPerSocket is the number of cores per socket in a vm. The number
// of vCPUs on the vm will be NumCPUs times NumCoresPerSocket.
// For example: 4 CPUs and 4 Cores per socket will result in 16 VPUs.
// The AHV scheduler treats socket and core allocation exactly the same
// so there is no benefit to configuring cores over CPUs.
//
// +optional
NumCoresPerSocket int64 `json:"coresPerSocket,omitempty"`

// Memory is the size of a VM's memory in MiB.
//
// +optional
MemoryMiB int64 `json:"memoryMiB,omitempty"`

// OSDisk defines the storage for instance.
//
// +optional
OSDisk `json:"osDisk,omitempty"`

// BootType indicates the boot type (Legacy, UEFI or SecureBoot) the Machine's VM uses to boot.
// If this field is empty or omitted, the VM will use the default boot type "Legacy" to boot.
// "SecureBoot" depends on "UEFI" boot, i.e., enabling "SecureBoot" means that "UEFI" boot is also enabled.
// +kubebuilder:validation:Enum="";Legacy;UEFI;SecureBoot
// +optional
BootType machinev1.NutanixBootType `json:"bootType,omitempty"`

// Project optionally identifies a Prism project for the Machine's VM to associate with.
// +optional
Project *machinev1.NutanixResourceIdentifier `json:"project,omitempty"`

// Categories optionally adds one or more prism categories (each with key and value) for
// the Machine's VM to associate with. All the category key and value pairs specified must
// already exist in the prism central.
// +listType=map
// +listMapKey=key
// +optional
Categories []machinev1.NutanixCategory `json:"categories,omitempty"`

// GPUs is a list of GPU devices to attach to the machine's VM.
// +kubebuilder:validation:X-KubernetesListType=set
// +kubebuilder:validation:X-KubernetesMapType=atomic
// +optional
GPUs []machinev1.NutanixGPU `json:"gpus,omitempty"`

// DataDisks holds information of the data disks to attach to the Machine's VM
// +kubebuilder:validation:X-KubernetesListType=set
// +optional
DataDisks []machinev1.NutanixVMDisk `json:"dataDisks,omitempty"`

// FailureDomains optionally configures a list of failure domain names
// that will be applied to the MachinePool
// +listType=set
// +optional
FailureDomains []string `json:"failureDomains,omitempty"`
}

// OSDisk defines the system disk for a Machine VM.
type OSDisk struct {
// DiskSizeGiB defines the size of disk in GiB.
//
// +optional
DiskSizeGiB int64 `json:"diskSizeGiB,omitempty"`
}

// StorageConfig specifies the storage configuration parameters for VM disks.
type StorageConfig struct {
// diskMode specifies the disk mode.
// The valid values are Standard and Flash, and the default is Standard.
// +kubebuilder:default=Standard
// +kubebuilder:validation:Enum=Standard;Flash
DiskMode machinev1.NutanixDiskMode `json:"diskMode"`

// storageContainer refers to the storage_container used by the VM disk.
// +optional
StorageContainer *StorageResourceReference `json:"storageContainer,omitempty"`
}
130 changes: 130 additions & 0 deletions apis/hive/v1/nutanix/platform.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package nutanix

import (
configv1 "github.com/openshift/api/config/v1"
corev1 "k8s.io/api/core/v1"
)

// CredentialsSecretName is the default nutanix credentials secret name.
//
//nolint:gosec
const CredentialsSecretName = "nutanix-credentials"

// Platform stores any global configuration used for Nutanix platforms.
type Platform struct {
// PrismCentral is the endpoint (address and port) and credentials to connect to the Prism Central.
// This serves as the default Prism-Central.
PrismCentral PrismCentral `json:"prismCentral"`

// PrismElements holds a list of Prism Elements (clusters). A Prism Element encompasses all Nutanix resources (VMs, subnets, etc.)
// used to host the OpenShift cluster. Currently only a single Prism Element may be defined.
// This serves as the default Prism-Element.
PrismElements []PrismElement `json:"prismElements"`

// CredentialsSecretRef refers to a secret that contains the Nutanix account access
// credentials.
CredentialsSecretRef corev1.LocalObjectReference `json:"credentialsSecretRef"`

// CertificatesSecretRef refers to a secret that contains the Prism Central CA certificates
// necessary for communicating with the Prism Central.
CertificatesSecretRef corev1.LocalObjectReference `json:"certificatesSecretRef"`

// ClusterOSImage overrides the url provided in rhcos.json to download the RHCOS Image.
//
// +optional
ClusterOSImage string `json:"clusterOSImage,omitempty"`

// DefaultMachinePlatform is the default configuration used when
// installing on Nutanix for machine pools which do not define their own
// platform configuration.
// +optional
DefaultMachinePlatform *MachinePool `json:"defaultMachinePlatform,omitempty"`

// SubnetUUIDs identifies the network subnets to be used by the cluster.
// Currently, we only support one subnet for an OpenShift cluster.
SubnetUUIDs []string `json:"subnetUUIDs"`

// LoadBalancer defines how the load balancer used by the cluster is configured.
// LoadBalancer is available in TechPreview.
// +optional
LoadBalancer *configv1.NutanixPlatformLoadBalancer `json:"loadBalancer,omitempty"`

// FailureDomains configures failure domains for the Nutanix platform.
// +optional
FailureDomains []FailureDomain `json:"failureDomains,omitempty"`
}

// PrismCentral holds the endpoint and credentials data used to connect to the Prism Central
type PrismCentral struct {
// Endpoint holds the address and port of the Prism Central
Endpoint PrismEndpoint `json:"endpoint"`
}

// PrismElement holds the uuid, endpoint of the Prism Element (cluster)
type PrismElement struct {
// UUID is the UUID of the Prism Element (cluster)
UUID string `json:"uuid"`

// Endpoint holds the address and port of the Prism Element
// +optional
Endpoint PrismEndpoint `json:"endpoint,omitempty"`

// Name is prism endpoint Name
Name string `json:"name,omitempty"`
}

// PrismEndpoint holds the endpoint address and port to access the Nutanix Prism Central or Element (cluster)
type PrismEndpoint struct {
// address is the endpoint address (DNS name or IP address) of the Nutanix Prism Central or Element (cluster)
Address string `json:"address"`

// port is the port number to access the Nutanix Prism Central or Element (cluster)
Port int32 `json:"port"`
}

// FailureDomain configures failure domain information for the Nutanix platform.
type FailureDomain struct {
// Name defines the unique name of a failure domain.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=64
// +kubebuilder:validation:Pattern=`^[0-9A-Za-z_.-@/]+$`
Name string `json:"name"`

// prismElement holds the identification (name, uuid) and the optional endpoint address and port of the Nutanix Prism Element.
// When a cluster-wide proxy is installed, by default, this endpoint will be accessed via the proxy.
// Should you wish for communication with this endpoint not to be proxied, please add the endpoint to the
// proxy spec.noProxy list.
// +kubebuilder:validation:Required
PrismElement PrismElement `json:"prismElement"`

// SubnetUUIDs identifies the network subnets of the Prism Element.
// Currently we only support one subnet for a failure domain.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
// +listType=set
SubnetUUIDs []string `json:"subnetUUIDs"`

// StorageContainers identifies the storage containers in the Prism Element.
// +optional
StorageContainers []StorageResourceReference `json:"storageContainers,omitempty"`

// DataSourceImages identifies the datasource images in the Prism Element.
// +optional
DataSourceImages []StorageResourceReference `json:"dataSourceImages,omitempty"`
}

// StorageResourceReference holds reference information of a storage resource (storage container, data source image, etc.)
type StorageResourceReference struct {
// ReferenceName is the identifier of the storage resource configured in the FailureDomain.
// +optional
ReferenceName string `json:"referenceName,omitempty"`

// UUID is the UUID of the storage container resource in the Prism Element.
// +kubebuilder:validation:Required
UUID string `json:"uuid"`

// Name is the name of the storage container resource in the Prism Element.
// +optional
Name string `json:"name,omitempty"`
}
Loading