Skip to content

Commit 68f5288

Browse files
Merge pull request #9656 from sadasu/custom-dns-private-installs
OCPBUGS-54902: Custom-DNS: Update Kubeconfig and Infra CR based on private or public cluster
2 parents a4cb998 + 002849d commit 68f5288

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

cmd/openshift-install/create.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,12 @@ func handleUnreachableAPIServer(ctx context.Context, config *rest.Config) error
897897
return fmt.Errorf("failed to fetch %s: %w", lbConfig.Name(), err)
898898
}
899899

900-
_, ipAddrs, err := lbConfig.ParseDNSDataFromConfig(lbconfig.PublicLoadBalancer)
900+
lbType := lbconfig.PublicLoadBalancer
901+
if !installConfig.Config.PublicAPI() {
902+
lbType = lbconfig.PrivateLoadBalancer
903+
}
904+
905+
_, ipAddrs, err := lbConfig.ParseDNSDataFromConfig(lbType)
901906
if err != nil {
902907
return fmt.Errorf("failed to parse lbconfig: %w", err)
903908
}

pkg/infrastructure/aws/clusterapi/ignition.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ func editIgnition(ctx context.Context, in clusterapi.IgnitionInput) (*clusterapi
7171
privateIPAddresses = append(privateIPAddresses, *nic.PrivateIpAddress)
7272
}
7373
}
74+
if !in.InstallConfig.Config.PublicAPI() {
75+
// For private cluster installs, the API LB IP is the same as the API-Int LB IP
76+
publicIPAddresses = privateIPAddresses
77+
}
7478
logrus.Debugf("AWS: Editing Ignition files to start in-cluster DNS when UserProvisionedDNS is enabled")
7579
return clusterapi.EditIgnition(in, awstypes.Name, publicIPAddresses, privateIPAddresses)
7680
}

pkg/infrastructure/gcp/clusterapi/ignition.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)