Commit 621dd36f authored by Miek Gieben's avatar Miek Gieben Committed by GitHub

plugin/kubernetes: set TTL on pod responses (#1239)

The TTL was still zero, instead it should adhere to the k.ttl setting.
Change this and update tests to match.
parent 99dd8f99
...@@ -15,14 +15,14 @@ var podModeInsecureCases = []test.Case{ ...@@ -15,14 +15,14 @@ var podModeInsecureCases = []test.Case{
Qname: "10-240-0-1.podns.pod.cluster.local.", Qtype: dns.TypeA, Qname: "10-240-0-1.podns.pod.cluster.local.", Qtype: dns.TypeA,
Rcode: dns.RcodeSuccess, Rcode: dns.RcodeSuccess,
Answer: []dns.RR{ Answer: []dns.RR{
test.A("10-240-0-1.podns.pod.cluster.local. 0 IN A 10.240.0.1"), test.A("10-240-0-1.podns.pod.cluster.local. 5 IN A 10.240.0.1"),
}, },
}, },
{ {
Qname: "172-0-0-2.podns.pod.cluster.local.", Qtype: dns.TypeA, Qname: "172-0-0-2.podns.pod.cluster.local.", Qtype: dns.TypeA,
Rcode: dns.RcodeSuccess, Rcode: dns.RcodeSuccess,
Answer: []dns.RR{ Answer: []dns.RR{
test.A("172-0-0-2.podns.pod.cluster.local. 0 IN A 172.0.0.2"), test.A("172-0-0-2.podns.pod.cluster.local. 5 IN A 172.0.0.2"),
}, },
}, },
} }
......
...@@ -15,7 +15,7 @@ var podModeVerifiedCases = []test.Case{ ...@@ -15,7 +15,7 @@ var podModeVerifiedCases = []test.Case{
Qname: "10-240-0-1.podns.pod.cluster.local.", Qtype: dns.TypeA, Qname: "10-240-0-1.podns.pod.cluster.local.", Qtype: dns.TypeA,
Rcode: dns.RcodeSuccess, Rcode: dns.RcodeSuccess,
Answer: []dns.RR{ Answer: []dns.RR{
test.A("10-240-0-1.podns.pod.cluster.local. 0 IN A 10.240.0.1"), test.A("10-240-0-1.podns.pod.cluster.local. 5 IN A 10.240.0.1"),
}, },
}, },
{ {
......
...@@ -320,7 +320,7 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service, ...@@ -320,7 +320,7 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
} }
if k.podMode == podModeInsecure { if k.podMode == podModeInsecure {
return []msg.Service{{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip}}, nil return []msg.Service{{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip, TTL: k.ttl}}, nil
} }
// PodModeVerified // PodModeVerified
...@@ -331,7 +331,7 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service, ...@@ -331,7 +331,7 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
} }
// check for matching ip and namespace // check for matching ip and namespace
if ip == p.Status.PodIP && match(namespace, p.Namespace) { if ip == p.Status.PodIP && match(namespace, p.Namespace) {
s := msg.Service{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip} s := msg.Service{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip, TTL: k.ttl}
pods = append(pods, s) pods = append(pods, s)
err = nil err = nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment