diff --git a/data/data/install.openshift.io_installconfigs.yaml b/data/data/install.openshift.io_installconfigs.yaml index 91a45536654..1f696d398a5 100644 --- a/data/data/install.openshift.io_installconfigs.yaml +++ b/data/data/install.openshift.io_installconfigs.yaml @@ -417,6 +417,30 @@ spec: - high_performance type: string type: object + powervs: + description: PowerVS is the configuration used when installing + on IBM Power VS. + properties: + memory: + description: Memory defines the memory in GB for the instance. + type: integer + procType: + description: ProcType defines the processor sharing model + for the instance. + type: string + processors: + description: Processors defines the processing units for + the instance. + sysType: + description: SysType defines the system type for instance. + type: string + volumeIDs: + description: VolumeIDs is the list of volumes attached to + the instance. + items: + type: string + type: array + type: object vsphere: description: VSphere is the configuration used when installing on vSphere. @@ -825,6 +849,30 @@ spec: - high_performance type: string type: object + powervs: + description: PowerVS is the configuration used when installing + on IBM Power VS. + properties: + memory: + description: Memory defines the memory in GB for the instance. + type: integer + procType: + description: ProcType defines the processor sharing model + for the instance. + type: string + processors: + description: Processors defines the processing units for the + instance. + sysType: + description: SysType defines the system type for instance. + type: string + volumeIDs: + description: VolumeIDs is the list of volumes attached to + the instance. + items: + type: string + type: array + type: object vsphere: description: VSphere is the configuration used when installing on vSphere. @@ -1966,6 +2014,87 @@ spec: - ovirt_cluster_id - ovirt_storage_domain_id type: object + powervs: + description: PowerVS is the configuration used when installing on + Power VS. + properties: + APIKey: + description: APIKey is the API key for the user's IBM Cloud account. + type: string + clusterOSImage: + description: ClusterOSImage is a pre-created Power VS boot image + that overrides the default image for cluster nodes. + type: string + defaultMachinePlatform: + description: DefaultMachinePlatform is the default configuration + used when installing on Power VS for machine pools which do + not define their own platform configuration. + properties: + memory: + description: Memory defines the memory in GB for the instance. + type: integer + procType: + description: ProcType defines the processor sharing model + for the instance. + type: string + processors: + description: Processors defines the processing units for the + instance. + sysType: + description: SysType defines the system type for instance. + type: string + volumeIDs: + description: VolumeIDs is the list of volumes attached to + the instance. + items: + type: string + type: array + type: object + powervsResourceGroup: + description: PowerVSResourceGroup is the resource group for creating + Power VS resources. + type: string + pvsNetworkName: + description: PVSNetworkName specifies an existing network within + the Power VS Service Instance. + type: string + region: + description: Region specifies the IBM Cloud region where the cluster + will be created. + type: string + serviceInstance: + description: ServiceInstanceID is the ID of the Power IAAS instance + created from the IBM Cloud Catalog + type: string + subnets: + description: Subnets specifies existing subnets (by ID) where + cluster resources will be created. Leave unset to have the + installer create subnets in a new VPC on your behalf. + items: + type: string + type: array + userID: + description: UserID is the login for the user's IBM Cloud account. + type: string + vpc: + description: VPC is a VPC inside IBM Cloud. Needed in order to + create VPC Load Balancers. + type: string + vpcRegion: + description: Zone in the region used to create VPC resources. + Leave unset to allow installer to randomly select a zone. + type: string + zone: + description: Zone specifies the IBM Cloud colo region where the + cluster will be created. Required for multi-zone regions. + type: string + required: + - powervsResourceGroup + - region + - serviceInstance + - userID + - zone + type: object vsphere: description: VSphere is the configuration used when installing on vSphere. diff --git a/pkg/types/clustermetadata.go b/pkg/types/clustermetadata.go index 9534b28a8b9..e525ee9c898 100644 --- a/pkg/types/clustermetadata.go +++ b/pkg/types/clustermetadata.go @@ -9,6 +9,7 @@ import ( "github.com/openshift/installer/pkg/types/libvirt" "github.com/openshift/installer/pkg/types/openstack" "github.com/openshift/installer/pkg/types/ovirt" + "github.com/openshift/installer/pkg/types/powervs" "github.com/openshift/installer/pkg/types/vsphere" ) @@ -34,6 +35,7 @@ type ClusterPlatformMetadata struct { IBMCloud *ibmcloud.Metadata `json:"ibmcloud,omitempty"` BareMetal *baremetal.Metadata `json:"baremetal,omitempty"` Ovirt *ovirt.Metadata `json:"ovirt,omitempty"` + PowerVS *powervs.Metadata `json:"powervs,omitempty"` VSphere *vsphere.Metadata `json:"vsphere,omitempty"` } @@ -68,6 +70,9 @@ func (cpm *ClusterPlatformMetadata) Platform() string { if cpm.Ovirt != nil { return ovirt.Name } + if cpm.PowerVS != nil { + return powervs.Name + } if cpm.VSphere != nil { return vsphere.Name } diff --git a/pkg/types/defaults/installconfig.go b/pkg/types/defaults/installconfig.go index ace0565aa01..720b82b98d2 100644 --- a/pkg/types/defaults/installconfig.go +++ b/pkg/types/defaults/installconfig.go @@ -14,6 +14,7 @@ import ( nonedefaults "github.com/openshift/installer/pkg/types/none/defaults" openstackdefaults "github.com/openshift/installer/pkg/types/openstack/defaults" ovirtdefaults "github.com/openshift/installer/pkg/types/ovirt/defaults" + powervsdefaults "github.com/openshift/installer/pkg/types/powervs/defaults" vspheredefaults "github.com/openshift/installer/pkg/types/vsphere/defaults" ) @@ -105,6 +106,8 @@ func SetInstallConfigDefaults(c *types.InstallConfig) { for i := range c.Compute { ovirtdefaults.SetComputeDefaults(c.Platform.Ovirt, &c.Compute[i]) } + case c.Platform.PowerVS != nil: + powervsdefaults.SetPlatformDefaults(c.Platform.PowerVS) case c.Platform.None != nil: nonedefaults.SetPlatformDefaults(c.Platform.None) } diff --git a/pkg/types/installconfig.go b/pkg/types/installconfig.go index 0d1d59b8529..fe03d95672f 100644 --- a/pkg/types/installconfig.go +++ b/pkg/types/installconfig.go @@ -14,6 +14,7 @@ import ( "github.com/openshift/installer/pkg/types/none" "github.com/openshift/installer/pkg/types/openstack" "github.com/openshift/installer/pkg/types/ovirt" + "github.com/openshift/installer/pkg/types/powervs" "github.com/openshift/installer/pkg/types/vsphere" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -45,6 +46,7 @@ var ( baremetal.Name, ibmcloud.Name, none.Name, + powervs.Name, } // OKD is a setting to enable community-only modifications @@ -198,6 +200,10 @@ type Platform struct { // +optional OpenStack *openstack.Platform `json:"openstack,omitempty"` + // PowerVS is the configuration used when installing on Power VS. + // +optional + PowerVS *powervs.Platform `json:"powervs,omitempty"` + // VSphere is the configuration used when installing on vSphere. // +optional VSphere *vsphere.Platform `json:"vsphere,omitempty"` @@ -234,6 +240,8 @@ func (p *Platform) Name() string { return vsphere.Name case p.Ovirt != nil: return ovirt.Name + case p.PowerVS != nil: + return powervs.Name default: return "" } diff --git a/pkg/types/machinepools.go b/pkg/types/machinepools.go index 390a2f9a9f0..787fb71f19e 100644 --- a/pkg/types/machinepools.go +++ b/pkg/types/machinepools.go @@ -9,6 +9,7 @@ import ( "github.com/openshift/installer/pkg/types/libvirt" "github.com/openshift/installer/pkg/types/openstack" "github.com/openshift/installer/pkg/types/ovirt" + "github.com/openshift/installer/pkg/types/powervs" "github.com/openshift/installer/pkg/types/vsphere" ) @@ -96,6 +97,9 @@ type MachinePoolPlatform struct { // Ovirt is the configuration used when installing on oVirt. Ovirt *ovirt.MachinePool `json:"ovirt,omitempty"` + + // PowerVS is the configuration used when installing on IBM Power VS. + PowerVS *powervs.MachinePool `json:"powervs,omitempty"` } // Name returns a string representation of the platform (e.g. "aws" if @@ -123,6 +127,8 @@ func (p *MachinePoolPlatform) Name() string { return vsphere.Name case p.Ovirt != nil: return ovirt.Name + case p.PowerVS != nil: + return powervs.Name default: return "" } diff --git a/pkg/types/powervs/OWNERS b/pkg/types/powervs/OWNERS new file mode 100644 index 00000000000..dbf1edc8d97 --- /dev/null +++ b/pkg/types/powervs/OWNERS @@ -0,0 +1,8 @@ +# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md +# This file just uses aliases defined in OWNERS_ALIASES in the root of the +# installer repo. + +approvers: + - powervs-approvers +reviewers: + - powervs-reviewers diff --git a/pkg/types/powervs/defaults/platform.go b/pkg/types/powervs/defaults/platform.go new file mode 100644 index 00000000000..86d8cda6730 --- /dev/null +++ b/pkg/types/powervs/defaults/platform.go @@ -0,0 +1,9 @@ +package defaults + +import ( + "github.com/openshift/installer/pkg/types/powervs" +) + +// SetPlatformDefaults sets the defaults for the platform. +func SetPlatformDefaults(p *powervs.Platform) { +} diff --git a/pkg/types/powervs/doc.go b/pkg/types/powervs/doc.go new file mode 100644 index 00000000000..7f0864590c0 --- /dev/null +++ b/pkg/types/powervs/doc.go @@ -0,0 +1,6 @@ +// Package powervs contains Power VS-specific structures for installer +// configuration and management. +package powervs + +// Name is name for the Power VS platform. +const Name string = "powervs" diff --git a/pkg/types/powervs/machinepools.go b/pkg/types/powervs/machinepools.go new file mode 100644 index 00000000000..a544a63dcf0 --- /dev/null +++ b/pkg/types/powervs/machinepools.go @@ -0,0 +1,51 @@ +package powervs + +// MachinePool stores the configuration for a machine pool installed on IBM Power VS. +type MachinePool struct { + // VolumeIDs is the list of volumes attached to the instance. + // + // +optional + VolumeIDs []string `json:"volumeIDs"` + + // Memory defines the memory in GB for the instance. + // + // +optional + Memory int `json:"memory"` + + // Processors defines the processing units for the instance. + // + // +optional + Processors float64 `json:"processors"` + + // ProcType defines the processor sharing model for the instance. + // + // +optional + ProcType string `json:"procType"` + + // SysType defines the system type for instance. + // + // +optional + SysType string `json:"sysType"` +} + +// Set stores values from required into a +func (a *MachinePool) Set(required *MachinePool) { + if required == nil || a == nil { + return + } + if len(required.VolumeIDs) != 0 { + a.VolumeIDs = required.VolumeIDs + } + if required.Memory != 0 { + a.Memory = required.Memory + } + if required.Processors != 0 { + a.Processors = required.Processors + } + if required.ProcType != "" { + a.ProcType = required.ProcType + } + if required.SysType != "" { + a.SysType = required.SysType + } +} diff --git a/pkg/types/powervs/metadata.go b/pkg/types/powervs/metadata.go new file mode 100644 index 00000000000..ef67610ab97 --- /dev/null +++ b/pkg/types/powervs/metadata.go @@ -0,0 +1,8 @@ +package powervs + +// Metadata contains Power VS metadata (e.g. for uninstalling the cluster). +type Metadata struct { + CISInstanceCRN string `json:"cisInstanceCRN"` + Region string `json:"region"` + Zone string `json:"zone"` +} diff --git a/pkg/types/powervs/platform.go b/pkg/types/powervs/platform.go new file mode 100644 index 00000000000..8263762e098 --- /dev/null +++ b/pkg/types/powervs/platform.go @@ -0,0 +1,63 @@ +package powervs + +// Platform stores all the global configuration that all machinesets +// use. +// Note: The subsequent mentions of future-TF support refer to work that is +// undergoing and should be available to test well in time for 4.10 feature- +// freeze. We do not plan to GA with these as required inputs. +type Platform struct { + + // ServiceInstanceID is the ID of the Power IAAS instance created from the IBM Cloud Catalog + ServiceInstanceID string `json:"serviceInstance"` + + // PowerVSResourceGroup is the resource group for creating Power VS resources. + PowerVSResourceGroup string `json:"powervsResourceGroup"` + + // Region specifies the IBM Cloud region where the cluster will be created. + Region string `json:"region"` + + // Zone specifies the IBM Cloud colo region where the cluster will be created. + // Required for multi-zone regions. + Zone string `json:"zone"` + + // Zone in the region used to create VPC resources. Leave unset + // to allow installer to randomly select a zone. + // + // +optional + VPCZone string `json:"vpcRegion,omitempty"` + + // UserID is the login for the user's IBM Cloud account. + UserID string `json:"userID"` + + // APIKey is the API key for the user's IBM Cloud account. + APIKey string `json:"APIKey,omitempty"` + + // VPC is a VPC inside IBM Cloud. Needed in order to create VPC Load Balancers. + // + // +optional + VPC string `json:"vpc,omitempty"` + + // Subnets specifies existing subnets (by ID) where cluster + // resources will be created. Leave unset to have the installer + // create subnets in a new VPC on your behalf. + // + // +optional + Subnets []string `json:"subnets,omitempty"` + + // PVSNetworkName specifies an existing network within the Power VS Service Instance. + // + // +optional + PVSNetworkName string `json:"pvsNetworkName,omitempty"` + + // ClusterOSImage is a pre-created Power VS boot image that overrides the + // default image for cluster nodes. + // + // +optional + ClusterOSImage string `json:"clusterOSImage,omitempty"` + + // DefaultMachinePlatform is the default configuration used when + // installing on Power VS for machine pools which do not define their own + // platform configuration. + // +optional + DefaultMachinePlatform *MachinePool `json:"defaultMachinePlatform,omitempty"` +} diff --git a/pkg/types/powervs/validation/machinepool.go b/pkg/types/powervs/validation/machinepool.go new file mode 100644 index 00000000000..b214e4a0bae --- /dev/null +++ b/pkg/types/powervs/validation/machinepool.go @@ -0,0 +1,27 @@ +package validation + +import ( + "k8s.io/apimachinery/pkg/util/validation/field" + + "github.com/openshift/installer/pkg/types/powervs" +) + +// ValidateMachinePool checks that the specified machine pool is valid. +func ValidateMachinePool(p *powervs.MachinePool, fldPath *field.Path) field.ErrorList { + allErrs := field.ErrorList{} + /* + for i, zone := range p.Zones { + if !strings.HasPrefix(zone, platform.Region) { + allErrs = append(allErrs, field.Invalid(fldPath.Child("zones").Index(i), zone, fmt.Sprintf("Zone not in configured region (%s)", platform.Region))) + } + } + + if p.OSDisk.DiskType != "" { + diskTypes := sets.NewString("pd-standard", "pd-ssd") + if !diskTypes.Has(p.OSDisk.DiskType) { + allErrs = append(allErrs, field.NotSupported(fldPath.Child("diskType"), p.OSDisk.DiskType, diskTypes.List())) + } + }*/ + + return allErrs +} diff --git a/pkg/types/powervs/validation/platform.go b/pkg/types/powervs/validation/platform.go new file mode 100644 index 00000000000..ec3855f144c --- /dev/null +++ b/pkg/types/powervs/validation/platform.go @@ -0,0 +1,23 @@ +package validation + +import ( + "k8s.io/apimachinery/pkg/util/validation/field" + + "github.com/openshift/installer/pkg/types/powervs" +) + +// ValidatePlatform checks that the specified platform is valid. +func ValidatePlatform(p *powervs.Platform, fldPath *field.Path) field.ErrorList { + allErrs := field.ErrorList{} + + if p.Region == "" { + allErrs = append(allErrs, field.Required(fldPath.Child("region"), "region must be specified")) + } + + /*if p.DefaultMachinePlatform != nil { + allErrs = append(allErrs, ValidateMachinePool(p, p.DefaultMachinePlatform, fldPath.Child("defaultMachinePlatform"))...) + }*/ + return allErrs +} + +//var schemeRE = regexp.MustCompile("^([^:]+)://") diff --git a/pkg/types/validation/installconfig.go b/pkg/types/validation/installconfig.go index c0c1312a61d..cdc97c7c25f 100644 --- a/pkg/types/validation/installconfig.go +++ b/pkg/types/validation/installconfig.go @@ -37,6 +37,8 @@ import ( openstackvalidation "github.com/openshift/installer/pkg/types/openstack/validation" "github.com/openshift/installer/pkg/types/ovirt" ovirtvalidation "github.com/openshift/installer/pkg/types/ovirt/validation" + "github.com/openshift/installer/pkg/types/powervs" + powervsvalidation "github.com/openshift/installer/pkg/types/powervs/validation" "github.com/openshift/installer/pkg/types/vsphere" vspherevalidation "github.com/openshift/installer/pkg/types/vsphere/validation" "github.com/openshift/installer/pkg/validate" @@ -480,6 +482,9 @@ func validatePlatform(platform *types.Platform, fldPath *field.Path, network *ty return openstackvalidation.ValidatePlatform(platform.OpenStack, network, f, c) }) } + if platform.PowerVS != nil { + validate(powervs.Name, platform.PowerVS, func(f *field.Path) field.ErrorList { return powervsvalidation.ValidatePlatform(platform.PowerVS, f) }) + } if platform.VSphere != nil { validate(vsphere.Name, platform.VSphere, func(f *field.Path) field.ErrorList { return vspherevalidation.ValidatePlatform(platform.VSphere, f) }) } diff --git a/pkg/types/validation/installconfig_test.go b/pkg/types/validation/installconfig_test.go index b9c908d971f..925c8957e0d 100644 --- a/pkg/types/validation/installconfig_test.go +++ b/pkg/types/validation/installconfig_test.go @@ -514,7 +514,7 @@ func TestValidateInstallConfig(t *testing.T) { c.Platform = types.Platform{} return c }(), - expectedError: `^platform: Invalid value: "": must specify one of the platforms \(aws, azure, baremetal, gcp, ibmcloud, none, openstack, ovirt, vsphere\)$`, + expectedError: `^platform: Invalid value: "": must specify one of the platforms \(aws, azure, baremetal, gcp, ibmcloud, none, openstack, ovirt, powervs, vsphere\)$`, }, { name: "multiple platforms", @@ -545,7 +545,7 @@ func TestValidateInstallConfig(t *testing.T) { } return c }(), - expectedError: `^platform: Invalid value: "libvirt": must specify one of the platforms \(aws, azure, baremetal, gcp, ibmcloud, none, openstack, ovirt, vsphere\)$`, + expectedError: `^platform: Invalid value: "libvirt": must specify one of the platforms \(aws, azure, baremetal, gcp, ibmcloud, none, openstack, ovirt, powervs, vsphere\)$`, }, { name: "invalid libvirt platform", @@ -557,7 +557,7 @@ func TestValidateInstallConfig(t *testing.T) { c.Platform.Libvirt.URI = "" return c }(), - expectedError: `^\[platform: Invalid value: "libvirt": must specify one of the platforms \(aws, azure, baremetal, gcp, ibmcloud, none, openstack, ovirt, vsphere\), platform\.libvirt\.uri: Invalid value: "": invalid URI "" \(no scheme\)]$`, + expectedError: `^\[platform: Invalid value: "libvirt": must specify one of the platforms \(aws, azure, baremetal, gcp, ibmcloud, none, openstack, ovirt, powervs, vsphere\), platform\.libvirt\.uri: Invalid value: "": invalid URI "" \(no scheme\)]$`, }, { name: "valid none platform", diff --git a/pkg/types/validation/machinepools.go b/pkg/types/validation/machinepools.go index f14f8078113..d7b0af2c271 100644 --- a/pkg/types/validation/machinepools.go +++ b/pkg/types/validation/machinepools.go @@ -22,6 +22,8 @@ import ( openstackvalidation "github.com/openshift/installer/pkg/types/openstack/validation" "github.com/openshift/installer/pkg/types/ovirt" ovirtvalidation "github.com/openshift/installer/pkg/types/ovirt/validation" + "github.com/openshift/installer/pkg/types/powervs" + powervsvalidation "github.com/openshift/installer/pkg/types/powervs/validation" "github.com/openshift/installer/pkg/types/vsphere" vspherevalidation "github.com/openshift/installer/pkg/types/vsphere/validation" ) @@ -117,6 +119,9 @@ func validateMachinePoolPlatform(platform *types.Platform, p *types.MachinePoolP if p.Ovirt != nil { validate(ovirt.Name, p.Ovirt, func(f *field.Path) field.ErrorList { return ovirtvalidation.ValidateMachinePool(p.Ovirt, f) }) } + if p.PowerVS != nil { + validate(powervs.Name, p.PowerVS, func(f *field.Path) field.ErrorList { return powervsvalidation.ValidateMachinePool(p.PowerVS, f) }) + } if p.OpenStack != nil { validate(openstack.Name, p.OpenStack, func(f *field.Path) field.ErrorList { return openstackvalidation.ValidateMachinePool(platform.OpenStack, p.OpenStack, pool.Name, f)