diff --git a/.golangci.yml b/.golangci.yml index f508b31c77..d250b36e06 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,7 +3,6 @@ run: go: "1.20" skip-files: - "zz_generated.*\\.go$" - - apis/v1alpha3 allow-parallel-runners: true linters: diff --git a/apis/v1alpha3/cloudprovider_encoding_test.go b/apis/v1alpha3/cloudprovider_encoding_test.go index 82285cb81f..86f8e50f54 100644 --- a/apis/v1alpha3/cloudprovider_encoding_test.go +++ b/apis/v1alpha3/cloudprovider_encoding_test.go @@ -23,10 +23,10 @@ import ( "github.com/onsi/gomega" "github.com/pkg/errors" - "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1alpha3" + infrav1alpha3 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1alpha3" ) -var unmarshalWarnAsFatal = []v1alpha3.UnmarshalINIOptionFunc{v1alpha3.WarnAsFatal} +var unmarshalWarnAsFatal = []infrav1alpha3.UnmarshalINIOptionFunc{infrav1alpha3.WarnAsFatal} func errDeprecated(section, key string) error { return errors.Errorf("warning:\ncan't store data at section \"%s\", variable \"%s\"\n", section, key) //nolint:revive @@ -35,9 +35,9 @@ func errDeprecated(section, key string) error { type codecTestCase struct { testName string iniString string - configObj v1alpha3.CPIConfig + configObj infrav1alpha3.CPIConfig expectedError error - unmarshalOptions []v1alpha3.UnmarshalINIOptionFunc + unmarshalOptions []infrav1alpha3.UnmarshalINIOptionFunc } func TestMarshalINI(t *testing.T) { @@ -61,17 +61,17 @@ folder = "kubernetes" default-datastore = "default" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Username: "user", Password: "password", Datacenters: "us-west", ClusterID: "cluster-namespace/cluster-name", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": {}, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -96,19 +96,19 @@ datacenter = "us-west" folder = "kubernetes" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Port: "443", Insecure: true, Datacenters: "us-west", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": { Username: "user", Password: "password", }, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -130,16 +130,16 @@ datacenter = "us-west" folder = "kubernetes" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ SecretName: "vccreds", SecretNamespace: "kube-system", Datacenters: "us-west", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": {}, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -164,20 +164,20 @@ datacenter = "us-west" folder = "kubernetes" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Port: "443", Insecure: true, SecretName: "vccreds", SecretNamespace: "kube-system", Datacenters: "us-west", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": { Password: "password", }, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -205,13 +205,13 @@ datacenter = "us-west" folder = "kubernetes" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Username: "user", Password: "password", Datacenters: "us-west", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": { Thumbprint: "thumbprint:0", }, @@ -220,7 +220,7 @@ folder = "kubernetes" Thumbprint: "thumbprint:1", }, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -245,24 +245,24 @@ datacenter = "us-west" folder = "kubernetes" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Datacenters: "us-west", SecretName: "vccreds", SecretNamespace: "kube-system", CAFile: "/some/path/to/my/trusted/ca.pem", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": {}, "1.1.1.1": {}, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", }, - ProviderConfig: v1alpha3.CPIProviderConfig{ - Cloud: &v1alpha3.CPICloudConfig{ + ProviderConfig: infrav1alpha3.CPIProviderConfig{ + Cloud: &infrav1alpha3.CPICloudConfig{ ControllerImage: "test", }, }, @@ -371,17 +371,17 @@ func TestUnmarshalINI(t *testing.T) { folder = "kubernetes" default-datastore = "default" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Username: "user", Password: "password", Datacenters: "us-west", ClusterID: "cluster-namespace/cluster-name", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": {}, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -406,19 +406,19 @@ func TestUnmarshalINI(t *testing.T) { datacenter = "us-west" folder = "kubernetes" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Port: "443", Insecure: true, Datacenters: "us-west", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": { Username: "user", Password: "password", }, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -442,19 +442,19 @@ func TestUnmarshalINI(t *testing.T) { datacenter = "us-west" folder = "kubernetes" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Port: "443", Insecure: true, Datacenters: "us-west", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": { Username: "domain\\user", Password: "password", }, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -476,16 +476,16 @@ func TestUnmarshalINI(t *testing.T) { datacenter = "us-west" folder = "kubernetes" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ SecretName: "vccreds", SecretNamespace: "kube-system", Datacenters: "us-west", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": {}, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -510,20 +510,20 @@ func TestUnmarshalINI(t *testing.T) { datacenter = "us-west" folder = "kubernetes" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Port: "443", Insecure: true, SecretName: "vccreds", SecretNamespace: "kube-system", Datacenters: "us-west", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": { Password: "password", }, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -551,13 +551,13 @@ func TestUnmarshalINI(t *testing.T) { datacenter = "us-west" folder = "kubernetes" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Username: "user", Password: "password", Datacenters: "us-west", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": { Thumbprint: "thumbprint:0", }, @@ -566,7 +566,7 @@ func TestUnmarshalINI(t *testing.T) { Thumbprint: "thumbprint:1", }, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -590,18 +590,18 @@ func TestUnmarshalINI(t *testing.T) { datacenter = "us-west" folder = "kubernetes" `, - configObj: v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + configObj: infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Datacenters: "us-west", SecretName: "vccreds", SecretNamespace: "kube-system", CAFile: "/some/path/to/my/trusted/ca.pem", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": {}, "1.1.1.1": {}, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", @@ -618,7 +618,7 @@ func TestUnmarshalINI(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.testName, func(t *testing.T) { - var actualConfig v1alpha3.CPIConfig + var actualConfig infrav1alpha3.CPIConfig if err := actualConfig.UnmarshalINI( []byte(tc.iniString), @@ -676,7 +676,7 @@ func TestPasswords(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.testName, func(t *testing.T) { - var actualConfig v1alpha3.CPIConfig + var actualConfig infrav1alpha3.CPIConfig iniString := ` [Global] @@ -693,19 +693,19 @@ func TestPasswords(t *testing.T) { datacenter = "us-west" folder = "kubernetes" ` - expectedConfig := v1alpha3.CPIConfig{ - Global: v1alpha3.CPIGlobalConfig{ + expectedConfig := infrav1alpha3.CPIConfig{ + Global: infrav1alpha3.CPIGlobalConfig{ Port: "443", Insecure: true, Datacenters: "us-west", }, - VCenter: map[string]v1alpha3.CPIVCenterConfig{ + VCenter: map[string]infrav1alpha3.CPIVCenterConfig{ "0.0.0.0": { Username: "user", Password: tc.expectedString, }, }, - Workspace: v1alpha3.CPIWorkspaceConfig{ + Workspace: infrav1alpha3.CPIWorkspaceConfig{ Server: "0.0.0.0", Datacenter: "us-west", Folder: "kubernetes", diff --git a/apis/v1alpha3/cloudprovider_types.go b/apis/v1alpha3/cloudprovider_types.go index b3bfb83669..66b6b1ea00 100644 --- a/apis/v1alpha3/cloudprovider_types.go +++ b/apis/v1alpha3/cloudprovider_types.go @@ -27,7 +27,8 @@ limitations under the License. package v1alpha3 // CPIConfig is the vSphere cloud provider's configuration. -// DEPRECATED: will be removed in v1alpha4 +// +// Deprecated: will be removed in v1alpha4. type CPIConfig struct { // Global is the vSphere cloud provider's global configuration. // +optional @@ -59,7 +60,7 @@ type CPIConfig struct { } // CPIProviderConfig defines any extra information used to configure -// the vSphere external cloud provider +// the vSphere external cloud provider. type CPIProviderConfig struct { Cloud *CPICloudConfig `json:"cloud,omitempty"` Storage *CPIStorageConfig `json:"storage,omitempty"` diff --git a/apis/v1alpha3/conversion.go b/apis/v1alpha3/conversion.go index 1dd265e51b..8cbe0dc91d 100644 --- a/apis/v1alpha3/conversion.go +++ b/apis/v1alpha3/conversion.go @@ -19,31 +19,31 @@ package v1alpha3 import ( "k8s.io/apimachinery/pkg/conversion" - "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1" ) // Convert_v1beta1_VirtualMachineCloneSpec_To_v1alpha3_VirtualMachineCloneSpec is an autogenerated conversion function. -func Convert_v1beta1_VirtualMachineCloneSpec_To_v1alpha3_VirtualMachineCloneSpec(in *v1beta1.VirtualMachineCloneSpec, out *VirtualMachineCloneSpec, s conversion.Scope) error { +func Convert_v1beta1_VirtualMachineCloneSpec_To_v1alpha3_VirtualMachineCloneSpec(in *infrav1.VirtualMachineCloneSpec, out *VirtualMachineCloneSpec, s conversion.Scope) error { return autoConvert_v1beta1_VirtualMachineCloneSpec_To_v1alpha3_VirtualMachineCloneSpec(in, out, s) } // Convert_v1beta1_VSphereVMStatus_To_v1alpha3_VSphereVMStatus is an autogenerated conversion function. -func Convert_v1beta1_VSphereVMStatus_To_v1alpha3_VSphereVMStatus(in *v1beta1.VSphereVMStatus, out *VSphereVMStatus, s conversion.Scope) error { +func Convert_v1beta1_VSphereVMStatus_To_v1alpha3_VSphereVMStatus(in *infrav1.VSphereVMStatus, out *VSphereVMStatus, s conversion.Scope) error { return autoConvert_v1beta1_VSphereVMStatus_To_v1alpha3_VSphereVMStatus(in, out, s) } -func Convert_v1beta1_VSphereClusterStatus_To_v1alpha3_VSphereClusterStatus(in *v1beta1.VSphereClusterStatus, out *VSphereClusterStatus, s conversion.Scope) error { +func Convert_v1beta1_VSphereClusterStatus_To_v1alpha3_VSphereClusterStatus(in *infrav1.VSphereClusterStatus, out *VSphereClusterStatus, s conversion.Scope) error { return autoConvert_v1beta1_VSphereClusterStatus_To_v1alpha3_VSphereClusterStatus(in, out, s) } -func Convert_v1beta1_VSphereClusterSpec_To_v1alpha3_VSphereClusterSpec(in *v1beta1.VSphereClusterSpec, out *VSphereClusterSpec, s conversion.Scope) error { +func Convert_v1beta1_VSphereClusterSpec_To_v1alpha3_VSphereClusterSpec(in *infrav1.VSphereClusterSpec, out *VSphereClusterSpec, s conversion.Scope) error { return autoConvert_v1beta1_VSphereClusterSpec_To_v1alpha3_VSphereClusterSpec(in, out, s) } -func Convert_v1beta1_VSphereMachineSpec_To_v1alpha3_VSphereMachineSpec(in *v1beta1.VSphereMachineSpec, out *VSphereMachineSpec, s conversion.Scope) error { +func Convert_v1beta1_VSphereMachineSpec_To_v1alpha3_VSphereMachineSpec(in *infrav1.VSphereMachineSpec, out *VSphereMachineSpec, s conversion.Scope) error { return autoConvert_v1beta1_VSphereMachineSpec_To_v1alpha3_VSphereMachineSpec(in, out, s) } -func Convert_v1beta1_VSphereVMSpec_To_v1alpha3_VSphereVMSpec(in *v1beta1.VSphereVMSpec, out *VSphereVMSpec, s conversion.Scope) error { +func Convert_v1beta1_VSphereVMSpec_To_v1alpha3_VSphereVMSpec(in *infrav1.VSphereVMSpec, out *VSphereVMSpec, s conversion.Scope) error { return autoConvert_v1beta1_VSphereVMSpec_To_v1alpha3_VSphereVMSpec(in, out, s) } diff --git a/apis/v1alpha3/conversion_test.go b/apis/v1alpha3/conversion_test.go index 63ff552db1..6b6aa01fd9 100644 --- a/apis/v1alpha3/conversion_test.go +++ b/apis/v1alpha3/conversion_test.go @@ -24,10 +24,10 @@ import ( "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" "k8s.io/apimachinery/pkg/runtime" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" - clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" + clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3" utilconversion "sigs.k8s.io/cluster-api/util/conversion" - nextver "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1" ) //nolint:paralleltest @@ -35,11 +35,11 @@ func TestFuzzyConversion(t *testing.T) { g := NewWithT(t) scheme := runtime.NewScheme() g.Expect(AddToScheme(scheme)).To(Succeed()) - g.Expect(nextver.AddToScheme(scheme)).To(Succeed()) + g.Expect(infrav1.AddToScheme(scheme)).To(Succeed()) t.Run("for VSphereCluster", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Scheme: scheme, - Hub: &nextver.VSphereCluster{}, + Hub: &infrav1.VSphereCluster{}, Spoke: &VSphereCluster{}, FuzzerFuncs: []fuzzer.FuzzerFuncs{ overrideVSphereClusterDeprecatedFieldsFuncs, @@ -49,25 +49,25 @@ func TestFuzzyConversion(t *testing.T) { })) t.Run("for VSphereMachine", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Scheme: scheme, - Hub: &nextver.VSphereMachine{}, + Hub: &infrav1.VSphereMachine{}, Spoke: &VSphereMachine{}, FuzzerFuncs: []fuzzer.FuzzerFuncs{CustomNewFieldFuzzFunc}, })) t.Run("for VSphereMachineTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Scheme: scheme, - Hub: &nextver.VSphereMachineTemplate{}, + Hub: &infrav1.VSphereMachineTemplate{}, Spoke: &VSphereMachineTemplate{}, FuzzerFuncs: []fuzzer.FuzzerFuncs{CustomObjectMetaFuzzFunc, CustomNewFieldFuzzFunc}, })) t.Run("for VSphereVM", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Scheme: scheme, - Hub: &nextver.VSphereVM{}, + Hub: &infrav1.VSphereVM{}, Spoke: &VSphereVM{}, FuzzerFuncs: []fuzzer.FuzzerFuncs{CustomNewFieldFuzzFunc}, })) } -func overrideVSphereClusterDeprecatedFieldsFuncs(codecs runtimeserializer.CodecFactory) []interface{} { +func overrideVSphereClusterDeprecatedFieldsFuncs(runtimeserializer.CodecFactory) []interface{} { return []interface{}{ func(vsphereClusterSpec *VSphereClusterSpec, c fuzz.Continue) { vsphereClusterSpec.CloudProviderConfiguration = CPIConfig{} @@ -75,9 +75,9 @@ func overrideVSphereClusterDeprecatedFieldsFuncs(codecs runtimeserializer.CodecF } } -func overrideVSphereClusterSpecFieldsFuncs(codecs runtimeserializer.CodecFactory) []interface{} { +func overrideVSphereClusterSpecFieldsFuncs(runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(in *nextver.VSphereClusterSpec, c fuzz.Continue) { + func(in *infrav1.VSphereClusterSpec, c fuzz.Continue) { c.FuzzNoCustom(in) in.ClusterModules = nil in.FailureDomainSelector = nil @@ -85,23 +85,22 @@ func overrideVSphereClusterSpecFieldsFuncs(codecs runtimeserializer.CodecFactory } } -func overrideVSphereClusterStatusFieldsFuncs(codecs runtimeserializer.CodecFactory) []interface{} { +func overrideVSphereClusterStatusFieldsFuncs(runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - func(in *nextver.VSphereClusterStatus, c fuzz.Continue) { + func(in *infrav1.VSphereClusterStatus, c fuzz.Continue) { c.FuzzNoCustom(in) in.VCenterVersion = "" }, } } -func CustomObjectMetaFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { +func CustomObjectMetaFuzzFunc(runtimeserializer.CodecFactory) []interface{} { return []interface{}{ CustomObjectMetaFuzzer, } } -// nolint -func CustomObjectMetaFuzzer(in *clusterv1.ObjectMeta, c fuzz.Continue) { +func CustomObjectMetaFuzzer(in *clusterv1alpha3.ObjectMeta, c fuzz.Continue) { c.FuzzNoCustom(in) // These fields have been removed in v1alpha4 @@ -112,14 +111,14 @@ func CustomObjectMetaFuzzer(in *clusterv1.ObjectMeta, c fuzz.Continue) { in.OwnerReferences = nil } -func CustomNewFieldFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { +func CustomNewFieldFuzzFunc(runtimeserializer.CodecFactory) []interface{} { return []interface{}{ CustomSpecNewFieldFuzzer, CustomStatusNewFieldFuzzer, } } -func CustomSpecNewFieldFuzzer(in *nextver.VirtualMachineCloneSpec, c fuzz.Continue) { +func CustomSpecNewFieldFuzzer(in *infrav1.VirtualMachineCloneSpec, c fuzz.Continue) { c.FuzzNoCustom(in) in.PciDevices = nil @@ -128,7 +127,7 @@ func CustomSpecNewFieldFuzzer(in *nextver.VirtualMachineCloneSpec, c fuzz.Contin in.HardwareVersion = "" } -func CustomStatusNewFieldFuzzer(in *nextver.VSphereVMStatus, c fuzz.Continue) { +func CustomStatusNewFieldFuzzer(in *infrav1.VSphereVMStatus, c fuzz.Continue) { c.FuzzNoCustom(in) in.Host = "" diff --git a/apis/v1alpha3/networkdevicespec_conversion.go b/apis/v1alpha3/networkdevicespec_conversion.go index 2d69a8cc34..15c37283e1 100644 --- a/apis/v1alpha3/networkdevicespec_conversion.go +++ b/apis/v1alpha3/networkdevicespec_conversion.go @@ -17,12 +17,12 @@ limitations under the License. package v1alpha3 import ( - conversion "k8s.io/apimachinery/pkg/conversion" + "k8s.io/apimachinery/pkg/conversion" - v1beta1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1" ) -func Convert_v1beta1_NetworkDeviceSpec_To_v1alpha3_NetworkDeviceSpec(in *v1beta1.NetworkDeviceSpec, out *NetworkDeviceSpec, s conversion.Scope) error { +func Convert_v1beta1_NetworkDeviceSpec_To_v1alpha3_NetworkDeviceSpec(in *infrav1.NetworkDeviceSpec, out *NetworkDeviceSpec, s conversion.Scope) error { out.NetworkName = in.NetworkName out.DeviceName = in.DeviceName out.DHCP4 = in.DHCP4 diff --git a/apis/v1alpha3/types.go b/apis/v1alpha3/types.go index 3ff9e5d7d5..c1ba06f1c0 100644 --- a/apis/v1alpha3/types.go +++ b/apis/v1alpha3/types.go @@ -20,7 +20,7 @@ package v1alpha3 import ( "fmt" - clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" + clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3" ) const ( @@ -149,7 +149,7 @@ type VSphereMachineTemplateResource struct { // Standard object's metadata. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata // +optional - ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"` + ObjectMeta clusterv1alpha3.ObjectMeta `json:"metadata,omitempty"` // Spec is the specification of the desired behavior of the machine. Spec VSphereMachineSpec `json:"spec"` diff --git a/apis/v1alpha3/vspherecluster_types.go b/apis/v1alpha3/vspherecluster_types.go index 2a1702de1d..4e0b1773a5 100644 --- a/apis/v1alpha3/vspherecluster_types.go +++ b/apis/v1alpha3/vspherecluster_types.go @@ -19,7 +19,7 @@ package v1alpha3 import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" + clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3" ) const ( @@ -29,14 +29,15 @@ const ( ClusterFinalizer = "vspherecluster.infrastructure.cluster.x-k8s.io" ) -// VSphereClusterSpec defines the desired state of VSphereCluster +// VSphereClusterSpec defines the desired state of VSphereCluster. type VSphereClusterSpec struct { // Server is the address of the vSphere endpoint. Server string `json:"server,omitempty"` - // Insecure is a flag that controls whether or not to validate the + // Insecure is a flag that controls whether to validate the // vSphere server's certificate. - // DEPRECATED: will be removed in v1alpha4 + // + // Deprecated: will be removed in v1alpha4. // +optional Insecure *bool `json:"insecure,omitempty"` @@ -45,9 +46,9 @@ type VSphereClusterSpec struct { // +optional Thumbprint string `json:"thumbprint,omitempty"` - // CloudProviderConfiguration holds the cluster-wide configuration for the - // DEPRECATED: will be removed in v1alpha4 - // vSphere cloud provider. + // CloudProviderConfiguration holds the cluster-wide configuration for the vSphere cloud provider. + // + // Deprecated: will be removed in v1alpha4. CloudProviderConfiguration CPIConfig `json:"cloudProviderConfiguration,omitempty"` // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. @@ -59,7 +60,8 @@ type VSphereClusterSpec struct { // When a LoadBalancerRef is provided, the VSphereCluster.Status.Ready field // will not be true until the referenced resource is Status.Ready and has a // non-empty Status.Address value. - // DEPRECATED: will be removed in v1alpha4 + // + // Deprecated: will be removed in v1alpha4. // +optional LoadBalancerRef *corev1.ObjectReference `json:"loadBalancerRef,omitempty"` @@ -69,17 +71,17 @@ type VSphereClusterSpec struct { IdentityRef *VSphereIdentityReference `json:"identityRef,omitempty"` } -// VSphereClusterStatus defines the observed state of VSphereClusterSpec +// VSphereClusterStatus defines the observed state of VSphereClusterSpec. type VSphereClusterStatus struct { // +optional Ready bool `json:"ready,omitempty"` // Conditions defines current service state of the VSphereCluster. // +optional - Conditions clusterv1.Conditions `json:"conditions,omitempty"` + Conditions clusterv1alpha3.Conditions `json:"conditions,omitempty"` // FailureDomains is a list of failure domain objects synced from the infrastructure provider. - FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"` + FailureDomains clusterv1alpha3.FailureDomains `json:"failureDomains,omitempty"` } // +kubebuilder:object:root=true @@ -102,11 +104,11 @@ type VSphereCluster struct { Status VSphereClusterStatus `json:"status,omitempty"` } -func (m *VSphereCluster) GetConditions() clusterv1.Conditions { +func (m *VSphereCluster) GetConditions() clusterv1alpha3.Conditions { return m.Status.Conditions } -func (m *VSphereCluster) SetConditions(conditions clusterv1.Conditions) { +func (m *VSphereCluster) SetConditions(conditions clusterv1alpha3.Conditions) { m.Status.Conditions = conditions } diff --git a/apis/v1alpha3/vsphereclusteridentity_conversion.go b/apis/v1alpha3/vsphereclusteridentity_conversion.go index 7a2ab815c2..82492a8033 100644 --- a/apis/v1alpha3/vsphereclusteridentity_conversion.go +++ b/apis/v1alpha3/vsphereclusteridentity_conversion.go @@ -32,7 +32,7 @@ func (src *VSphereClusterIdentity) ConvertTo(dstRaw conversion.Hub) error { } // ConvertFrom converts from the Hub version (v1beta1) to this VSphereClusterIdentity. -func (dst *VSphereClusterIdentity) ConvertFrom(srcRaw conversion.Hub) error { // nolint +func (dst *VSphereClusterIdentity) ConvertFrom(srcRaw conversion.Hub) error { src := srcRaw.(*infrav1.VSphereClusterIdentity) if err := Convert_v1beta1_VSphereClusterIdentity_To_v1alpha3_VSphereClusterIdentity(src, dst, nil); err != nil { return err @@ -47,7 +47,7 @@ func (src *VSphereClusterIdentityList) ConvertTo(dstRaw conversion.Hub) error { } // ConvertFrom converts from the Hub version (v1beta1) to this VSphereClusterIdentityList. -func (dst *VSphereClusterIdentityList) ConvertFrom(srcRaw conversion.Hub) error { // nolint +func (dst *VSphereClusterIdentityList) ConvertFrom(srcRaw conversion.Hub) error { src := srcRaw.(*infrav1.VSphereClusterIdentityList) return Convert_v1beta1_VSphereClusterIdentityList_To_v1alpha3_VSphereClusterIdentityList(src, dst, nil) } diff --git a/apis/v1alpha3/vsphereclusteridentity_types.go b/apis/v1alpha3/vsphereclusteridentity_types.go index 39e512e590..77db74825b 100644 --- a/apis/v1alpha3/vsphereclusteridentity_types.go +++ b/apis/v1alpha3/vsphereclusteridentity_types.go @@ -14,12 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1alpha3 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" + clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3" ) const ( @@ -44,7 +43,7 @@ type VSphereClusterIdentityStatus struct { // Conditions defines current service state of the VSphereCluster. // +optional - Conditions clusterv1.Conditions `json:"conditions,omitempty"` + Conditions clusterv1alpha3.Conditions `json:"conditions,omitempty"` } type AllowedNamespaces struct { @@ -70,11 +69,11 @@ type VSphereIdentityReference struct { Name string `json:"name"` } -func (c *VSphereClusterIdentity) GetConditions() clusterv1.Conditions { +func (c *VSphereClusterIdentity) GetConditions() clusterv1alpha3.Conditions { return c.Status.Conditions } -func (c *VSphereClusterIdentity) SetConditions(conditions clusterv1.Conditions) { +func (c *VSphereClusterIdentity) SetConditions(conditions clusterv1alpha3.Conditions) { c.Status.Conditions = conditions } diff --git a/apis/v1alpha3/vspheredeploymentzone_conversion.go b/apis/v1alpha3/vspheredeploymentzone_conversion.go index fe6f1f8fdc..6e1ea2b225 100644 --- a/apis/v1alpha3/vspheredeploymentzone_conversion.go +++ b/apis/v1alpha3/vspheredeploymentzone_conversion.go @@ -29,7 +29,7 @@ func (src *VSphereDeploymentZone) ConvertTo(dstRaw conversion.Hub) error { } // ConvertFrom converts from the Hub version (v1beta1) to this VSphereDeploymentZone. -func (dst *VSphereDeploymentZone) ConvertFrom(srcRaw conversion.Hub) error { // nolint +func (dst *VSphereDeploymentZone) ConvertFrom(srcRaw conversion.Hub) error { src := srcRaw.(*infrav1.VSphereDeploymentZone) return Convert_v1beta1_VSphereDeploymentZone_To_v1alpha3_VSphereDeploymentZone(src, dst, nil) } @@ -41,7 +41,7 @@ func (src *VSphereDeploymentZoneList) ConvertTo(dstRaw conversion.Hub) error { } // ConvertFrom converts this VSphereDeploymentZoneList to the Hub version (v1beta1). -func (dst *VSphereDeploymentZoneList) ConvertFrom(srcRaw conversion.Hub) error { // nolint +func (dst *VSphereDeploymentZoneList) ConvertFrom(srcRaw conversion.Hub) error { src := srcRaw.(*infrav1.VSphereDeploymentZoneList) return Convert_v1beta1_VSphereDeploymentZoneList_To_v1alpha3_VSphereDeploymentZoneList(src, dst, nil) } diff --git a/apis/v1alpha3/vspheredeploymentzone_types.go b/apis/v1alpha3/vspheredeploymentzone_types.go index 26d56bab95..cbb403469d 100644 --- a/apis/v1alpha3/vspheredeploymentzone_types.go +++ b/apis/v1alpha3/vspheredeploymentzone_types.go @@ -19,7 +19,7 @@ package v1alpha3 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" + clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3" ) // VSphereDeploymentZoneSpec defines the desired state of VSphereDeploymentZone @@ -74,7 +74,7 @@ type VSphereDeploymentZoneStatus struct { // Conditions defines current service state of the VSphereMachine. // +optional - Conditions clusterv1.Conditions `json:"conditions,omitempty"` + Conditions clusterv1alpha3.Conditions `json:"conditions,omitempty"` } // +kubebuilder:object:root=true diff --git a/apis/v1alpha3/vspherefailuredomain_conversion.go b/apis/v1alpha3/vspherefailuredomain_conversion.go index 4cd8388959..357490d221 100644 --- a/apis/v1alpha3/vspherefailuredomain_conversion.go +++ b/apis/v1alpha3/vspherefailuredomain_conversion.go @@ -29,7 +29,7 @@ func (src *VSphereFailureDomain) ConvertTo(dstRaw conversion.Hub) error { } // ConvertFrom converts from the Hub version (v1beta1) to this VSphereFailureDomain. -func (dst *VSphereFailureDomain) ConvertFrom(srcRaw conversion.Hub) error { // nolint +func (dst *VSphereFailureDomain) ConvertFrom(srcRaw conversion.Hub) error { src := srcRaw.(*infrav1.VSphereFailureDomain) return Convert_v1beta1_VSphereFailureDomain_To_v1alpha3_VSphereFailureDomain(src, dst, nil) } @@ -41,7 +41,7 @@ func (src *VSphereFailureDomainList) ConvertTo(dstRaw conversion.Hub) error { } // ConvertFrom converts this VSphereFailureDomainList to the Hub version (v1beta1). -func (dst *VSphereFailureDomainList) ConvertFrom(srcRaw conversion.Hub) error { // nolint +func (dst *VSphereFailureDomainList) ConvertFrom(srcRaw conversion.Hub) error { src := srcRaw.(*infrav1.VSphereFailureDomainList) return Convert_v1beta1_VSphereFailureDomainList_To_v1alpha3_VSphereFailureDomainList(src, dst, nil) } diff --git a/apis/v1alpha3/vspheremachine_types.go b/apis/v1alpha3/vspheremachine_types.go index 35282ba052..9f1d5eb675 100644 --- a/apis/v1alpha3/vspheremachine_types.go +++ b/apis/v1alpha3/vspheremachine_types.go @@ -19,7 +19,7 @@ package v1alpha3 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" + clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3" "sigs.k8s.io/cluster-api/errors" ) @@ -51,7 +51,7 @@ type VSphereMachineStatus struct { Ready bool `json:"ready"` // Addresses contains the VSphere instance associated addresses. - Addresses []clusterv1.MachineAddress `json:"addresses,omitempty"` + Addresses []clusterv1alpha3.MachineAddress `json:"addresses,omitempty"` // Network returns the network status for each of the machine's configured // network interfaces. @@ -98,7 +98,7 @@ type VSphereMachineStatus struct { // Conditions defines current service state of the VSphereMachine. // +optional - Conditions clusterv1.Conditions `json:"conditions,omitempty"` + Conditions clusterv1alpha3.Conditions `json:"conditions,omitempty"` } // +kubebuilder:object:root=true @@ -122,11 +122,11 @@ type VSphereMachine struct { Status VSphereMachineStatus `json:"status,omitempty"` } -func (m *VSphereMachine) GetConditions() clusterv1.Conditions { +func (m *VSphereMachine) GetConditions() clusterv1alpha3.Conditions { return m.Status.Conditions } -func (m *VSphereMachine) SetConditions(conditions clusterv1.Conditions) { +func (m *VSphereMachine) SetConditions(conditions clusterv1alpha3.Conditions) { m.Status.Conditions = conditions } diff --git a/apis/v1alpha3/vspheremachinetemplate_conversion.go b/apis/v1alpha3/vspheremachinetemplate_conversion.go index 521f8e641a..f7e8ecba2c 100644 --- a/apis/v1alpha3/vspheremachinetemplate_conversion.go +++ b/apis/v1alpha3/vspheremachinetemplate_conversion.go @@ -18,15 +18,15 @@ package v1alpha3 import ( apiconversion "k8s.io/apimachinery/pkg/conversion" - clusterv1a3 "sigs.k8s.io/cluster-api/api/v1alpha3" - clusterv1b1 "sigs.k8s.io/cluster-api/api/v1beta1" + clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" utilconversion "sigs.k8s.io/cluster-api/util/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" infrav1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1" ) -// ConvertTo. +// ConvertTo converts this VSphereMachineTemplate to the Hub version (v1beta1). func (src *VSphereMachineTemplate) ConvertTo(dstRaw conversion.Hub) error { dst := dstRaw.(*infrav1.VSphereMachineTemplate) if err := Convert_v1alpha3_VSphereMachineTemplate_To_v1beta1_VSphereMachineTemplate(src, dst, nil); err != nil { @@ -75,16 +75,14 @@ func (dst *VSphereMachineTemplateList) ConvertFrom(srcRaw conversion.Hub) error return Convert_v1beta1_VSphereMachineTemplateList_To_v1alpha3_VSphereMachineTemplateList(src, dst, nil) } -// nolint -func Convert_v1alpha3_ObjectMeta_To_v1beta1_ObjectMeta(in *clusterv1a3.ObjectMeta, out *clusterv1b1.ObjectMeta, s apiconversion.Scope) error { +func Convert_v1alpha3_ObjectMeta_To_v1beta1_ObjectMeta(in *clusterv1alpha3.ObjectMeta, out *clusterv1.ObjectMeta, s apiconversion.Scope) error { // wrapping the conversion func to avoid having compile errors due to compileErrorOnMissingConversion() // more details at https://github.com/kubernetes/kubernetes/issues/98380 - return clusterv1a3.Convert_v1alpha3_ObjectMeta_To_v1beta1_ObjectMeta(in, out, s) + return clusterv1alpha3.Convert_v1alpha3_ObjectMeta_To_v1beta1_ObjectMeta(in, out, s) } -// nolint -func Convert_v1beta1_ObjectMeta_To_v1alpha3_ObjectMeta(in *clusterv1b1.ObjectMeta, out *clusterv1a3.ObjectMeta, s apiconversion.Scope) error { +func Convert_v1beta1_ObjectMeta_To_v1alpha3_ObjectMeta(in *clusterv1.ObjectMeta, out *clusterv1alpha3.ObjectMeta, s apiconversion.Scope) error { // wrapping the conversion func to avoid having compile errors due to compileErrorOnMissingConversion() // more details at https://github.com/kubernetes/kubernetes/issues/98380 - return clusterv1a3.Convert_v1beta1_ObjectMeta_To_v1alpha3_ObjectMeta(in, out, s) + return clusterv1alpha3.Convert_v1beta1_ObjectMeta_To_v1alpha3_ObjectMeta(in, out, s) } diff --git a/apis/v1alpha3/vspherevm_types.go b/apis/v1alpha3/vspherevm_types.go index ba336eeb53..5b97bedd60 100644 --- a/apis/v1alpha3/vspherevm_types.go +++ b/apis/v1alpha3/vspherevm_types.go @@ -20,7 +20,7 @@ package v1alpha3 import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" + clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3" "sigs.k8s.io/cluster-api/errors" ) @@ -122,7 +122,7 @@ type VSphereVMStatus struct { // Conditions defines current service state of the VSphereVM. // +optional - Conditions clusterv1.Conditions `json:"conditions,omitempty"` + Conditions clusterv1alpha3.Conditions `json:"conditions,omitempty"` } // +kubebuilder:object:root=true @@ -141,11 +141,11 @@ type VSphereVM struct { Status VSphereVMStatus `json:"status,omitempty"` } -func (m *VSphereVM) GetConditions() clusterv1.Conditions { +func (m *VSphereVM) GetConditions() clusterv1alpha3.Conditions { return m.Status.Conditions } -func (m *VSphereVM) SetConditions(conditions clusterv1.Conditions) { +func (m *VSphereVM) SetConditions(conditions clusterv1alpha3.Conditions) { m.Status.Conditions = conditions } diff --git a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusters.yaml b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusters.yaml index 7a1515b1a3..0ee84903f3 100644 --- a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusters.yaml +++ b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusters.yaml @@ -54,11 +54,12 @@ spec: metadata: type: object spec: - description: VSphereClusterSpec defines the desired state of VSphereCluster + description: VSphereClusterSpec defines the desired state of VSphereCluster. properties: cloudProviderConfiguration: - description: 'CloudProviderConfiguration holds the cluster-wide configuration - for the DEPRECATED: will be removed in v1alpha4 vSphere cloud provider.' + description: "CloudProviderConfiguration holds the cluster-wide configuration + for the vSphere cloud provider. \n Deprecated: will be removed in + v1alpha4." properties: disk: description: Disk is the vSphere cloud provider's disk configuration. @@ -279,16 +280,16 @@ spec: - name type: object insecure: - description: 'Insecure is a flag that controls whether or not to validate - the vSphere server''s certificate. DEPRECATED: will be removed in - v1alpha4' + description: "Insecure is a flag that controls whether to validate + the vSphere server's certificate. \n Deprecated: will be removed + in v1alpha4." type: boolean loadBalancerRef: - description: 'LoadBalancerRef may be used to enable a control plane + description: "LoadBalancerRef may be used to enable a control plane load balancer for this cluster. When a LoadBalancerRef is provided, the VSphereCluster.Status.Ready field will not be true until the referenced resource is Status.Ready and has a non-empty Status.Address - value. DEPRECATED: will be removed in v1alpha4' + value. \n Deprecated: will be removed in v1alpha4." properties: apiVersion: description: API version of the referent. @@ -334,7 +335,7 @@ spec: type: string type: object status: - description: VSphereClusterStatus defines the observed state of VSphereClusterSpec + description: VSphereClusterStatus defines the observed state of VSphereClusterSpec. properties: conditions: description: Conditions defines current service state of the VSphereCluster. diff --git a/test/e2e/data/infrastructure-vsphere/clusterclass-quick-start.yaml b/test/e2e/data/infrastructure-vsphere/clusterclass-quick-start.yaml new file mode 100644 index 0000000000..d2711cdd76 --- /dev/null +++ b/test/e2e/data/infrastructure-vsphere/clusterclass-quick-start.yaml @@ -0,0 +1,277 @@ +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: VSphereClusterTemplate +metadata: + name: '${CLUSTER_CLASS_NAME}' + namespace: '${NAMESPACE}' +spec: + template: + spec: {} +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: ClusterClass +metadata: + name: '${CLUSTER_CLASS_NAME}' +spec: + controlPlane: + machineInfrastructure: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: VSphereMachineTemplate + name: ${CLUSTER_CLASS_NAME}-template + namespace: '${NAMESPACE}' + ref: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KubeadmControlPlaneTemplate + name: ${CLUSTER_CLASS_NAME}-controlplane + namespace: '${NAMESPACE}' + infrastructure: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: VSphereClusterTemplate + name: '${CLUSTER_CLASS_NAME}' + namespace: '${NAMESPACE}' + patches: + - definitions: + - jsonPatches: + - op: add + path: /spec/template/spec/kubeadmConfigSpec/users + valueFrom: + template: | + - name: capv + sshAuthorizedKeys: + - '{{ .sshKey }}' + sudo: ALL=(ALL) NOPASSWD:ALL + selector: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KubeadmControlPlaneTemplate + matchResources: + controlPlane: true + - jsonPatches: + - op: add + path: /spec/template/spec/users + valueFrom: + template: | + - name: capv + sshAuthorizedKeys: + - '{{ .sshKey }}' + sudo: ALL=(ALL) NOPASSWD:ALL + selector: + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: KubeadmConfigTemplate + matchResources: + machineDeploymentClass: + names: + - ${CLUSTER_CLASS_NAME}-worker + enabledIf: '{{ if .sshKey }}true{{end}}' + name: enableSSHIntoNodes + - definitions: + - jsonPatches: + - op: add + path: /spec/template/spec/controlPlaneEndpoint + valueFrom: + template: | + host: '{{ .controlPlaneIpAddr }}' + port: 6443 + - op: add + path: /spec/template/spec/identityRef + valueFrom: + template: | + kind: Secret + name: '{{ .credsSecretName }}' + - op: add + path: /spec/template/spec/server + valueFrom: + variable: infraServer.url + - op: add + path: /spec/template/spec/thumbprint + valueFrom: + variable: infraServer.thumbprint + selector: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: VSphereClusterTemplate + matchResources: + infrastructureCluster: true + name: infraClusterSubstitutions + - definitions: + - jsonPatches: + - op: add + path: /spec/template/spec/kubeadmConfigSpec/files/0/content + valueFrom: + variable: kubeVipPodManifest + selector: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KubeadmControlPlaneTemplate + matchResources: + controlPlane: true + name: kubeVipEnabled + variables: + - name: sshKey + required: false + schema: + openAPIV3Schema: + description: Public key to SSH onto the cluster nodes. + type: string + - name: infraServer + required: true + schema: + openAPIV3Schema: + properties: + thumbprint: + type: string + url: + type: string + type: object + - name: controlPlaneIpAddr + required: true + schema: + openAPIV3Schema: + description: Floating VIP for the control plane. + type: string + - name: credsSecretName + required: true + schema: + openAPIV3Schema: + description: Secret containing the credentials for the infra cluster. + type: string + - name: kubeVipPodManifest + required: true + schema: + openAPIV3Schema: + description: kube-vip manifest for the control plane. + type: string + workers: + machineDeployments: + - class: ${CLUSTER_CLASS_NAME}-worker + template: + bootstrap: + ref: + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: KubeadmConfigTemplate + name: ${CLUSTER_CLASS_NAME}-worker-bootstrap-template + namespace: '${NAMESPACE}' + infrastructure: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: VSphereMachineTemplate + name: ${CLUSTER_CLASS_NAME}-worker-machinetemplate + namespace: '${NAMESPACE}' + metadata: {} +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: VSphereMachineTemplate +metadata: + name: ${CLUSTER_CLASS_NAME}-template + namespace: '${NAMESPACE}' +spec: + template: + spec: + cloneMode: linkedClone + datacenter: '${VSPHERE_DATACENTER}' + datastore: '${VSPHERE_DATASTORE}' + diskGiB: 25 + folder: '${VSPHERE_FOLDER}' + memoryMiB: 8192 + network: + devices: + - dhcp4: true + networkName: '${VSPHERE_NETWORK}' + numCPUs: 2 + os: Linux + powerOffMode: hard + resourcePool: '${VSPHERE_RESOURCE_POOL}' + server: '${VSPHERE_SERVER}' + storagePolicyName: '${VSPHERE_STORAGE_POLICY}' + template: '${VSPHERE_TEMPLATE}' + thumbprint: '${VSPHERE_TLS_THUMBPRINT}' +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: VSphereMachineTemplate +metadata: + name: ${CLUSTER_CLASS_NAME}-worker-machinetemplate + namespace: '${NAMESPACE}' +spec: + template: + spec: + cloneMode: linkedClone + datacenter: '${VSPHERE_DATACENTER}' + datastore: '${VSPHERE_DATASTORE}' + diskGiB: 25 + folder: '${VSPHERE_FOLDER}' + memoryMiB: 8192 + network: + devices: + - dhcp4: true + networkName: '${VSPHERE_NETWORK}' + numCPUs: 2 + os: Linux + powerOffMode: hard + resourcePool: '${VSPHERE_RESOURCE_POOL}' + server: '${VSPHERE_SERVER}' + storagePolicyName: '${VSPHERE_STORAGE_POLICY}' + template: '${VSPHERE_TEMPLATE}' + thumbprint: '${VSPHERE_TLS_THUMBPRINT}' +--- +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +kind: KubeadmControlPlaneTemplate +metadata: + name: ${CLUSTER_CLASS_NAME}-controlplane + namespace: '${NAMESPACE}' +spec: + template: + spec: + kubeadmConfigSpec: + clusterConfiguration: + apiServer: + extraArgs: + cloud-provider: external + controllerManager: + extraArgs: + cloud-provider: external + files: + - owner: root:root + path: /etc/kubernetes/manifests/kube-vip.yaml + initConfiguration: + nodeRegistration: + criSocket: /var/run/containerd/containerd.sock + kubeletExtraArgs: + cloud-provider: external + name: '{{ local_hostname }}' + joinConfiguration: + nodeRegistration: + criSocket: /var/run/containerd/containerd.sock + kubeletExtraArgs: + cloud-provider: external + name: '{{ local_hostname }}' + preKubeadmCommands: + - hostnamectl set-hostname "{{ ds.meta_data.hostname }}" + - echo "::1 ipv6-localhost ipv6-loopback localhost6 localhost6.localdomain6" + >/etc/hosts + - echo "127.0.0.1 {{ ds.meta_data.hostname }} {{ local_hostname }} localhost + localhost.localdomain localhost4 localhost4.localdomain4" >>/etc/hosts + users: + - name: capv + sshAuthorizedKeys: + - '${VSPHERE_SSH_AUTHORIZED_KEY}' + sudo: ALL=(ALL) NOPASSWD:ALL +--- +apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +kind: KubeadmConfigTemplate +metadata: + name: ${CLUSTER_CLASS_NAME}-worker-bootstrap-template + namespace: '${NAMESPACE}' +spec: + template: + spec: + joinConfiguration: + nodeRegistration: + criSocket: /var/run/containerd/containerd.sock + kubeletExtraArgs: + cloud-provider: external + name: '{{ local_hostname }}' + preKubeadmCommands: + - hostnamectl set-hostname "{{ ds.meta_data.hostname }}" + - echo "::1 ipv6-localhost ipv6-loopback localhost6 localhost6.localdomain6" + >/etc/hosts + - echo "127.0.0.1 {{ ds.meta_data.hostname }} {{ local_hostname }} localhost + localhost.localdomain localhost4 localhost4.localdomain4" >>/etc/hosts