plugin/kubernetes: Add support for dual stack ClusterIP Services (#4339)
* support dual stack clusterIPs Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * stickler Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * fix ClusterIPs make Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
parent
302434e392
commit
51c05679e6
14 changed files with 204 additions and 111 deletions
|
@ -433,8 +433,7 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
|
|||
|
||||
// If "ignore empty_service" option is set and no endpoints exist, return NXDOMAIN unless
|
||||
// it's a headless or externalName service (covered below).
|
||||
if k.opts.ignoreEmptyService && svc.ClusterIP != api.ClusterIPNone && svc.Type != api.ServiceTypeExternalName {
|
||||
// serve NXDOMAIN if no endpoint is able to answer
|
||||
if k.opts.ignoreEmptyService && svc.Type != api.ServiceTypeExternalName && !svc.Headless() { // serve NXDOMAIN if no endpoint is able to answer
|
||||
podsCount := 0
|
||||
for _, ep := range endpointsListFunc() {
|
||||
for _, eps := range ep.Subsets {
|
||||
|
@ -447,8 +446,20 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
|
|||
}
|
||||
}
|
||||
|
||||
// External service
|
||||
if svc.Type == api.ServiceTypeExternalName {
|
||||
s := msg.Service{Key: strings.Join([]string{zonePath, Svc, svc.Namespace, svc.Name}, "/"), Host: svc.ExternalName, TTL: k.ttl}
|
||||
if t, _ := s.HostType(); t == dns.TypeCNAME {
|
||||
s.Key = strings.Join([]string{zonePath, Svc, svc.Namespace, svc.Name}, "/")
|
||||
services = append(services, s)
|
||||
|
||||
err = nil
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Endpoint query or headless service
|
||||
if svc.ClusterIP == api.ClusterIPNone || r.endpoint != "" {
|
||||
if svc.Headless() || r.endpoint != "" {
|
||||
if endpointsList == nil {
|
||||
endpointsList = endpointsListFunc()
|
||||
}
|
||||
|
@ -485,18 +496,6 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
|
|||
continue
|
||||
}
|
||||
|
||||
// External service
|
||||
if svc.Type == api.ServiceTypeExternalName {
|
||||
s := msg.Service{Key: strings.Join([]string{zonePath, Svc, svc.Namespace, svc.Name}, "/"), Host: svc.ExternalName, TTL: k.ttl}
|
||||
if t, _ := s.HostType(); t == dns.TypeCNAME {
|
||||
s.Key = strings.Join([]string{zonePath, Svc, svc.Namespace, svc.Name}, "/")
|
||||
services = append(services, s)
|
||||
|
||||
err = nil
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// ClusterIP service
|
||||
for _, p := range svc.Ports {
|
||||
if !(match(r.port, p.Name) && match(r.protocol, string(p.Protocol))) {
|
||||
|
@ -505,10 +504,11 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
|
|||
|
||||
err = nil
|
||||
|
||||
s := msg.Service{Host: svc.ClusterIP, Port: int(p.Port), TTL: k.ttl}
|
||||
s.Key = strings.Join([]string{zonePath, Svc, svc.Namespace, svc.Name}, "/")
|
||||
|
||||
services = append(services, s)
|
||||
for _, ip := range svc.ClusterIPs {
|
||||
s := msg.Service{Host: ip, Port: int(p.Port), TTL: k.ttl}
|
||||
s.Key = strings.Join([]string{zonePath, Svc, svc.Namespace, svc.Name}, "/")
|
||||
services = append(services, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
return services, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue