github.com/openshift/installer@v1.4.17/pkg/types/nutanix/platform.go (about) 1 package nutanix 2 3 import ( 4 "fmt" 5 6 configv1 "github.com/openshift/api/config/v1" 7 ) 8 9 // CredentialsSecretName is the default nutanix credentials secret name. 10 // 11 //nolint:gosec 12 const CredentialsSecretName = "nutanix-credentials" 13 14 // Platform stores any global configuration used for Nutanix platforms. 15 type Platform struct { 16 // PrismCentral is the endpoint (address and port) and credentials to 17 // connect to the Prism Central. 18 // This serves as the default Prism-Central. 19 PrismCentral PrismCentral `json:"prismCentral"` 20 21 // PrismElements holds a list of Prism Elements (clusters). A Prism Element encompasses all Nutanix resources (VMs, subnets, etc.) 22 // used to host the OpenShift cluster. Currently only a single Prism Element may be defined. 23 // This serves as the default Prism-Element. 24 PrismElements []PrismElement `json:"prismElements"` 25 26 // ClusterOSImage overrides the url provided in rhcos.json to download the RHCOS Image. 27 // 28 // +optional 29 ClusterOSImage string `json:"clusterOSImage,omitempty"` 30 31 // DeprecatedAPIVIP is the virtual IP address for the api endpoint 32 // Deprecated: use APIVIPs 33 // 34 // +kubebuilder:validation:format=ip 35 // +optional 36 DeprecatedAPIVIP string `json:"apiVIP,omitempty"` 37 38 // APIVIPs contains the VIP(s) for the api endpoint. In dual stack clusters 39 // it contains an IPv4 and IPv6 address, otherwise only one VIP 40 // 41 // +kubebuilder:validation:MaxItems=2 42 // +kubebuilder:validation:UniqueItems=true 43 // +kubebuilder:validation:Format=ip 44 // +optional 45 APIVIPs []string `json:"apiVIPs,omitempty"` 46 47 // DeprecatedIngressVIP is the virtual IP address for ingress 48 // Deprecated: use IngressVIPs 49 // 50 // +kubebuilder:validation:format=ip 51 // +optional 52 DeprecatedIngressVIP string `json:"ingressVIP,omitempty"` 53 54 // IngressVIPs contains the VIP(s) for ingress. In dual stack clusters 55 // it contains an IPv4 and IPv6 address, otherwise only one VIP 56 // 57 // +kubebuilder:validation:MaxItems=2 58 // +kubebuilder:validation:UniqueItems=true 59 // +kubebuilder:validation:Format=ip 60 // +optional 61 IngressVIPs []string `json:"ingressVIPs,omitempty"` 62 63 // DefaultMachinePlatform is the default configuration used when 64 // installing on Nutanix for machine pools which do not define their own 65 // platform configuration. 66 // +optional 67 DefaultMachinePlatform *MachinePool `json:"defaultMachinePlatform,omitempty"` 68 69 // SubnetUUIDs identifies the network subnets to be used by the cluster. 70 // Currently we only support one subnet for an OpenShift cluster. 71 SubnetUUIDs []string `json:"subnetUUIDs"` 72 73 // LoadBalancer defines how the load balancer used by the cluster is configured. 74 // LoadBalancer is available in TechPreview. 75 // +optional 76 LoadBalancer *configv1.NutanixPlatformLoadBalancer `json:"loadBalancer,omitempty"` 77 78 // FailureDomains configures failure domains for the Nutanix platform. 79 // +optional 80 FailureDomains []FailureDomain `json:"failureDomains,omitempty"` 81 } 82 83 // PrismCentral holds the endpoint and credentials data used to connect to the Prism Central 84 type PrismCentral struct { 85 // Endpoint holds the address and port of the Prism Central 86 Endpoint PrismEndpoint `json:"endpoint"` 87 88 // Username is the name of the user to connect to the Prism Central 89 Username string `json:"username"` 90 91 // Password is the password for the user to connect to the Prism Central 92 Password string `json:"password"` 93 } 94 95 // PrismElement holds the uuid, endpoint of the Prism Element (cluster) 96 type PrismElement struct { 97 // UUID is the UUID of the Prism Element (cluster) 98 UUID string `json:"uuid"` 99 100 // Endpoint holds the address and port of the Prism Element 101 // +optional 102 Endpoint PrismEndpoint `json:"endpoint,omitempty"` 103 104 // Name is prism endpoint Name 105 Name string `json:"name,omitempty"` 106 } 107 108 // PrismEndpoint holds the endpoint address and port to access the Nutanix Prism Central or Element (cluster) 109 type PrismEndpoint struct { 110 // address is the endpoint address (DNS name or IP address) of the Nutanix Prism Central or Element (cluster) 111 Address string `json:"address"` 112 113 // port is the port number to access the Nutanix Prism Central or Element (cluster) 114 Port int32 `json:"port"` 115 } 116 117 // FailureDomain configures failure domain information for the Nutanix platform. 118 type FailureDomain struct { 119 // Name defines the unique name of a failure domain. 120 // +kubebuilder:validation:Required 121 // +kubebuilder:validation:MinLength=1 122 // +kubebuilder:validation:MaxLength=64 123 // +kubebuilder:validation:Pattern=`^[0-9A-Za-z_.-@/]+$` 124 Name string `json:"name"` 125 126 // prismElement holds the identification (name, uuid) and the optional endpoint address and port of the Nutanix Prism Element. 127 // When a cluster-wide proxy is installed, by default, this endpoint will be accessed via the proxy. 128 // Should you wish for communication with this endpoint not to be proxied, please add the endpoint to the 129 // proxy spec.noProxy list. 130 // +kubebuilder:validation:Required 131 PrismElement PrismElement `json:"prismElement"` 132 133 // SubnetUUIDs identifies the network subnets of the Prism Element. 134 // Currently we only support one subnet for a failure domain. 135 // +kubebuilder:validation:Required 136 // +kubebuilder:validation:MinItems=1 137 // +listType=set 138 SubnetUUIDs []string `json:"subnetUUIDs"` 139 140 // StorageContainers identifies the storage containers in the Prism Element. 141 // +optional 142 StorageContainers []StorageResourceReference `json:"storageContainers,omitempty"` 143 144 // DataSourceImages identifies the datasource images in the Prism Element. 145 // +optional 146 DataSourceImages []StorageResourceReference `json:"dataSourceImages,omitempty"` 147 } 148 149 // GetFailureDomainByName returns the NutanixFailureDomain pointer with the input name. 150 // Returns nil if not found. 151 func (p Platform) GetFailureDomainByName(fdName string) (*FailureDomain, error) { 152 for _, fd := range p.FailureDomains { 153 if fd.Name == fdName { 154 return &fd, nil 155 } 156 } 157 158 return nil, fmt.Errorf("not found the defined failure domain with name %q", fdName) 159 } 160 161 // GetStorageContainerFromFailureDomain returns the storage container configuration with the provided reference and failuer domain names. 162 // Returns nil and error if not found. 163 func (p Platform) GetStorageContainerFromFailureDomain(fdName, storageContainerRefName string) (*StorageResourceReference, error) { 164 for _, fd := range p.FailureDomains { 165 if fd.Name == fdName { 166 for _, sc := range fd.StorageContainers { 167 if sc.ReferenceName == storageContainerRefName { 168 return &sc, nil 169 } 170 } 171 } 172 } 173 174 return nil, fmt.Errorf("not found the storage container with reference name %q in failureDomain %q", storageContainerRefName, fdName) 175 } 176 177 // GetDataSourceImageFromFailureDomain returns the datasource image configuration with the provided reference and failuer domain names. 178 // Returns nil and error if not found. 179 func (p Platform) GetDataSourceImageFromFailureDomain(fdName, dataSourceRefName string) (*StorageResourceReference, error) { 180 for _, fd := range p.FailureDomains { 181 if fd.Name == fdName { 182 for _, dsi := range fd.DataSourceImages { 183 if dsi.ReferenceName == dataSourceRefName { 184 return &dsi, nil 185 } 186 } 187 } 188 } 189 190 return nil, fmt.Errorf("not found the datasource image with reference name %q in failureDomain %q", dataSourceRefName, fdName) 191 }