无法通过 Kubernetes 中的 skydns 服务解析 'kubernetes'
Can't resolve 'kubernetes' by skydns serivce in Kubernetes
core@core-1-94 ~ $ kubectl exec -it busybox -- nslookup kubernetes
Server: 10.100.0.10
Address 1: 10.100.0.10
nslookup: can't resolve 'kubernetes'
core@core-1-94 ~ $ kubectl get svc --namespace=kube-system
NAME LABELS SELECTOR IP(S) PORT(S)
kube-dns k8s-app=kube-dns,kubernetes.io/cluster-service=true,kubernetes.io/name=KubeDNS k8s-app=kube-dns 10.100.0.10 53/UDP
53/TCP
kube-ui k8s-app=kube-ui,kubernetes.io/cluster-service=true,kubernetes.io/name=KubeUI k8s-app=kube-ui 10.100.110.236 80/TCP
core@core-1-94 ~ $ kubectl exec -it busybox -- nslookup kubernetes 10.100.0.10:53
Server: 10.100.0.10
Address 1: 10.100.0.10
nslookup: can't resolve 'kubernetes'
core@core-1-94 ~ $ kubectl get endpoints --namespace=kube-system
NAME ENDPOINTS
kube-dns 10.244.31.16:53,10.244.31.16:53
kube-ui 10.244.3.2:8080
core@core-1-94 ~ $ kubectl exec -it busybox -- nslookup kubernetes 10.244.31.16:53
Server: 10.244.31.16
Address 1: 10.244.31.16
Name: kubernetes
Address 1: 10.100.0.1
我认为 kube-dns
的服务不可用。
skydns-svc.yaml
:
apiVersion: v1
kind: Service
metadata:
name: kube-dns
namespace: kube-system
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "KubeDNS"
spec:
selector:
k8s-app: kube-dns
clusterIP: 10.100.0.10
ports:
- name: dns
port: 53
protocol: UDP
- name: dns-tcp
port: 53
protocol: TCP
谁能帮忙?
要使 DNS 正常工作,kubelet 需要在启动时传递标志 --cluster_dns= 和 --cluster_domain=cluster.local。此标志未包含在 the set of flags passed to the kubelet, so the kubelet won't try to contact the DNS pod that you've created for name resolution services. To fix this, you can modify the script to add these two flags to the kubelet and then when you create a DNS service, you need to make sure that you set the same ip address that you passed to the --cluster_dns flag as the portalIP field of the service spec like this 中。
有关任何其他信息,您可以查看 it.
core@core-1-94 ~ $ kubectl exec -it busybox -- nslookup kubernetes Server: 10.100.0.10 Address 1: 10.100.0.10 nslookup: can't resolve 'kubernetes' core@core-1-94 ~ $ kubectl get svc --namespace=kube-system NAME LABELS SELECTOR IP(S) PORT(S) kube-dns k8s-app=kube-dns,kubernetes.io/cluster-service=true,kubernetes.io/name=KubeDNS k8s-app=kube-dns 10.100.0.10 53/UDP 53/TCP kube-ui k8s-app=kube-ui,kubernetes.io/cluster-service=true,kubernetes.io/name=KubeUI k8s-app=kube-ui 10.100.110.236 80/TCP core@core-1-94 ~ $ kubectl exec -it busybox -- nslookup kubernetes 10.100.0.10:53 Server: 10.100.0.10 Address 1: 10.100.0.10 nslookup: can't resolve 'kubernetes' core@core-1-94 ~ $ kubectl get endpoints --namespace=kube-system NAME ENDPOINTS kube-dns 10.244.31.16:53,10.244.31.16:53 kube-ui 10.244.3.2:8080 core@core-1-94 ~ $ kubectl exec -it busybox -- nslookup kubernetes 10.244.31.16:53 Server: 10.244.31.16 Address 1: 10.244.31.16 Name: kubernetes Address 1: 10.100.0.1
我认为 kube-dns
的服务不可用。
skydns-svc.yaml
:
apiVersion: v1 kind: Service metadata: name: kube-dns namespace: kube-system labels: k8s-app: kube-dns kubernetes.io/cluster-service: "true" kubernetes.io/name: "KubeDNS" spec: selector: k8s-app: kube-dns clusterIP: 10.100.0.10 ports: - name: dns port: 53 protocol: UDP - name: dns-tcp port: 53 protocol: TCP
谁能帮忙?
要使 DNS 正常工作,kubelet 需要在启动时传递标志 --cluster_dns= 和 --cluster_domain=cluster.local。此标志未包含在 the set of flags passed to the kubelet, so the kubelet won't try to contact the DNS pod that you've created for name resolution services. To fix this, you can modify the script to add these two flags to the kubelet and then when you create a DNS service, you need to make sure that you set the same ip address that you passed to the --cluster_dns flag as the portalIP field of the service spec like this 中。 有关任何其他信息,您可以查看 it.