Skip to content

Commit 981416a

Browse files
committed
HIVE-2391: vSphere zonal support
1 parent 5a3b603 commit 981416a

34 files changed

+3012
-284
lines changed

apis/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313

1414
require (
1515
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
16-
github.com/go-logr/logr v1.4.2 // indirect
16+
github.com/go-logr/logr v1.4.2
1717
github.com/gogo/protobuf v1.3.2 // indirect
1818
github.com/json-iterator/go v1.1.12 // indirect
1919
github.com/kr/text v0.2.0 // indirect

apis/hive/v1/clusterdeprovision_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ type VSphereClusterDeprovision struct {
129129
// necessary for communicating with the VCenter.
130130
CertificatesSecretRef corev1.LocalObjectReference `json:"certificatesSecretRef"`
131131
// VCenter is the vSphere vCenter hostname.
132+
// Deprecated: use VCenters instead
132133
VCenter string `json:"vCenter"`
134+
// VCenters are potentially multiple vCenter hostnames. Prefer this field over VCenter.
135+
VCenters []string `json:"vCenters"`
133136
}
134137

135138
// IBMClusterDeprovision contains IBM Cloud specific configuration for a ClusterDeprovision

apis/hive/v1/vsphere/platform.go

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
package vsphere
22

33
import (
4+
"fmt"
5+
"strings"
6+
7+
"github.com/go-logr/logr"
8+
configv1 "github.com/openshift/api/config/v1"
49
corev1 "k8s.io/api/core/v1"
510
)
611

712
// Platform stores any global configuration used for vSphere platforms.
813
type Platform struct {
914
// VCenter is the domain name or IP address of the vCenter.
10-
VCenter string `json:"vCenter"`
15+
// Deprecated: Please use Platform.VSphere instead
16+
// See also: Platform.ConvertDeprecatedFields
17+
// +optional
18+
VCenter string `json:"vCenter,omitempty"`
1119

1220
// CredentialsSecretRef refers to a secret that contains the vSphere account access
1321
// credentials: GOVC_USERNAME, GOVC_PASSWORD fields.
@@ -18,18 +26,95 @@ type Platform struct {
1826
CertificatesSecretRef corev1.LocalObjectReference `json:"certificatesSecretRef"`
1927

2028
// Datacenter is the name of the datacenter to use in the vCenter.
21-
Datacenter string `json:"datacenter"`
29+
// Deprecated: Please use Platform.VSphere instead
30+
// See also: Platform.ConvertDeprecatedFields
31+
// +optional
32+
Datacenter string `json:"datacenter,omitempty"`
2233

2334
// DefaultDatastore is the default datastore to use for provisioning volumes.
24-
DefaultDatastore string `json:"defaultDatastore"`
35+
// Deprecated: Please use Platform.VSphere instead
36+
// See also: Platform.ConvertDeprecatedFields
37+
// +optional
38+
DefaultDatastore string `json:"defaultDatastore,omitempty"`
2539

2640
// Folder is the name of the folder that will be used and/or created for
2741
// virtual machines.
42+
// Deprecated: Please use Platform.VSphere instead
43+
// See also: Platform.ConvertDeprecatedFields
44+
// +optional
2845
Folder string `json:"folder,omitempty"`
2946

3047
// Cluster is the name of the cluster virtual machines will be cloned into.
48+
// Deprecated: Please use Platform.VSphere instead
49+
// See also: Platform.ConvertDeprecatedFields
50+
// +optional
3151
Cluster string `json:"cluster,omitempty"`
3252

3353
// Network specifies the name of the network to be used by the cluster.
54+
// Deprecated: Please use Platform.VSphere instead
55+
// See also: Platform.ConvertDeprecatedFields
56+
// +optional
3457
Network string `json:"network,omitempty"`
58+
59+
// VSphere is the full spec of the vSphere platform.
60+
VSphere *configv1.VSpherePlatformSpec `json:"vSphere,omitempty"`
61+
}
62+
63+
func (p *Platform) ConvertDeprecatedFields(logger logr.Logger) {
64+
if p.VSphere != nil {
65+
return
66+
}
67+
68+
p.VSphere = &configv1.VSpherePlatformSpec{
69+
VCenters: []configv1.VSpherePlatformVCenterSpec{
70+
{
71+
Server: p.VCenter,
72+
Port: 443,
73+
Datacenters: []string{p.Datacenter},
74+
},
75+
},
76+
FailureDomains: []configv1.VSpherePlatformFailureDomainSpec{
77+
{
78+
// names from https://github.com/openshift/installer/blob/f7731922a0f17a8339a3e837f72898ac77643611/pkg/types/vsphere/conversion/installconfig.go#L58-L61
79+
Name: "generated-failure-domain",
80+
Region: "generated-region",
81+
Zone: "generated-zone",
82+
Server: p.VCenter,
83+
Topology: configv1.VSpherePlatformTopology{
84+
Datacenter: p.Datacenter,
85+
Datastore: setDatastorePath(p.DefaultDatastore, p.Datacenter, logger),
86+
Folder: setFolderPath(p.Folder, p.Datacenter, logger),
87+
ComputeCluster: setComputeClusterPath(p.Cluster, p.Datacenter, logger),
88+
Networks: []string{p.Network},
89+
},
90+
},
91+
},
92+
}
93+
94+
}
95+
96+
// Copied (and slightly modified) from https://github.com/openshift/installer/blob/f7731922a0f17a8339a3e837f72898ac77643611/pkg/types/vsphere/conversion/installconfig.go#L75-L97
97+
98+
func setComputeClusterPath(cluster, datacenter string, logger logr.Logger) string {
99+
if cluster != "" && !strings.HasPrefix(cluster, "/") {
100+
logger.V(1).Info(fmt.Sprintf("computeCluster as a non-path is now depreciated please use the form: /%s/host/%s", datacenter, cluster))
101+
return fmt.Sprintf("/%s/host/%s", datacenter, cluster)
102+
}
103+
return cluster
104+
}
105+
106+
func setDatastorePath(datastore, datacenter string, logger logr.Logger) string {
107+
if datastore != "" && !strings.HasPrefix(datastore, "/") {
108+
logger.V(1).Info(fmt.Sprintf("datastore as a non-path is now depreciated please use the form: /%s/datastore/%s", datacenter, datastore))
109+
return fmt.Sprintf("/%s/datastore/%s", datacenter, datastore)
110+
}
111+
return datastore
112+
}
113+
114+
func setFolderPath(folder, datacenter string, logger logr.Logger) string {
115+
if folder != "" && !strings.HasPrefix(folder, "/") {
116+
logger.V(1).Info(fmt.Sprintf("folder as a non-path is now depreciated please use the form: /%s/vm/%s", datacenter, folder))
117+
return fmt.Sprintf("/%s/vm/%s", datacenter, folder)
118+
}
119+
return folder
35120
}

apis/hive/v1/vsphere/zz_generated.deepcopy.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/hive/v1/zz_generated.deepcopy.go

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)