Skip to content

Commit 6eb7556

Browse files
committed
gce: expose kops-controller on internal LB for gossip clusters
Enable workers to reach kops-controller via the internal API load balancer instead of resolving kops-controller.internal via gossip DNS, which broke when the gcediscovery resolver was removed in #15121. Signed-off-by: Ciprian Hacman <ciprian@hakman.dev>
1 parent e1fe0d7 commit 6eb7556

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

pkg/apis/kops/cluster.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,19 @@ func (c *Cluster) UsesNoneDNS() bool {
955955
return false
956956
}
957957

958+
// UsesLoadBalancerForKopsController returns true when worker nodes reach kops-controller
959+
// via the cluster API load balancer instead of via gossip-populated /etc/hosts. True for
960+
// None-DNS clusters across all clouds, plus GCE gossip clusters with an API load balancer.
961+
func (c *Cluster) UsesLoadBalancerForKopsController() bool {
962+
if c.UsesNoneDNS() {
963+
return true
964+
}
965+
if c.UsesLegacyGossip() && c.GetCloudProvider() == CloudProviderGCE && c.Spec.API.LoadBalancer != nil {
966+
return true
967+
}
968+
return false
969+
}
970+
958971
func (c *Cluster) InstallCNIAssets() bool {
959972
return c.Spec.Networking.AmazonVPC == nil &&
960973
c.Spec.Networking.Calico == nil &&

pkg/apis/kops/model/features.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ func UseChallengeCallback(cloudProvider kops.CloudProviderID) bool {
3939
// UseKopsControllerForNodeConfig checks if nodeup should use kops-controller to get nodeup.Config.
4040
func UseKopsControllerForNodeConfig(cluster *kops.Cluster) bool {
4141
if cluster.UsesLegacyGossip() {
42+
if cluster.UsesLoadBalancerForKopsController() {
43+
return true
44+
}
4245
switch cluster.GetCloudProvider() {
43-
case kops.CloudProviderGCE:
44-
// We can use cloud-discovery here.
4546
case kops.CloudProviderHetzner, kops.CloudProviderScaleway, kops.CloudProviderDO:
4647
// We don't have a cloud-discovery mechanism implemented in nodeup for many clouds,
4748
// but we assume that we're using a load balancer with a fixed IP address

pkg/model/gcemodel/api_loadbalancer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (b *APILoadBalancerBuilder) addFirewallRules(c *fi.CloudupModelBuilderConte
118118
})
119119
}
120120

121-
if b.Cluster.UsesNoneDNS() {
121+
if b.Cluster.UsesLoadBalancerForKopsController() {
122122
b.AddFirewallRulesTasks(c, "kops-controller", &gcetasks.FirewallRule{
123123
Lifecycle: b.Lifecycle,
124124
Network: network,
@@ -211,7 +211,7 @@ func (b *APILoadBalancerBuilder) createInternalLB(c *fi.CloudupModelBuilderConte
211211
"name": "api-" + sn.Name,
212212
},
213213
})
214-
if b.Cluster.UsesNoneDNS() {
214+
if b.Cluster.UsesLoadBalancerForKopsController() {
215215
ipAddress.WellKnownServices = append(ipAddress.WellKnownServices, wellknownservices.KopsController)
216216

217217
fr := &gcetasks.ForwardingRule{

pkg/nodemodel/nodeupconfigbuilder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ func (n *nodeUpConfigBuilder) BuildConfig(ig *kops.InstanceGroup, wellKnownAddre
379379
controlPlaneIPs = append(controlPlaneIPs, wellKnownAddresses[wellknownservices.KubeAPIServer]...)
380380
}
381381

382-
if cluster.UsesNoneDNS() {
382+
if cluster.UsesLoadBalancerForKopsController() {
383383
bootConfig.APIServerIPs = controlPlaneIPs
384384
} else {
385385
// If we do have a fixed IP, we use it (on some clouds, initially)

0 commit comments

Comments
 (0)