问题描述
我想增加来自群集内部流量的缓存限制。例如,如果从nginx容器内部,如果我确实挖掘到nginx-service,则TTL应该是不同的;如果我确实是挖掘到google.com,则它一定是不同的。有什么可能的方法可以实现这一目标? 预先感谢。
解决方法
在coreDNS Corefile的kubernetes插件部分中,您可以设置TTL来设置响应的自定义TTL。默认值为5秒。允许的最小TTL为0秒,最大为3600秒。将TTL设置为0将防止记录被缓存。
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
data:
Corefile: |
.:53 {
errors
health {
lameduck 5s
}
ready
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
fallthrough in-addr.arpa ip6.arpa
ttl 30 # Set this to anything between 0 to 3600
}
prometheus :9153
forward . /etc/resolv.conf
cache 30
loop
reload
loadbalance
}