Skip to content

Commit

Permalink
WIP: kindnet + ipalias
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsb committed Jan 14, 2025
1 parent 2b133b2 commit cf70ea6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 2 additions & 3 deletions pkg/model/components/gcpcloudcontrollermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ func (b *GCPCloudControllerManagerOptionsBuilder) BuildOptions(cluster *kops.Clu
ccmConfig.ClusterCIDR = clusterSpec.Networking.PodCIDR
}

if clusterSpec.Networking.GCP != nil {
// "GCP" networking mode is called "ip-alias" or "vpc-native" on GKE.
// We don't need to configure routes if we are using "real" IPs.
if gce.UsesIPAliases(cluster) {
// We don't need to configure routes if we are using ipalias; these are "real" IPs
ccmConfig.ConfigureCloudRoutes = fi.PtrTo(false)
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/model/components/kubecontrollermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o *kops.Cluster) erro
} else {
kcm.CIDRAllocatorType = fi.PtrTo("CloudAllocator")
}
} else if networking.Kindnet != nil {
// We don't expect KCM to configure routes; it should be done by the CCM (or by the infrastructure)
kcm.ConfigureCloudRoutes = fi.PtrTo(false)

// If the cloud is allocating the node CIDRs, that should be done by CCM
if o.GetCloudProvider() == kops.CloudProviderGCE && gce.UsesIPAliases(o) {
kcm.AllocateNodeCIDRs = fi.PtrTo(false)
}
} else if networking.External != nil {
kcm.ConfigureCloudRoutes = fi.PtrTo(false)
} else if UsesCNI(networking) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/gcemodel/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (c *GCEModelContext) NameForFirewallRule(id string) string {
}

func (c *GCEModelContext) NetworkingIsIPAlias() bool {
return c.Cluster.Spec.Networking.GCP != nil
return gce.UsesIPAliases(c.Cluster)
}

func (c *GCEModelContext) NetworkingIsGCERoutes() bool {
Expand Down
7 changes: 7 additions & 0 deletions upup/pkg/fi/cloudup/gce/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ import (

// UsesIPAliases checks if the cluster uses IP aliases for network connectivity
func UsesIPAliases(c *kops.Cluster) bool {
// "GCP" networking mode is called "ip-alias" or "vpc-native" on GKE.
if c.Spec.Networking.GCP != nil {
return true
}

if c.Spec.Networking.Kindnet != nil {
// TODO: Are we _always_ using ipalias - should we at least check the cloud is GCP?
return true
}

return false
}

Expand Down

0 comments on commit cf70ea6

Please sign in to comment.