Skip to content

Commit

Permalink
Merge 94fd35b into 0b91e4a
Browse files Browse the repository at this point in the history
  • Loading branch information
rbtr committed Dec 13, 2019
2 parents 0b91e4a + 94fd35b commit b548e70
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions source/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (sc *serviceSource) extractHeadlessEndpoints(svc *v1.Service, hostname stri
}
} else {
log.Debugf("Generating matching endpoint %s with PodIP %s", headlessDomain, v.Status.PodIP)
// To reduce traffice on the DNS API only add record for running Pods. Good Idea?
// To reduce traffic on the DNS API only add record for running Pods. Good Idea?
if v.Status.Phase == v1.PodRunning {
targetsByHeadlessDomain[headlessDomain] = append(targetsByHeadlessDomain[headlessDomain], v.Status.PodIP)
} else {
Expand Down Expand Up @@ -507,10 +507,16 @@ func (sc *serviceSource) extractNodePortTargets(svc *v1.Service) (endpoint.Targe
}
}

access := getAccessFromAnnotations(svc.Annotations)
if access == "public" {
return externalIPs, nil
}
if access == "private" {
return internalIPs, nil
}
if len(externalIPs) > 0 {
return externalIPs, nil
}

return internalIPs, nil
}

Expand Down
7 changes: 7 additions & 0 deletions source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const (
controllerAnnotationKey = "external-dns.alpha.kubernetes.io/controller"
// The annotation used for defining the desired hostname
hostnameAnnotationKey = "external-dns.alpha.kubernetes.io/hostname"
// The annotation used for specifying whether the public or private interface address is used
accessAnnotationKey = "external-dns.alpha.kubernetes.io/access"
// The annotation used for defining the desired ingress target
targetAnnotationKey = "external-dns.alpha.kubernetes.io/target"
// The annotation used for defining the desired DNS record TTL
Expand Down Expand Up @@ -83,6 +85,11 @@ func getHostnamesFromAnnotations(annotations map[string]string) []string {
return strings.Split(strings.Replace(hostnameAnnotation, " ", "", -1), ",")
}

func getAccessFromAnnotations(annotations map[string]string) string {
accessAnnotation, _ := annotations[accessAnnotationKey]
return accessAnnotation
}

func getAliasFromAnnotations(annotations map[string]string) bool {
aliasAnnotation, exists := annotations[aliasAnnotationKey]
return exists && aliasAnnotation == "true"
Expand Down

0 comments on commit b548e70

Please sign in to comment.