Use dns=none for newly created clusters except for AWS and GCE

This commit is contained in:
Ciprian Hacman 2023-10-07 14:26:08 +03:00
parent d2b789da07
commit ef85e29286
2 changed files with 12 additions and 10 deletions

View File

@ -68,7 +68,6 @@ type CreateClusterOptions struct {
ContainerRuntime string
OutDir string
DisableSubnetTags bool
DNSZone string
NodeSecurityGroups []string
ControlPlaneSecurityGroups []string
AssociatePublicIP *bool

View File

@ -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