Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17,165 changes: 5,179 additions & 11,986 deletions data/data/cluster-api/vsphere-infrastructure-components.yaml

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ require (
github.com/thedevsaddam/retry v0.0.0-20200324223450-9769a859cc6d
github.com/ulikunitz/xz v0.5.11
github.com/vincent-petithory/dataurl v1.0.0
github.com/vmware/govmomi v0.30.4
github.com/vmware/govmomi v0.30.7
golang.org/x/crypto v0.14.0
golang.org/x/oauth2 v0.10.0
golang.org/x/sync v0.3.0
Expand All @@ -108,6 +108,7 @@ require (
sigs.k8s.io/cluster-api v1.5.2
sigs.k8s.io/cluster-api-provider-aws/v2 v2.2.4
sigs.k8s.io/cluster-api-provider-azure v0.0.0-00010101000000-000000000000
sigs.k8s.io/cluster-api-provider-vsphere v1.8.3
sigs.k8s.io/controller-runtime v0.16.2
sigs.k8s.io/controller-tools v0.10.0
sigs.k8s.io/yaml v1.3.0
Expand Down Expand Up @@ -143,6 +144,7 @@ require (
github.com/coreos/vcontext v0.0.0-20230201181013-d72178a18687 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/dougm/pretty v0.0.0-20171025230240-2ee9d7453c02 // indirect
github.com/elliotwutingfeng/asciiset v0.0.0-20230602022725-51bbb787efab // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
Expand Down Expand Up @@ -186,6 +188,7 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/leodido/go-urn v1.2.3 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand Down Expand Up @@ -226,7 +229,7 @@ require (
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/exp v0.0.0-20221002003631-540bb7301a08 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/text v0.13.0 // indirect
Expand All @@ -243,7 +246,7 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/gorm v1.24.5 // indirect
k8s.io/cluster-bootstrap v0.27.2 // indirect
k8s.io/cluster-bootstrap v0.27.4 // indirect
k8s.io/component-base v0.28.3 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
18 changes: 11 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b/go.mod h1:9rfv
github.com/containers/ocicrypt v1.0.2/go.mod h1:nsOhbP19flrX6rE7ieGFvBlr7modwmNjsqWarIUce4M=
github.com/containers/ocicrypt v1.1.1/go.mod h1:Dm55fwWm1YZAjYRaJ94z2mfZikIyIN4B0oB3dj3jFxY=
github.com/containers/storage v1.20.2/go.mod h1:oOB9Ie8OVPojvoaKWEGSEtHbXUAs+tSyr7RO7ZGteMc=
github.com/coredns/caddy v1.1.0 h1:ezvsPrT/tA/7pYDBZxu0cT0VmWk75AfIaf6GSYCNMf0=
github.com/coredns/caddy v1.1.1 h1:2eYKZT7i6yxIfGP3qLJoJ7HAsDJqYB+X68g4NYjSrE0=
github.com/coredns/corefile-migration v1.0.21 h1:W/DCETrHDiFo0Wj03EyMkaQ9fwsmSgqTCQDHpceaSsE=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down Expand Up @@ -319,6 +319,8 @@ github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNE
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/dougm/pretty v0.0.0-20171025230240-2ee9d7453c02 h1:tR3jsKPiO/mb6ntzk/dJlHZtm37CPfVp1C9KIo534+4=
github.com/dougm/pretty v0.0.0-20171025230240-2ee9d7453c02/go.mod h1:7NQ3kWOx2cZOSjtcveTa5nqupVr2s6/83sG+rTlI7uA=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
Expand Down Expand Up @@ -1236,8 +1238,8 @@ github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/vmware/govmomi v0.30.4 h1:BCKLoTmiBYRuplv3GxKEMBLtBaJm8PA56vo9bddIpYQ=
github.com/vmware/govmomi v0.30.4/go.mod h1:F7adsVewLNHsW/IIm7ziFURaXDaHEwcc+ym4r3INMdY=
github.com/vmware/govmomi v0.30.7 h1:YO8CcDpLJzmq6PK5/CBQbXyV21iCMh8SbdXt+xNkXp8=
github.com/vmware/govmomi v0.30.7/go.mod h1:epgoslm97rLECMV4D+08ORzUBEU7boFSepKjt7AYVGg=
github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728/go.mod h1:x9oS4Wk2s2u4tS29nEaDLdzvuHdB19CvSGJjPgkZJNk=
github.com/vmware/vmw-ovflib v0.0.0-20170608004843-1f217b9dc714/go.mod h1:jiPk45kn7klhByRvUq5i2vo1RtHKBHj+iWGFpxbXuuI=
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
Expand Down Expand Up @@ -1308,8 +1310,8 @@ go4.org v0.0.0-20200104003542-c7e774b10ea0/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
golang.org/x/exp v0.0.0-20221002003631-540bb7301a08 h1:LtBIgSqNhkuC9gA3BFjGy5obHQT1lnmNsMDFSqWzQ5w=
golang.org/x/exp v0.0.0-20221002003631-540bb7301a08/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down Expand Up @@ -1634,8 +1636,8 @@ k8s.io/apiserver v0.28.3 h1:8Ov47O1cMyeDzTXz0rwcfIIGAP/dP7L8rWbEljRcg5w=
k8s.io/cli-runtime v0.19.0/go.mod h1:tun9l0eUklT8IHIM0jors17KmUjcrAxn0myoBYwuNuo=
k8s.io/client-go v0.28.2 h1:DNoYI1vGq0slMBN/SWKMZMw0Rq+0EQW6/AK4v9+3VeY=
k8s.io/client-go v0.28.2/go.mod h1:sMkApowspLuc7omj1FOSUxSoqjr+d5Q0Yc0LOFnYFJY=
k8s.io/cluster-bootstrap v0.27.2 h1:OL3onrOwrUD7NQxBUqQwTl1Uu2GQKCkw9BMHpc4PbiA=
k8s.io/cluster-bootstrap v0.27.2/go.mod h1:b++PF0mjUOiTKdPQFlDw7p4V2VquANZ8SfhAwzxZJFM=
k8s.io/cluster-bootstrap v0.27.4 h1:fobmnzmWrv0RcTed71Kdek7ElUWDkQ38zG799o8M8I4=
k8s.io/cluster-bootstrap v0.27.4/go.mod h1:sLvyEcIhRmoG8HhaIDy8htZ9MuaYK6nP+BMKGqqirBs=
k8s.io/code-generator v0.18.0/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc=
k8s.io/code-generator v0.18.2/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc=
k8s.io/code-generator v0.19.0/go.mod h1:moqLn7w0t9cMs4+5CQyxnfA/HV8MF6aAVENF+WZZhgk=
Expand Down Expand Up @@ -1695,6 +1697,8 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.9/go.mod h1:dzAXnQb
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
sigs.k8s.io/cluster-api v1.5.2 h1:pCsyEHwTBb7n+U5Z2OA5STxdJ1EuSpJv8FLBx4lii3s=
sigs.k8s.io/cluster-api v1.5.2/go.mod h1:EGJUNpFWi7dF426tO8MG/jE+w7T0UO5KyMnOwQ5riUY=
sigs.k8s.io/cluster-api-provider-vsphere v1.8.3 h1:JoE3uRHuNHIx2j/80T3vVk+T4SbNWuU/TcbN5tDHCZY=
sigs.k8s.io/cluster-api-provider-vsphere v1.8.3/go.mod h1:rr8gLmOtYAIQb19YIsG4WbG84/i3VwD4OqA3nb7HAsI=
sigs.k8s.io/controller-tools v0.3.1-0.20200617211605-651903477185 h1:wLsmaqTEgs3DIfNzr0u/AfPHSVJbWHj/eevcS4AFvFE=
sigs.k8s.io/controller-tools v0.3.1-0.20200617211605-651903477185/go.mod h1:JuPG+FXjAeZL7eGmTuXUJduEMlI2/kGqb0rUGlVi+Yo=
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6/go.mod h1:p4QtZmO4uMYipTQNzagwnNoseA6OxSUutVw05NhYDRs=
Expand Down
24 changes: 21 additions & 3 deletions pkg/asset/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
typesaws "github.com/openshift/installer/pkg/types/aws"
typesazure "github.com/openshift/installer/pkg/types/azure"
typesopenstack "github.com/openshift/installer/pkg/types/openstack"
typesvsphere "github.com/openshift/installer/pkg/types/vsphere"
)

const (
Expand Down Expand Up @@ -115,8 +116,8 @@ func (c *Cluster) Generate(parents asset.Parents) (err error) {

platform := installConfig.Config.Platform.Name()
switch platform {
case typesaws.Name, typesazure.Name:
return c.generateClusterAPI(parents, installConfig, clusterID)
case typesaws.Name, typesazure.Name, typesvsphere.Name:
return c.generateClusterAPI(parents, installConfig, clusterID, terraformVariables)
default:
return c.generateTerraform(installConfig, clusterID, terraformVariables, platform)
}
Expand All @@ -141,7 +142,7 @@ func (c *Cluster) Load(f asset.FileFetcher) (found bool, err error) {
return false, nil
}

func (c *Cluster) generateClusterAPI(parents asset.Parents, installConfig *installconfig.InstallConfig, clusterID *installconfig.ClusterID) error {
func (c *Cluster) generateClusterAPI(parents asset.Parents, installConfig *installconfig.InstallConfig, clusterID *installconfig.ClusterID, terraformVariables *TerraformVariables) error {
capiManifests := &manifests.ClusterAPI{}
capiMachines := &machines.CAPIMachine{}
bootstrapIgnAsset := &bootstrap.Bootstrap{}
Expand All @@ -156,6 +157,23 @@ func (c *Cluster) generateClusterAPI(parents asset.Parents, installConfig *insta
clusterKubeconfigAsset,
)

platform := installConfig.Config.Platform.Name()

// vSphere has pre-reqs that need to be executed
switch platform {
case typesvsphere.Name:
tfvarsFiles := []*asset.File{}
for _, file := range terraformVariables.Files() {
tfvarsFiles = append(tfvarsFiles, file)
}

provider := infra.ProviderForPlatform(platform)
_, err := provider.Provision(InstallDir, tfvarsFiles)
if err != nil {
return err
}
}

// Only need the objects--not the files.
manifests := []client.Object{}
for _, m := range capiManifests.Manifests {
Expand Down
67 changes: 67 additions & 0 deletions pkg/asset/machines/capimachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import (
"context"
"fmt"
"strings"
"time"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
capa "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
capv "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1"
capi "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand All @@ -19,9 +21,11 @@ import (
"github.com/openshift/installer/pkg/asset/ignition/machine"
"github.com/openshift/installer/pkg/asset/installconfig"
"github.com/openshift/installer/pkg/asset/machines/aws"
"github.com/openshift/installer/pkg/asset/machines/vsphere"
"github.com/openshift/installer/pkg/asset/rhcos"
awstypes "github.com/openshift/installer/pkg/types/aws"
awsdefaults "github.com/openshift/installer/pkg/types/aws/defaults"
vspheretypes "github.com/openshift/installer/pkg/types/vsphere"
)

// Master generates the machines for the `master` machine pool.
Expand Down Expand Up @@ -56,6 +60,7 @@ func (m *CAPIMachine) Generate(dependencies asset.Parents) error {
installConfig := &installconfig.InstallConfig{}
rhcosImage := new(rhcos.Image)
mign := &machine.Master{}

dependencies.Get(clusterID, installConfig, rhcosImage, mign)

ic := installConfig.Config
Expand Down Expand Up @@ -194,6 +199,68 @@ func (m *CAPIMachine) Generate(dependencies asset.Parents) error {
}

m.Machines = append(m.Machines, bootstrapAWSMachine, bootstrapMachine)
case vspheretypes.Name:
templateName := clusterID.InfraID + "-rhcos"
mpool := defaultVSphereMachinePoolPlatform()

mpool.Set(ic.Platform.VSphere.DefaultMachinePlatform)
mpool.Set(pool.Platform.VSphere)

pool.Platform.VSphere = &mpool
timedContext, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
vsphereMachines, machines, err := vsphere.VSphereMachines(
timedContext,
clusterID.InfraID,
installConfig.Config,
&pool,
templateName,
"master",
fmt.Sprintf("%s-%s", clusterID.InfraID, "master"),
)
if err != nil {
return errors.Wrap(err, "failed to create master machine objects")
}
m.Machines = append(m.Machines, vsphereMachines...)

// TODO(vincepri): The following code is almost duplicated from aws.AWSMachines.
// Refactor and generalize around a bootstrap pool, with a single machine and
// a custom openshift label to determine the bootstrap machine role, so we can
// delete the machine when the stage is complete.
bootstrapVSphereMachine := &capv.VSphereMachine{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-%s-bootstrap", clusterID.InfraID, pool.Name),
Labels: map[string]string{
"cluster.x-k8s.io/control-plane": "",
},
},
Spec: machines[0].Spec,
}

//bootstrapVSphereMachine.Spec.CustomVMXKeys["guestinfo.ignition.config.data"] =

bootstrapMachine := &capi.Machine{
ObjectMeta: metav1.ObjectMeta{
Name: bootstrapVSphereMachine.Name,
Labels: map[string]string{
"cluster.x-k8s.io/control-plane": "",
},
},
Spec: capi.MachineSpec{
ClusterName: clusterID.InfraID,
Bootstrap: capi.Bootstrap{
DataSecretName: pointer.String(fmt.Sprintf("%s-%s", clusterID.InfraID, "bootstrap")),
},
InfrastructureRef: v1.ObjectReference{
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "VSphereMachine",
Name: bootstrapVSphereMachine.Name,
},
},
}

m.Machines = append(m.Machines, bootstrapVSphereMachine, bootstrapMachine)

default:
return nil
}
Expand Down
Loading