-
Notifications
You must be signed in to change notification settings - Fork 19
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
add dns caching #64
add dns caching #64
Conversation
1833460
to
20eff25
Compare
oh no |
/hold |
9f91d60
to
4ba36e7
Compare
func (d *DNSCacheAgent) lookupIP(ctx context.Context, network, host string) ([]net.IP, error) { | ||
ips, ok := d.cache.get(network, host, expireTimeout) | ||
if ok { | ||
klog.V(4).Infof("Cached entries for %s %s : %v", network, host, ips) | ||
return ips, nil | ||
} | ||
ips, err := d.resolver.LookupIP(ctx, network, host) | ||
if err != nil { | ||
// cache empty answers | ||
if e, ok := err.(*net.DNSError); !ok || !e.IsNotFound { | ||
return nil, err | ||
} | ||
} | ||
d.cache.add(network, host, ips) | ||
klog.V(4).Infof("Caching new entries for %s %s : %v", network, host, ips) | ||
return ips, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the important thing to solve:
- cache agent has the pod parameters ndots and searches (it is deployed as a hostnetwork pod with dnsPoliyc: ClusterFirstWithHostNet)
- when pod ask for
kubernetes.default
the resolver on the pod will append allsearches
until the number ofndots
I0913 09:47:13.869272 1 dnscache.go:249] UDP connection from 100.96.1.14:59154
I0913 09:47:13.869338 1 dnscache.go:283] dialing from 100.64.0.10:53 to 100.96.1.14:59154
I0913 09:47:13.869435 1 dnscache.go:444] starting parsing packet
I0913 09:47:13.869469 1 dnscache.go:559] DNS A request for kubernetes.default.default.svc.cluster.local.
I0913 09:47:13.869484 1 dnscache.go:658] Cached entries for ip4 kubernetes.default.default.svc.cluster.local. : []
I0913 09:47:13.869498 1 dnscache.go:496] answer correct
I0913 09:47:13.870417 1 dnscache.go:249] UDP connection from 100.96.1.14:52573
I0913 09:47:13.870465 1 dnscache.go:283] dialing from 100.64.0.10:53 to 100.96.1.14:52573
I0913 09:47:13.870550 1 dnscache.go:444] starting parsing packet
I0913 09:47:13.870578 1 dnscache.go:559] DNS A request for kubernetes.default.svc.cluster.local.
I0913 09:47:13.871531 1 dnscache.go:669] Caching new entries for ip4 kubernetes.default.svc.cluster.local. : [100.64.0.1]
I0913 09:47:13.871627 1 dnscache.go:568] DNS A request for kubernetes.default.svc.cluster.local. ips: [100.64.0.1]
I0913 09:47:13.871640 1 dnscache.go:496] answer correct
I0913 09:47:13.874943 1 dnscache.go:249] UDP connection from 100.96.1.14:55191
I0913 09:47:13.874996 1 dnscache.go:283] dialing from 100.64.0.10:53 to 100.96.1.14:55191
I0913 09:47:13.875084 1 dnscache.go:444] starting parsing packet
I0913 09:47:13.875150 1 dnscache.go:589] DNS AAAA request for kubernetes.default.svc.cluster.local.
I0913 09:47:13.876114 1 dnscache.go:669] Caching new entries for ip6 kubernetes.default.svc.cluster.local. : []
I0913 09:47:13.876212 1 dnscache.go:496] answer correct
This means that the cache CAN know the original question of the pod and can deduplicate all these queries to answer on the first query ... this will be a big improvement since it will allow to remove all the amplification added by searches
@thockin
bff7c81
to
18da2f0
Compare
Change-Id: If90379e54b08ffab3c909b889e9dd532931aaf3e
Pass through cache for A and AAAA records with ttl 30 seconds
Only captures Pods requests
TODO: