github.com/openshift/installer@v1.4.17/pkg/types/vsphere/platform.go (about)

     1  package vsphere
     2  
     3  import (
     4  	configv1 "github.com/openshift/api/config/v1"
     5  )
     6  
     7  // DiskType is a disk provisioning type for vsphere.
     8  // +kubebuilder:validation:Enum="";thin;thick;eagerZeroedThick
     9  type DiskType string
    10  
    11  // FailureDomainType is the name of the failure domain type.
    12  // There are two defined failure domains currently, Datacenter and ComputeCluster.
    13  // Each represents a vCenter object type within a vSphere environment.
    14  // +kubebuilder:validation:Enum=HostGroup;Datacenter;ComputeCluster
    15  type FailureDomainType string
    16  
    17  const (
    18  	// DiskTypeThin uses Thin disk provisioning type for vsphere in the cluster.
    19  	DiskTypeThin DiskType = "thin"
    20  
    21  	// DiskTypeThick uses Thick disk provisioning type for vsphere in the cluster.
    22  	DiskTypeThick DiskType = "thick"
    23  
    24  	// DiskTypeEagerZeroedThick uses EagerZeroedThick disk provisioning type for vsphere in the cluster.
    25  	DiskTypeEagerZeroedThick DiskType = "eagerZeroedThick"
    26  
    27  	// TagCategoryRegion the tag category associated with regions.
    28  	TagCategoryRegion = "openshift-region"
    29  
    30  	// TagCategoryZone the tag category associated with zones.
    31  	TagCategoryZone = "openshift-zone"
    32  )
    33  
    34  const (
    35  	// ControlPlaneRole represents control-plane nodes.
    36  	ControlPlaneRole = "control-plane"
    37  	// ComputeRole represents worker nodes.
    38  	ComputeRole = "compute"
    39  	// BootstrapRole represents bootstrap nodes.
    40  	BootstrapRole = "bootstrap"
    41  )
    42  
    43  // Platform stores any global configuration used for vsphere platforms.
    44  type Platform struct {
    45  	// VCenter is the domain name or IP address of the vCenter.
    46  	// Deprecated: Use VCenters.Server
    47  	DeprecatedVCenter string `json:"vCenter,omitempty"`
    48  	// Username is the name of the user to use to connect to the vCenter.
    49  	// Deprecated: Use VCenters.Username
    50  	DeprecatedUsername string `json:"username,omitempty"`
    51  	// Password is the password for the user to use to connect to the vCenter.
    52  	// Deprecated: Use VCenters.Password
    53  	DeprecatedPassword string `json:"password,omitempty"`
    54  	// Datacenter is the name of the datacenter to use in the vCenter.
    55  	// Deprecated: Use FailureDomains.Topology.Datacenter
    56  	DeprecatedDatacenter string `json:"datacenter,omitempty"`
    57  	// DefaultDatastore is the default datastore to use for provisioning volumes.
    58  	// Deprecated: Use FailureDomains.Topology.Datastore
    59  	DeprecatedDefaultDatastore string `json:"defaultDatastore,omitempty"`
    60  	// Folder is the absolute path of the folder that will be used and/or created for
    61  	// virtual machines. The absolute path is of the form /<datacenter>/vm/<folder>/<subfolder>.
    62  	// +kubebuilder:validation:Pattern=`^/.*?/vm/.*?`
    63  	// +optional
    64  	// Deprecated: Use FailureDomains.Topology.Folder
    65  	DeprecatedFolder string `json:"folder,omitempty"`
    66  	// Cluster is the name of the cluster virtual machines will be cloned into.
    67  	// Deprecated: Use FailureDomains.Topology.Cluster
    68  	DeprecatedCluster string `json:"cluster,omitempty"`
    69  	// ResourcePool is the absolute path of the resource pool where virtual machines will be
    70  	// created. The absolute path is of the form /<datacenter>/host/<cluster>/Resources/<resourcepool>.
    71  	// Deprecated: Use FailureDomains.Topology.ResourcePool
    72  	DeprecatedResourcePool string `json:"resourcePool,omitempty"`
    73  	// ClusterOSImage overrides the url provided in rhcos.json to download the RHCOS OVA
    74  	ClusterOSImage string `json:"clusterOSImage,omitempty"`
    75  
    76  	// DeprecatedAPIVIP is the virtual IP address for the api endpoint
    77  	// Deprecated: Use APIVIPs
    78  	//
    79  	// +kubebuilder:validation:format=ip
    80  	// +optional
    81  	DeprecatedAPIVIP string `json:"apiVIP,omitempty"`
    82  
    83  	// APIVIPs contains the VIP(s) for the api endpoint. In dual stack clusters
    84  	// it contains an IPv4 and IPv6 address, otherwise only one VIP
    85  	//
    86  	// +kubebuilder:validation:MaxItems=2
    87  	// +kubebuilder:validation:UniqueItems=true
    88  	// +kubebuilder:validation:Format=ip
    89  	// +optional
    90  	APIVIPs []string `json:"apiVIPs,omitempty"`
    91  
    92  	// DeprecatedIngressVIP is the virtual IP address for ingress
    93  	// Deprecated: Use IngressVIPs
    94  	//
    95  	// +kubebuilder:validation:format=ip
    96  	// +optional
    97  	DeprecatedIngressVIP string `json:"ingressVIP,omitempty"`
    98  
    99  	// IngressVIPs contains the VIP(s) for ingress. In dual stack clusters it
   100  	// contains an IPv4 and IPv6 address, otherwise only one VIP
   101  	//
   102  	// +kubebuilder:validation:MaxItems=2
   103  	// +kubebuilder:validation:UniqueItems=true
   104  	// +kubebuilder:validation:Format=ip
   105  	// +optional
   106  	IngressVIPs []string `json:"ingressVIPs,omitempty"`
   107  
   108  	// DefaultMachinePlatform is the default configuration used when
   109  	// installing on VSphere for machine pools which do not define their own
   110  	// platform configuration.
   111  	// +optional
   112  	DefaultMachinePlatform *MachinePool `json:"defaultMachinePlatform,omitempty"`
   113  	// Network specifies the name of the network to be used by the cluster.
   114  	// Deprecated: Use FailureDomains.Topology.Network
   115  	DeprecatedNetwork string `json:"network,omitempty"`
   116  	// DiskType is the name of the disk provisioning type,
   117  	// valid values are thin, thick, and eagerZeroedThick. When not
   118  	// specified, it will be set according to the default storage policy
   119  	// of vsphere.
   120  	DiskType DiskType `json:"diskType,omitempty"`
   121  	// VCenters holds the connection details for services to communicate with vCenter.
   122  	// Currently only a single vCenter is supported.
   123  	// +kubebuilder:validation:Optional
   124  	// +kubebuilder:validation:MaxItems=3
   125  	// +kubebuilder:validation:MinItems=1
   126  	VCenters []VCenter `json:"vcenters,omitempty"`
   127  	// FailureDomains holds the VSpherePlatformFailureDomainSpec which contains
   128  	// the definition of region, zone and the vCenter topology.
   129  	// If this is omitted failure domains (regions and zones) will not be used.
   130  	// +kubebuilder:validation:Optional
   131  	FailureDomains []FailureDomain `json:"failureDomains,omitempty"`
   132  
   133  	// LoadBalancer defines how the load balancer used by the cluster is configured.
   134  	// LoadBalancer is available in TechPreview.
   135  	// +optional
   136  	LoadBalancer *configv1.VSpherePlatformLoadBalancer `json:"loadBalancer,omitempty"`
   137  	// Hosts defines network configurations to be applied by the installer. Hosts is available in TechPreview.
   138  	Hosts []*Host `json:"hosts,omitempty"`
   139  }
   140  
   141  // FailureDomain holds the region and zone failure domain and
   142  // the vCenter topology of that failure domain.
   143  type FailureDomain struct {
   144  	// name defines the name of the FailureDomain
   145  	// This name is arbitrary but will be used
   146  	// in VSpherePlatformDeploymentZone for association.
   147  	// +kubebuilder:validation:Required
   148  	// +kubebuilder:validation:MinLength=1
   149  	// +kubebuilder:validation:MaxLength=256
   150  	Name string `json:"name"`
   151  	// region defines a FailureDomainCoordinate which
   152  	// includes the name of the vCenter tag, the failure domain type
   153  	// and the name of the vCenter tag category.
   154  	// +kubebuilder:validation:Required
   155  	Region string `json:"region"`
   156  	// zone defines a VSpherePlatformFailureDomain which
   157  	// includes the name of the vCenter tag, the failure domain type
   158  	// and the name of the vCenter tag category.
   159  	// +kubebuilder:validation:Required
   160  	Zone string `json:"zone"`
   161  	// server is the fully-qualified domain name or the IP address of the vCenter server.
   162  	// +kubebuilder:validation:Required
   163  	// +kubebuilder:validation:MinLength=1
   164  	// +kubebuilder:validation:MaxLength=255
   165  	Server string `json:"server"`
   166  	// Topology describes a given failure domain using vSphere constructs
   167  	// +kubebuilder:validation:Required
   168  	Topology Topology `json:"topology"`
   169  }
   170  
   171  // Topology holds the required and optional vCenter objects - datacenter,
   172  // computeCluster, networks, datastore and resourcePool - to provision virtual machines.
   173  type Topology struct {
   174  	// datacenter is the vCenter datacenter in which virtual machines will be located
   175  	// and defined as the failure domain.
   176  	// +kubebuilder:validation:Required
   177  	// +kubebuilder:validation:MinLength=1
   178  	// +kubebuilder:validation:MaxLength=80
   179  	Datacenter string `json:"datacenter"`
   180  	// computeCluster as the failure domain
   181  	// This is required to be a path
   182  	// +kubebuilder:validation:Required
   183  	// +kubebuilder:validation:MinLength=1
   184  	// +kubebuilder:validation:MaxLength=2048
   185  	ComputeCluster string `json:"computeCluster"`
   186  	// networks is the list of networks within this failure domain
   187  	Networks []string `json:"networks,omitempty"`
   188  	// datastore is the name or inventory path of the datastore in which the
   189  	// virtual machine is created/located.
   190  	// +kubebuilder:validation:Required
   191  	// +kubebuilder:validation:MinLength=1
   192  	// +kubebuilder:validation:MaxLength=2048
   193  	Datastore string `json:"datastore"`
   194  	// resourcePool is the absolute path of the resource pool where virtual machines will be
   195  	// created. The absolute path is of the form /<datacenter>/host/<cluster>/Resources/<resourcepool>.
   196  	// +kubebuilder:validation:MinLength=1
   197  	// +kubebuilder:validation:MaxLength=2048
   198  	// +kubebuilder:validation:Pattern=`^/.*?/host/.*?/Resources.*`
   199  	// +optional
   200  	ResourcePool string `json:"resourcePool,omitempty"`
   201  	// folder is the inventory path of the folder in which the
   202  	// virtual machine is created/located.
   203  	// +kubebuilder:validation:MinLength=1
   204  	// +kubebuilder:validation:MaxLength=2048
   205  	// +kubebuilder:validation:Pattern=`^/.*?/vm/.*?`
   206  	// +optional
   207  	Folder string `json:"folder,omitempty"`
   208  	// template is the inventory path of the virtual machine or template
   209  	// that will be used for cloning.
   210  	// +kubebuilder:validation:MinLength=1
   211  	// +kubebuilder:validation:MaxLength=2048
   212  	// +kubebuilder:validation:Pattern=`^/.*?/vm/.*?`
   213  	// +optional
   214  	Template string `json:"template,omitempty"`
   215  	// tagIDs is an optional set of tags to add to an instance. Specified tagIDs
   216  	// must use URN-notation instead of display names. A maximum of 10 tag IDs may be specified.
   217  	// +kubebuilder:example=`urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9578:GLOBAL`
   218  	// +optional
   219  	TagIDs []string `json:"tagIDs,omitempty"`
   220  }
   221  
   222  // VCenter stores the vCenter connection fields
   223  // https://github.com/kubernetes/cloud-provider-vsphere/blob/master/pkg/common/config/types_yaml.go
   224  type VCenter struct {
   225  	// server is the fully-qualified domain name or the IP address of the vCenter server.
   226  	// +kubebuilder:validation:Required
   227  	// +kubebuilder:validation:MaxLength=255
   228  	Server string `json:"server"`
   229  	// port is the TCP port that will be used to communicate to
   230  	// the vCenter endpoint. This is typically unchanged from
   231  	// the default of HTTPS TCP/443.
   232  	// +kubebuilder:validation:Optional
   233  	// +kubebuilder:validation:Minimum=1
   234  	// +kubebuilder:validation:Maximum=32767
   235  	// +kubebuilder:default=443
   236  	Port int32 `json:"port,omitempty"`
   237  	// Username is the username that will be used to connect to vCenter
   238  	// +kubebuilder:validation:Required
   239  	Username string `json:"user"`
   240  	// Password is the password for the user to use to connect to the vCenter.
   241  	// +kubebuilder:validation:Required
   242  	Password string `json:"password"`
   243  	// Datacenter in which VMs are located.
   244  	// +kubebuilder:validation:Required
   245  	// +kubebuilder:validation:MinItems=1
   246  	Datacenters []string `json:"datacenters"`
   247  }
   248  
   249  // Host defines host VMs to generate as part of the installation.
   250  type Host struct {
   251  	// FailureDomain refers to the name of a FailureDomain as described in https://github.com/openshift/enhancements/blob/master/enhancements/installer/vsphere-ipi-zonal.md
   252  	// +optional
   253  	FailureDomain string `json:"failureDomain"`
   254  	// NetworkDeviceSpec to be applied to the host
   255  	// +kubebuilder:validation:Required
   256  	NetworkDevice *NetworkDeviceSpec `json:"networkDevice"`
   257  	// Role defines the role of the node
   258  	// +kubebuilder:validation:Enum="";bootstrap;control-plane;compute
   259  	// +kubebuilder:validation:Required
   260  	Role string `json:"role"`
   261  }
   262  
   263  // NetworkDeviceSpec defines network config for static IP assignment.
   264  type NetworkDeviceSpec struct {
   265  	// gateway is an IPv4 or IPv6 address which represents the subnet gateway,
   266  	// for example, 192.168.1.1.
   267  	// +kubebuilder:validation:Format=ipv4
   268  	// +kubebuilder:validation:Format=ipv6
   269  	Gateway string `json:"gateway,omitempty"`
   270  
   271  	// ipAddrs is a list of one or more IPv4 and/or IPv6 addresses and CIDR to assign to
   272  	// this device, for example, 192.168.1.100/24. IP addresses provided via ipAddrs are
   273  	// intended to allow explicit assignment of a machine's IP address.
   274  	// +kubebuilder:validation:Format=ipv4
   275  	// +kubebuilder:validation:Format=ipv6
   276  	// +kubebuilder:example=`192.168.1.100/24`
   277  	// +kubebuilder:example=`2001:DB8:0000:0000:244:17FF:FEB6:D37D/64`
   278  	// +kubebuilder:validation:Required
   279  	IPAddrs []string `json:"ipAddrs"`
   280  
   281  	// nameservers is a list of IPv4 and/or IPv6 addresses used as DNS nameservers, for example,
   282  	// 8.8.8.8. a nameserver is not provided by a fulfilled IPAddressClaim. If DHCP is not the
   283  	// source of IP addresses for this network device, nameservers should include a valid nameserver.
   284  	// +kubebuilder:validation:Format=ipv4
   285  	// +kubebuilder:validation:Format=ipv6
   286  	// +kubebuilder:example=`8.8.8.8`
   287  	Nameservers []string `json:"nameservers,omitempty"`
   288  }
   289  
   290  // IsControlPlane checks if the current host is a master.
   291  func (h *Host) IsControlPlane() bool {
   292  	return h.Role == ControlPlaneRole
   293  }
   294  
   295  // IsCompute checks if the current host is a worker.
   296  func (h *Host) IsCompute() bool {
   297  	return h.Role == ComputeRole
   298  }
   299  
   300  // IsBootstrap checks if the current host is a bootstrap.
   301  func (h *Host) IsBootstrap() bool {
   302  	return h.Role == BootstrapRole
   303  }