Skip to content

Commit

Permalink
Use dns=none for newly created clusters except for AWS and GCE
Browse files Browse the repository at this point in the history
  • Loading branch information
hakman committed Oct 7, 2023
1 parent d2b789d commit ef85e29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 0 additions & 1 deletion cmd/kops/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ type CreateClusterOptions struct {
ContainerRuntime string
OutDir string
DisableSubnetTags bool
DNSZone string
NodeSecurityGroups []string
ControlPlaneSecurityGroups []string
AssociatePublicIP *bool
Expand Down
21 changes: 12 additions & 9 deletions upup/pkg/fi/cloudup/new_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ type NewClusterOptions struct {
Topology string
// DNSType is the DNS type to use; "public" or "private". Defaults to "public".
DNSType string
// DNSZone is the DNS zone to use.
DNSZone string

// APILoadBalancerClass determines whether to use classic or network load balancers for the API
APILoadBalancerClass string
Expand Down Expand Up @@ -1376,16 +1378,17 @@ func setupTopology(opt *NewClusterOptions, cluster *api.Cluster, allZones sets.S
func setupDNSTopology(opt *NewClusterOptions, cluster *api.Cluster) error {
switch strings.ToLower(opt.DNSType) {
case "":
switch cluster.Spec.GetCloudProvider() {
case api.CloudProviderHetzner, api.CloudProviderDO, api.CloudProviderAzure:
// Use dns=none if not specified
if opt.DNSZone != "" {
// Use dns=public if zone is specified
cluster.Spec.Networking.Topology.DNS = api.DNSTypePublic
} else if cluster.UsesLegacyGossip() {
// Use dns=none if .k8s.local is specified instead of Gossip
klog.Warningf("Gossip is deprecated, using None DNS instead")
cluster.Spec.Networking.Topology.DNS = api.DNSTypeNone
} else if cluster.Spec.GetCloudProvider() == api.CloudProviderAWS || cluster.Spec.GetCloudProvider() == api.CloudProviderGCE {
cluster.Spec.Networking.Topology.DNS = api.DNSTypePublic
} else {
cluster.Spec.Networking.Topology.DNS = api.DNSTypeNone
default:
if cluster.UsesLegacyGossip() {
cluster.Spec.Networking.Topology.DNS = api.DNSTypePrivate
} else {
cluster.Spec.Networking.Topology.DNS = api.DNSTypePublic
}
}
case "public":
cluster.Spec.Networking.Topology.DNS = api.DNSTypePublic
Expand Down

0 comments on commit ef85e29

Please sign in to comment.