Skip to content

[breaking] deprecate dnsZone and edgeDnsZone chart values #1876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions chart/k8gb/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,9 @@ k8gb-{{ index (split ":" (index (split ";" (include "k8gb.dnsZonesString" .)) "_
{{- $entries := list -}}
{{- range .Values.k8gb.dnsZones }}
{{- $dnsZoneNegTTL := toString (.dnsZoneNegTTL | default "300") }}
{{- $entry := printf "%s:%s:%s" .zone .domain $dnsZoneNegTTL }}
{{- $entry := printf "%s:%s:%s" .parentZone .loadBalancedZone $dnsZoneNegTTL }}
{{- $entries = append $entries $entry }}
{{- end }}
{{- if and (or (not .Values.k8gb.dnsZones) (eq (len .Values.k8gb.dnsZones) 0)) .Values.k8gb.dnsZone .Values.k8gb.edgeDNSZone }}
{{- $extraEntry := printf "%s:%s:%s" .Values.k8gb.edgeDNSZone .Values.k8gb.dnsZone "300" }}
{{- $entries = append $entries $extraEntry }}
{{- end }}
{{- join ";" $entries }}
{{- end }}

Expand Down
23 changes: 10 additions & 13 deletions chart/k8gb/templates/_validators.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,28 @@
{{- end -}}
{{- end -}}

# Validates that the zones in k8gb.edgeDNSZone/k8gb.dnsZones match the zones in extdns.domainFilters
# Validates that the zones in k8gb.dnsZones match the zones in extdns.domainFilters
{{- define "validateDnsZones" -}}
{{- $k8gbZones := list -}}
{{- $parentZones := list -}}
{{- range .Values.k8gb.dnsZones -}}
{{- $k8gbZones = append $k8gbZones .zone -}}
{{- $parentZones = append $parentZones .parentZone -}}
{{- end -}}
{{- if and (or (not .Values.k8gb.dnsZones) (eq (len .Values.k8gb.dnsZones) 0)) .Values.k8gb.dnsZone .Values.k8gb.edgeDNSZone }}
{{- $k8gbZones = append $k8gbZones .Values.k8gb.edgeDNSZone -}}
{{- end }}

{{- $extdnsZones := .Values.extdns.domainFilters -}}

{{- if ne (len $k8gbZones) (len $extdnsZones) -}}
{{- fail (printf "Validation failed: Number of zones in k8gb.edgeDNSZone/k8gb.dnsZones (%d) does not match number of domains in extdns.domainFilters (%d)" (len $k8gbZones) (len $extdnsZones)) -}}
{{- if ne (len $parentZones) (len $extdnsZones) -}}
{{- fail (printf "Validation failed: Number of zones in k8gb.dnsZones (%d) does not match number of domains in extdns.domainFilters (%d)" (len $parentZones) (len $extdnsZones)) -}}
{{- end -}}

{{- range $k8gbZone := $k8gbZones -}}
{{- if not (has $k8gbZone $extdnsZones) -}}
{{- fail (printf "Validation failed: Zone '%s' from k8gb.edgeDNSZone/k8gb.dnsZones is not present in extdns.domainFilters" $k8gbZone) -}}
{{- range $parentZone := $parentZones -}}
{{- if not (has $parentZone $extdnsZones) -}}
{{- fail (printf "Validation failed: Zone '%s' from k8gb.dnsZones is not present in extdns.domainFilters" $parentZone) -}}
{{- end -}}
{{- end -}}

{{- range $extdnsZone := $extdnsZones -}}
{{- if not (has $extdnsZone $k8gbZones) -}}
{{- fail (printf "Validation failed: Domain '%s' from extdns.domainFilters is not present in k8gb.edgeDNSZone/k8gb.dnsZones" $extdnsZone) -}}
{{- if not (has $extdnsZone $parentZones) -}}
{{- fail (printf "Validation failed: Domain '%s' from extdns.domainFilters is not present in k8gb.dnsZones" $extdnsZone) -}}
{{- end -}}
{{- end -}}

Expand Down
4 changes: 2 additions & 2 deletions chart/k8gb/templates/coredns/cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ data:
{{- $dnsZones := split ";" $dnsZonesRaw }}
{{- range $dnsZones }}
{{- $parts := split ":" . }}
{{- $domain := index $parts "_1" }}
{{- $loadBalancedZone := index $parts "_1" }}
{{- $dnsZoneNegTTL := index $parts "_2" }}
{{ $domain }}:5353 {
{{ $loadBalancedZone }}:5353 {
errors
health
{{- if $.Values.k8gb.coredns.extra_plugins }}
Expand Down
4 changes: 2 additions & 2 deletions chart/k8gb/templates/external-dns/external-dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ spec:
{{- $dnsZones := split ";" $dnsZonesRaw }}
{{- range $dnsZones }}
{{- $parts := split ":" . }}
{{- $zone := index $parts "_0" }}
- --domain-filter={{ $zone }} # will make ExternalDNS see only the hosted zones matching provided domain, omit to process all available hosted zones
{{- $parentZone := index $parts "_0" }}
- --domain-filter={{ $parentZone }} # will make ExternalDNS see only the hosted zones matching provided domain, omit to process all available hosted zones
{{- end }}
- --policy=sync # enable full synchronization including record removal
- --log-level=debug # debug only
Expand Down
4 changes: 2 additions & 2 deletions chart/k8gb/values-extdns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ k8gb:
clusterGeoTag: "us"
extGslbClustersGeoTags: "eu"
dnsZones:
- zone: "k8gb.io"
domain: "cloud.k8gb.io"
- parentZone: "k8gb.io"
loadBalancedZone: "cloud.k8gb.io"
dnsZoneNegTTL: 30

extdns:
Expand Down
43 changes: 9 additions & 34 deletions chart/k8gb/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,6 @@
"$ref": "#/definitions/k8gbDnsZone"
}
},
"dnsZone": {
"format": "idn-hostname",
"minLength": 1
},
"dnsZoneNegTTL": {
"type": "integer",
"minimum": 0
},
"edgeDNSZone": {
"format": "idn-hostname",
"minLength": 1
},
"edgeDNSServers": {
"type": "array",
"items": {
Expand Down Expand Up @@ -345,24 +333,11 @@
"type": "object"
}
},
"oneOf": [
{
"required": [
"clusterGeoTag",
"extGslbClustersGeoTags",
"edgeDNSServers",
"dnsZone",
"edgeDNSZone"
]
},
{
"required": [
"clusterGeoTag",
"extGslbClustersGeoTags",
"edgeDNSServers",
"dnsZones"
]
}
"required": [
"clusterGeoTag",
"extGslbClustersGeoTags",
"edgeDNSServers",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to change this terminology too to be consistent

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch
36382b7

"dnsZones"
],
"title": "k8gb"
},
Expand Down Expand Up @@ -447,11 +422,11 @@
"k8gbDnsZone": {
"type": "object",
"properties": {
"zone": {
"loadBalancedZone": {
"type": "string",
"format": "idn-hostname"
},
"domain": {
"parentZone": {
"type": "string",
"format": "idn-hostname"
},
Expand All @@ -462,8 +437,8 @@
}
},
"required": [
"zone",
"domain"
"loadBalancedZone",
"parentZone"
]
},
"Ns1": {
Expand Down
13 changes: 3 additions & 10 deletions chart/k8gb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@ k8gb:
# DNSZones - For backward compatibility, the dnsZone and edgeDNSZone fields are allowed; otherwise,
# the dnsZones array is used. For valid values, use either dnsZone and edgeDNSZone or dnsZones.
#
# -- dnsZone: deprecated
# dnsZone: "cloud.example.com"
# -- edgeDNSZone: deprecated
# edgeDNSZone: "example.com"
# -- array of dns zones controlled by gslb§
# -- array of dns zones controlled by gslb
dnsZones:
- zone: "example.com" # -- main zone which would contain gslb zone to delegate (same meaning as to edgeDNSZone)
domain: "cloud.example.com" # -- domain controlled by gslb (same meaning as to dnsZone)
- parentZone: "example.com" # -- parent zone which would contain gslb zone to delegate (same meaning as the old edgeDNSZone)
loadBalancedZone: "cloud.example.com" # -- zone controlled by gslb (same meaning as the old dnsZone)
dnsZoneNegTTL: 30 # -- Negative TTL for SOA record# -- host/ip[:port] format is supported here where port defaults to 53
# - zone: "example.org" # -- main zone which would contain gslb zone to delegate (same meaning as to edgeDNSZone)
# domain: "cloud.example.org" # -- domain controlled by gslb (same meaning as to dnsZone)
# dnsZoneNegTTL: 50 # -- Negative TTL for SOA record# -- host/ip[:port] format is supported here where port defaults to 53
edgeDNSServers:
# -- use this DNS server as a main resolver to enable cross k8gb DNS based communication
- "1.1.1.1"
Expand Down
8 changes: 4 additions & 4 deletions controllers/depresolver/depresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ type Config struct {
extClustersGeoTags []string `env:"EXT_GSLB_CLUSTERS_GEO_TAGS, default=[]"`
// EdgeDNSType is READONLY and is set automatically by configuration
EdgeDNSType EdgeDNSType
// EdgeDNSServers
EdgeDNSServers utils.DNSList
// to avoid breaking changes is used as fallback server for EdgeDNSServers
// ParentZoneDNSServers
ParentZoneDNSServers utils.DNSList
// to avoid breaking changes is used as fallback server for ParentZoneDNSServers
fallbackEdgeDNSServerName string `env:"EDGE_DNS_SERVER"`
// to avoid breaking changes is used as fallback server port for EdgeDNSServers
// to avoid breaking changes is used as fallback server port for ParentZoneDNSServers
fallbackEdgeDNSServerPort int `env:"EDGE_DNS_SERVER_PORT, default=53"`
// DelegationZones
DelegationZones DelegationZones
Expand Down
24 changes: 12 additions & 12 deletions controllers/depresolver/depresolver_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const (
CoreDNSServiceTypeKey = "COREDNS_SERVICE_TYPE"
ExtClustersGeoTagsKey = "EXT_GSLB_CLUSTERS_GEO_TAGS"
ExtDNSEnabledKey = "EXTDNS_ENABLED"
EdgeDNSServersKey = "EDGE_DNS_SERVERS"
ParentZoneDNSServersKey = "EDGE_DNS_SERVERS"
DNSZonesKey = "DNS_ZONES"
InfobloxGridHostKey = "INFOBLOX_GRID_HOST"
InfobloxVersionKey = "INFOBLOX_WAPI_VERSION"
Expand Down Expand Up @@ -95,8 +95,8 @@ func (dr *DependencyResolver) ResolveOperatorConfig() (*Config, error) {

// calculation
fallbackDNS := fmt.Sprintf("%s:%v", dr.config.fallbackEdgeDNSServerName, dr.config.fallbackEdgeDNSServerPort)
edgeDNSServerList := env.GetEnvAsArrayOfStringsOrFallback(EdgeDNSServersKey, []string{fallbackDNS})
dr.config.EdgeDNSServers = parseEdgeDNSServers(edgeDNSServerList)
edgeDNSServerList := env.GetEnvAsArrayOfStringsOrFallback(ParentZoneDNSServersKey, []string{fallbackDNS})
dr.config.ParentZoneDNSServers = parseParentZoneDNSServers(edgeDNSServerList)
dr.config.extClustersGeoTags = excludeGeoTag(dr.config.extClustersGeoTags, dr.config.ClusterGeoTag)
dr.config.Log.Level, _ = zerolog.ParseLevel(strings.ToLower(dr.config.Log.level))
dr.config.Log.Format = parseLogOutputFormat(strings.ToLower(dr.config.Log.format))
Expand Down Expand Up @@ -151,23 +151,23 @@ func (dr *DependencyResolver) validateConfig(config *Config, recognizedDNSTypes
return err
}
}
err = field(EdgeDNSServersKey, os.Getenv(EdgeDNSServersKey)).isNotEmpty().matchRegexp(hostNamesWithPortsRegex1).err
err = field(ParentZoneDNSServersKey, os.Getenv(ParentZoneDNSServersKey)).isNotEmpty().matchRegexp(hostNamesWithPortsRegex1).err
if err != nil {
return err
}
err = field(EdgeDNSServersKey, os.Getenv(EdgeDNSServersKey)).isNotEmpty().matchRegexp(hostNamesWithPortsRegex2).err
err = field(ParentZoneDNSServersKey, os.Getenv(ParentZoneDNSServersKey)).isNotEmpty().matchRegexp(hostNamesWithPortsRegex2).err
if err != nil {
return err
}
err = validateLocalhostNotAmongDNSServers(config)
if err != nil {
return err
}
err = field(EdgeDNSServersKey, config.EdgeDNSServers).isNotEmpty().matchRegexp(hostNamesWithPortsRegex1).err
err = field(ParentZoneDNSServersKey, config.ParentZoneDNSServers).isNotEmpty().matchRegexp(hostNamesWithPortsRegex1).err
if err != nil {
return err
}
for _, s := range config.EdgeDNSServers {
for _, s := range config.ParentZoneDNSServers {
if s.Port < 1 || s.Port > 65535 {
return fmt.Errorf("error for port of edge dns server(%v): it must be a positive integer between 1 and 65535", s)
}
Expand Down Expand Up @@ -205,8 +205,8 @@ func validateLocalhostNotAmongDNSServers(config *Config) error {
}
return false
}
if len(config.EdgeDNSServers) > 1 && containsLocalhost(config.EdgeDNSServers) {
return fmt.Errorf("invalid %s: the list can't contain 'localhost' or '127.0.0.1' on other than the first position", EdgeDNSServersKey)
if len(config.ParentZoneDNSServers) > 1 && containsLocalhost(config.ParentZoneDNSServers) {
return fmt.Errorf("invalid %s: the list can't contain 'localhost' or '127.0.0.1' on other than the first position", ParentZoneDNSServersKey)
}
return nil
}
Expand Down Expand Up @@ -252,11 +252,11 @@ func (dr *DependencyResolver) GetDeprecations() (deprecations []string) {

var deprecated = map[oldVar]newVar{
EdgeDNSServerKey: newVar{
Name: EdgeDNSServersKey,
Name: ParentZoneDNSServersKey,
Msg: "Pass the hostname or IP address as comma-separated list",
},
EdgeDNSServerPortKey: newVar{
Name: EdgeDNSServersKey,
Name: ParentZoneDNSServersKey,
Msg: "Port is an optional item in the comma-separated list of dns edge servers, in following form: dns1:53,dns2 (if not provided after the " +
"hostname and colon, it defaults to '53')",
},
Expand All @@ -281,7 +281,7 @@ func parseMetricsAddr(metricsAddr string) (host string, port int, err error) {
return
}

func parseEdgeDNSServers(serverList []string) (r []utils.DNSServer) {
func parseParentZoneDNSServers(serverList []string) (r []utils.DNSServer) {
r = []utils.DNSServer{}
var host, portStr string
var err error
Expand Down
39 changes: 22 additions & 17 deletions controllers/depresolver/depresolver_domaininfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
type DelegationZones []*DelegationZoneInfo

type DelegationZoneInfo struct {
Domain string // cloud.example.com
Zone string // example.com
LoadBalancedZone string // cloud.example.com
ParentZone string // example.com
NegativeTTL int
ClusterNSName string
ExtClusterNSNames map[string]string
Expand All @@ -39,18 +39,18 @@ type DelegationZoneInfo struct {

func parseDelegationZones(config *Config) ([]*DelegationZoneInfo, error) {
type info struct {
domain string
zone string
negTTL string
loadBalancedZone string
parentZone string
negTTL string
}

zones := config.dnsZones

getNsName := func(tag, zone, edge string) string {
getNsName := func(tag, zone, parentZone string) string {
const prefix = "gslb-ns"
d := strings.TrimSuffix(zone, "."+edge)
d := strings.TrimSuffix(zone, "."+parentZone)
domainX := strings.ReplaceAll(d, ".", "-")
return fmt.Sprintf("%s-%s-%s.%s", prefix, tag, domainX, edge)
return fmt.Sprintf("%s-%s-%s.%s", prefix, tag, domainX, parentZone)
}

validateRFC1035 := func(zoneInfo *DelegationZoneInfo) error {
Expand Down Expand Up @@ -79,7 +79,12 @@ func parseDelegationZones(config *Config) ([]*DelegationZoneInfo, error) {
if len(touple) != 3 {
return tuples, fmt.Errorf("invalid format of delegation zones: %s", z)
}
tuples = append(tuples, info{zone: strings.Trim(touple[0], " "), domain: strings.Trim(touple[1], " "), negTTL: strings.Trim(touple[2], " ")})
tuples = append(tuples,
info{
parentZone: strings.Trim(touple[0], " "),
loadBalancedZone: strings.Trim(touple[1], " "),
negTTL: strings.Trim(touple[2], " "),
})
}
return tuples, nil
}
Expand All @@ -96,17 +101,17 @@ func parseDelegationZones(config *Config) ([]*DelegationZoneInfo, error) {
return dzi, fmt.Errorf("invalid value of delegation zones: %s", zones)
}
zoneInfo := &DelegationZoneInfo{
Domain: inf.domain,
Zone: inf.zone,
NegativeTTL: negTTL,
ClusterNSName: getNsName(config.ClusterGeoTag, inf.domain, inf.zone),
LoadBalancedZone: inf.loadBalancedZone,
ParentZone: inf.parentZone,
NegativeTTL: negTTL,
ClusterNSName: getNsName(config.ClusterGeoTag, inf.loadBalancedZone, inf.parentZone),
ExtClusterNSNames: func(zone, edge string) map[string]string {
m := map[string]string{}
for _, tag := range config.extClustersGeoTags {
m[tag] = getNsName(tag, zone, edge)
}
return m
}(inf.domain, inf.zone),
}(inf.loadBalancedZone, inf.parentZone),
}
dzi = append(dzi, zoneInfo)
}
Expand All @@ -132,7 +137,7 @@ func (z *DelegationZoneInfo) GetNSServerList() []string {

// GetExternalDNSEndpointName returns name of endpoint sitting in k8gb namespace
func (z *DelegationZoneInfo) GetExternalDNSEndpointName() string {
var suffix = strings.Trim(strings.ReplaceAll(z.Domain, ".", "-"), " ")
var suffix = strings.Trim(strings.ReplaceAll(z.LoadBalancedZone, ".", "-"), " ")
return fmt.Sprintf("k8gb-ns-extdns-%s", suffix)
}

Expand Down Expand Up @@ -167,14 +172,14 @@ func (d *DelegationZones) ContainsZone(host string) bool {
func (d *DelegationZones) ListZones() []string {
var zones []string
for _, z := range *d {
zones = append(zones, z.Zone)
zones = append(zones, z.LoadBalancedZone)
}
return zones
}

func (d *DelegationZones) getZone(host string) *DelegationZoneInfo {
for _, z := range *d {
if strings.Contains(host, z.Zone) {
if strings.Contains(host, z.LoadBalancedZone) {
return z
}
}
Expand Down
Loading
Loading