无法通过Kubernetes中的skydns服务解析'kubernetes'

7rfyedvj  于 2023-10-17  发布在  Kubernetes
关注(0)|答案(1)|浏览(94)
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

谁能帮忙?

6ie5vjzr

6ie5vjzr1#

为了让DNS正常工作,kubelet需要在启动时传递标志--cluster_dns=和--cluster_domain=cluster.local。此标志不包含在传递给kubelet的标志集中,因此kubelet不会尝试联系您为名称解析服务创建的DNS pod。要解决这个问题,您可以修改脚本以将这两个标志添加到kubelet,然后当您创建DNS服务时,您需要确保将传递给--cluster_dns标志的IP地址设置为服务规范的portalIP字段(如this)。有关其他信息,您可以查看it

相关问题