From ef85e292868f294735a9c939d5075d9c4a3fa073 Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Sat, 7 Oct 2023 14:26:08 +0300 Subject: [PATCH 1/2] Use dns=none for newly created clusters except for AWS and GCE --- cmd/kops/create_cluster.go | 1 - upup/pkg/fi/cloudup/new_cluster.go | 21 ++++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cmd/kops/create_cluster.go b/cmd/kops/create_cluster.go index eb923619abf7e..b3475af67d370 100644 --- a/cmd/kops/create_cluster.go +++ b/cmd/kops/create_cluster.go @@ -68,7 +68,6 @@ type CreateClusterOptions struct { ContainerRuntime string OutDir string DisableSubnetTags bool - DNSZone string NodeSecurityGroups []string ControlPlaneSecurityGroups []string AssociatePublicIP *bool diff --git a/upup/pkg/fi/cloudup/new_cluster.go b/upup/pkg/fi/cloudup/new_cluster.go index 24d549bd8b511..d9c68e18b53ce 100644 --- a/upup/pkg/fi/cloudup/new_cluster.go +++ b/upup/pkg/fi/cloudup/new_cluster.go @@ -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 @@ -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 From 4632188467ce727ae5948aef0e742a61a41e3faa Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Sat, 7 Oct 2023 14:26:20 +0300 Subject: [PATCH 2/2] hack/update-expected.sh --- tests/integration/create_cluster/different-amis/options.yaml | 1 + .../create_cluster/ha_openstack/expected-v1alpha2.yaml | 2 +- .../create_cluster/ha_openstack_octavia/expected-v1alpha2.yaml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/integration/create_cluster/different-amis/options.yaml b/tests/integration/create_cluster/different-amis/options.yaml index 6b93c8a710d1f..e45e533cb743d 100644 --- a/tests/integration/create_cluster/different-amis/options.yaml +++ b/tests/integration/create_cluster/different-amis/options.yaml @@ -9,4 +9,5 @@ ControlPlaneImage: ami-control-plane NodeImage: ami-worker-image Bastion: true Topology: private +DNSType: public APIServerCount: 1 \ No newline at end of file diff --git a/tests/integration/create_cluster/ha_openstack/expected-v1alpha2.yaml b/tests/integration/create_cluster/ha_openstack/expected-v1alpha2.yaml index d800b43700413..ceaf1bec5116a 100644 --- a/tests/integration/create_cluster/ha_openstack/expected-v1alpha2.yaml +++ b/tests/integration/create_cluster/ha_openstack/expected-v1alpha2.yaml @@ -74,7 +74,7 @@ spec: zone: us-test1 topology: dns: - type: Private + type: None --- diff --git a/tests/integration/create_cluster/ha_openstack_octavia/expected-v1alpha2.yaml b/tests/integration/create_cluster/ha_openstack_octavia/expected-v1alpha2.yaml index 0aefe03ea109e..96a2fdc856b85 100644 --- a/tests/integration/create_cluster/ha_openstack_octavia/expected-v1alpha2.yaml +++ b/tests/integration/create_cluster/ha_openstack_octavia/expected-v1alpha2.yaml @@ -84,7 +84,7 @@ spec: zone: us-test1 topology: dns: - type: Private + type: None ---