如何在 kubernetes 1.10+ 中查看 coredns 的上游服务器?
how to see upstream server of coredns in kubernetes 1.10+?
我有以下配置图
kubectl get configmap coredns --namespace kube-system -o yaml
apiVersion: v1
data:
Corefile: |
.:53 {
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
}
prometheus :9153
proxy . /etc/resolv.conf
cache 30
reload
}
kind: ConfigMap
metadata:
creationTimestamp: 2018-06-29T03:48:35Z
name: coredns
namespace: kube-system
resourceVersion: "222"
selfLink: /api/v1/namespaces/kube-system/configmaps/coredns
uid: 4c8c3b17-7b4f-11e8-aaa1-0cc47a453e30
但我看不到它从哪里获取上游 dns 服务器。我最初使用 kube-dns 部署了这个 k8s 集群,但在 1.11 出来时更新为 coredns。我的上游服务器设置为 192.168.1.18,但我现在需要更改它。我已经检查了每个主机的 /etc/resolv.conf,那里没有列出 192.168.1.18,从这个配置图中,我也没有看到它......但是如果我在 192.168.1.18 上停止 DNS,pods 停止外部解析。此 IP 地址存储在哪里?
看来本地dns设置为coredns
/etc/resolv.conf
nameserver 127.0.0.53
如果我查看用于侦听 53 的 dns 的服务,我会得到这个
kubectl describe svc kube-dns --namespace kube-system
Name: kube-dns
Namespace: kube-system
Labels: k8s-app=kube-dns
kubernetes.io/cluster-service=true
kubernetes.io/name=KubeDNS
Annotations: prometheus.io/scrape=true
Selector: k8s-app=kube-dns
Type: ClusterIP
IP: 10.96.0.10
Port: dns 53/UDP
TargetPort: 53/UDP
Endpoints: 10.32.0.12:53,10.32.0.14:53
与 coredns 相关 pods..输入时...包含 IP 地址
kubectl exec -it --namespace kube-system coredns-78fcdf6894-l4tph -- sh
/ # cd /etc
/etc # ls
TZ fstab logrotate.d os-release services
alpine-release group modprobe.d passwd shadow
apk hostname modules periodic shells
ca-certificates hosts modules-load.d profile ssl
ca-certificates.conf init.d motd profile.d sysctl.conf
conf.d inittab mtab protocols sysctl.d
coredns issue network resolv.conf udhcpd.conf
crontabs localtime opt securetty
/etc # cat resolv.conf
nameserver 192.168.1.18
search home
呃。多么棒的 PITA
我有以下配置图
kubectl get configmap coredns --namespace kube-system -o yaml
apiVersion: v1
data:
Corefile: |
.:53 {
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
}
prometheus :9153
proxy . /etc/resolv.conf
cache 30
reload
}
kind: ConfigMap
metadata:
creationTimestamp: 2018-06-29T03:48:35Z
name: coredns
namespace: kube-system
resourceVersion: "222"
selfLink: /api/v1/namespaces/kube-system/configmaps/coredns
uid: 4c8c3b17-7b4f-11e8-aaa1-0cc47a453e30
但我看不到它从哪里获取上游 dns 服务器。我最初使用 kube-dns 部署了这个 k8s 集群,但在 1.11 出来时更新为 coredns。我的上游服务器设置为 192.168.1.18,但我现在需要更改它。我已经检查了每个主机的 /etc/resolv.conf,那里没有列出 192.168.1.18,从这个配置图中,我也没有看到它......但是如果我在 192.168.1.18 上停止 DNS,pods 停止外部解析。此 IP 地址存储在哪里?
看来本地dns设置为coredns
/etc/resolv.conf
nameserver 127.0.0.53
如果我查看用于侦听 53 的 dns 的服务,我会得到这个
kubectl describe svc kube-dns --namespace kube-system
Name: kube-dns
Namespace: kube-system
Labels: k8s-app=kube-dns
kubernetes.io/cluster-service=true
kubernetes.io/name=KubeDNS
Annotations: prometheus.io/scrape=true
Selector: k8s-app=kube-dns
Type: ClusterIP
IP: 10.96.0.10
Port: dns 53/UDP
TargetPort: 53/UDP
Endpoints: 10.32.0.12:53,10.32.0.14:53
与 coredns 相关 pods..输入时...包含 IP 地址
kubectl exec -it --namespace kube-system coredns-78fcdf6894-l4tph -- sh
/ # cd /etc
/etc # ls
TZ fstab logrotate.d os-release services
alpine-release group modprobe.d passwd shadow
apk hostname modules periodic shells
ca-certificates hosts modules-load.d profile ssl
ca-certificates.conf init.d motd profile.d sysctl.conf
conf.d inittab mtab protocols sysctl.d
coredns issue network resolv.conf udhcpd.conf
crontabs localtime opt securetty
/etc # cat resolv.conf
nameserver 192.168.1.18
search home
呃。多么棒的 PITA