@@ -11,7 +11,6 @@ import (
1111
1212 "github.com/openshift/installer/pkg/asset/manifests/capiutils"
1313 "github.com/openshift/installer/pkg/infrastructure/clusterapi"
14- "github.com/openshift/installer/pkg/types"
1514 "github.com/openshift/installer/pkg/types/dns"
1615 "github.com/openshift/installer/pkg/types/gcp"
1716)
@@ -46,8 +45,16 @@ func editIgnition(ctx context.Context, in clusterapi.IgnitionInput) (*clusterapi
4645 project = in .InstallConfig .Config .GCP .NetworkProjectID
4746 }
4847
48+ apiIntIPAddress := * gcpCluster .Status .Network .APIInternalAddress
49+ addressIntCut := apiIntIPAddress [strings .LastIndex (apiIntIPAddress , "/" )+ 1 :]
50+ computeIntAddressObj , err := svc .Addresses .Get (project , in .InstallConfig .Config .GCP .Region , addressIntCut ).Context (ctx ).Do ()
51+ if err != nil {
52+ return nil , fmt .Errorf ("failed to get compute address: %w" , err )
53+ }
54+ computeIntAddress := computeIntAddressObj .Address
55+
4956 computeAddress := ""
50- if in .InstallConfig .Config .Publish == types . ExternalPublishingStrategy {
57+ if in .InstallConfig .Config .PublicAPI () {
5158 apiIPAddress := * gcpCluster .Status .Network .APIServerAddress
5259 addressCut := apiIPAddress [strings .LastIndex (apiIPAddress , "/" )+ 1 :]
5360 computeAddressObj , err := svc .GlobalAddresses .Get (project , addressCut ).Context (ctx ).Do ()
@@ -56,14 +63,11 @@ func editIgnition(ctx context.Context, in clusterapi.IgnitionInput) (*clusterapi
5663 }
5764
5865 computeAddress = computeAddressObj .Address
66+ } else {
67+ // In private clusters, the API and API-Int servers both point to the same internal load balancer
68+ computeAddress = computeIntAddressObj .Address
5969 }
6070
61- apiIntIPAddress := * gcpCluster .Status .Network .APIInternalAddress
62- addressIntCut := apiIntIPAddress [strings .LastIndex (apiIntIPAddress , "/" )+ 1 :]
63- computeIntAddress , err := svc .Addresses .Get (project , in .InstallConfig .Config .GCP .Region , addressIntCut ).Context (ctx ).Do ()
64- if err != nil {
65- return nil , fmt .Errorf ("failed to get compute address: %w" , err )
66- }
6771 logrus .Debugf ("GCP: Editing Ignition files to start in-cluster DNS when UserProvisionedDNS is enabled" )
68- return clusterapi .EditIgnition (in , gcp .Name , []string {computeAddress }, []string {computeIntAddress . Address })
72+ return clusterapi .EditIgnition (in , gcp .Name , []string {computeAddress }, []string {computeIntAddress })
6973}
0 commit comments