Skip to content

Commit eb922c0

Browse files
Merge pull request #8011 from barbacbd/capg-basic-infrastructure
CORS-3220: Initiate CAPG installation
2 parents e28c80f + d1c7dde commit eb922c0

File tree

6 files changed

+70
-0
lines changed

6 files changed

+70
-0
lines changed

pkg/asset/cluster/cluster.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ import (
1919
"github.com/openshift/installer/pkg/asset/installconfig"
2020
"github.com/openshift/installer/pkg/asset/kubeconfig"
2121
"github.com/openshift/installer/pkg/asset/machines"
22+
"github.com/openshift/installer/pkg/asset/manifests"
2223
capimanifests "github.com/openshift/installer/pkg/asset/manifests/clusterapi"
2324
"github.com/openshift/installer/pkg/asset/password"
2425
"github.com/openshift/installer/pkg/asset/quota"
26+
"github.com/openshift/installer/pkg/asset/rhcos"
2527
infra "github.com/openshift/installer/pkg/infrastructure/platform"
2628
typesaws "github.com/openshift/installer/pkg/types/aws"
2729
typesazure "github.com/openshift/installer/pkg/types/azure"
@@ -67,6 +69,8 @@ func (c *Cluster) Dependencies() []asset.Asset {
6769
&bootstrap.Bootstrap{},
6870
&machine.Master{},
6971
&machines.ClusterAPI{},
72+
new(rhcos.Image),
73+
&manifests.Manifests{},
7074
}
7175
}
7276

pkg/infrastructure/clusterapi/clusterapi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ func (i *InfraProvider) Provision(dir string, parents asset.Parents) ([]*asset.F
206206
// bootstrap ignition behavior.
207207
if p, ok := i.impl.(IgnitionProvider); ok {
208208
ignInput := IgnitionInput{
209+
Client: cl,
209210
BootstrapIgnData: bootstrapIgnData,
210211
InfraID: clusterID.InfraID,
211212
InstallConfig: installConfig,

pkg/infrastructure/clusterapi/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type IgnitionProvider interface {
4444

4545
// IgnitionInput collects the args passed to the IgnitionProvider call.
4646
type IgnitionInput struct {
47+
Client client.Client
4748
BootstrapIgnData []byte
4849
InfraID string
4950
InstallConfig *installconfig.InstallConfig
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package clusterapi
2+
3+
import (
4+
"context"
5+
6+
"github.com/openshift/installer/pkg/infrastructure/clusterapi"
7+
gcptypes "github.com/openshift/installer/pkg/types/gcp"
8+
)
9+
10+
// Provider implements gcp infrastructure in conjunction with the
11+
// GCP CAPI provider.
12+
type Provider struct {
13+
}
14+
15+
var _ clusterapi.PreProvider = (*Provider)(nil)
16+
var _ clusterapi.IgnitionProvider = (*Provider)(nil)
17+
var _ clusterapi.InfraReadyProvider = (*Provider)(nil)
18+
var _ clusterapi.PostProvider = (*Provider)(nil)
19+
20+
// Name returns the name for the platform.
21+
func (p Provider) Name() string {
22+
return gcptypes.Name
23+
}
24+
25+
// PreProvision is called before provisioning using CAPI controllers has initiated.
26+
// GCP resources that are not created by CAPG (and are required for other stages of the install) are
27+
// created here using the gcp sdk.
28+
func (p Provider) PreProvision(ctx context.Context, in clusterapi.PreProvisionInput) error {
29+
return nil
30+
}
31+
32+
// Ignition provisions the GCP bucket and url that points to the bucket. Bootstrap ignition data cannot
33+
// populate the metadata field of the bootstrap instance as the data can be too large. Instead, the data is
34+
// added to a bucket. A signed url is generated to point to the bucket and the ignition data will be
35+
// updated to point to the url. This is also allows for bootstrap data to be edited after its initial creation.
36+
func (p Provider) Ignition(ctx context.Context, in clusterapi.IgnitionInput) ([]byte, error) {
37+
return nil, nil
38+
}
39+
40+
// InfraReady is called once cluster.Status.InfrastructureReady
41+
// is true, typically after load balancers have been provisioned. It can be used
42+
// to create DNS records.
43+
func (p Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput) error {
44+
return nil
45+
}
46+
47+
// PostProvision should be called to add or update and GCP resources after provisioning has completed.
48+
func (p Provider) PostProvision(ctx context.Context, in clusterapi.PostProvisionInput) error {
49+
return nil
50+
}

pkg/infrastructure/platform/platform.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
configv1 "github.com/openshift/api/config/v1"
1010
"github.com/openshift/installer/pkg/infrastructure"
1111
awsinfra "github.com/openshift/installer/pkg/infrastructure/aws"
12+
"github.com/openshift/installer/pkg/infrastructure/clusterapi"
13+
gcpcapi "github.com/openshift/installer/pkg/infrastructure/gcp/clusterapi"
1214
"github.com/openshift/installer/pkg/terraform"
1315
"github.com/openshift/installer/pkg/terraform/stages/aws"
1416
"github.com/openshift/installer/pkg/terraform/stages/azure"
@@ -52,6 +54,9 @@ func ProviderForPlatform(platform string, fg featuregates.FeatureGate) (infrastr
5254
case baremetaltypes.Name:
5355
return terraform.InitializeProvider(baremetal.PlatformStages), nil
5456
case gcptypes.Name:
57+
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
58+
return clusterapi.InitializeProvider(gcpcapi.Provider{}), nil
59+
}
5560
return terraform.InitializeProvider(gcp.PlatformStages), nil
5661
case ibmcloudtypes.Name:
5762
return terraform.InitializeProvider(ibmcloud.PlatformStages), nil

pkg/infrastructure/platform/platform_altinfra.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ package platform
66
import (
77
"fmt"
88

9+
configv1 "github.com/openshift/api/config/v1"
910
"github.com/openshift/installer/pkg/infrastructure"
1011
"github.com/openshift/installer/pkg/infrastructure/aws"
12+
"github.com/openshift/installer/pkg/infrastructure/clusterapi"
13+
gcpcapi "github.com/openshift/installer/pkg/infrastructure/gcp/clusterapi"
1114
awstypes "github.com/openshift/installer/pkg/types/aws"
1215
azuretypes "github.com/openshift/installer/pkg/types/azure"
1316
"github.com/openshift/installer/pkg/types/featuregates"
17+
gcptypes "github.com/openshift/installer/pkg/types/gcp"
1418
vspheretypes "github.com/openshift/installer/pkg/types/vsphere"
1519
)
1620

@@ -22,6 +26,11 @@ func ProviderForPlatform(platform string, fg featuregates.FeatureGate) (infrastr
2226
case azuretypes.Name:
2327
panic("not implemented")
2428
return nil, nil
29+
case gcptypes.Name:
30+
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
31+
return clusterapi.InitializeProvider(gcpcapi.Provider{}), nil
32+
}
33+
return nil, nil
2534
case vspheretypes.Name:
2635
panic("not implemented")
2736
return nil, nil

0 commit comments

Comments
 (0)