我在名为"a"
的命名空间中有一个简单的pod,
和命名空间"b"
中的另一个Pod ...
我还有一个测试脚本,可以从"a"
到"b"
进行grpc调用。
我想DNS解析有些错误, 但我真的无法前进。
有帮助吗?
kubectl exec -n a somepod-f647b7d95-mrvfr cat /etc/resolv.conf
nameserver 10.12.0.10
search chimera.svc.cluster.local svc.cluster.local cluster.local c.<company-name>-staging.internal <provider>.internal
options ndots:5
kubectl get pods -n kube-system
event-exporter-v0.2.4-6d4c69fbfb-f4xpf 1/1 Running 0 24d
fluentd-gcp-scaler-6965bb45c9-mzvw6 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-2m2bf 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-2v6bq 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-4xpbc 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-7g5hm 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-8mqvc 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-f9hrs 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-fr58c 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-hzrsb 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-kq8hc 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-kt6p5 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-nsztm 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-qcl4r 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-qggv9 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-qkkp5 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-rm9hn 1/1 Running 0 5d5h
fluentd-gcp-v3.2.0-sv52h 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-t75fp 1/1 Running 0 7d6h
fluentd-gcp-v3.2.0-v49fv 1/1 Running 0 7d6h
kube-dns-6cd7bbdf65-jnntn 4/4 Running 0 24d
kube-dns-6cd7bbdf65-txmlj 4/4 Running 0 24d
kube-dns-autoscaler-8687c64fc-29jgq 1/1 Running 0 7d6h
kube-proxy-gke-iceberg-api-v2-201908101259587443-01f0b55b-q0k3 1/1 Running 0 217d
kube-proxy-gke-iceberg-api-v2-201908101259587443-0d661dfb-3zhx 1/1 Running 0 217d
kube-proxy-gke-iceberg-api-v2-201908101259587443-92bbd393-w96w 1/1 Running 1 115d
kube-proxy-gke-iceberg-es-single-202003021919386-1b520a2e-sn9m 1/1 Running 0 5d6h
kube-proxy-gke-iceberg-es-single-202003021919386-bf6046bf-7wsp 1/1 Running 0 5d5h
kube-proxy-gke-iceberg-es-single-202003021919386-d64daa4e-1jqz 1/1 Running 0 5d5h
kube-proxy-gke-iceberg-general-20190810125958886-21ed2623-4m0p 1/1 Running 0 217d
kube-proxy-gke-iceberg-general-20190810125958886-8b185cf9-x1j2 1/1 Running 0 217d
kube-proxy-gke-iceberg-general-20190810125958886-eaf63d3c-k338 1/1 Running 0 217d
kube-proxy-gke-iceberg-kafka-2019081012595876540-429586da-m2qf 1/1 Running 0 217d
kube-proxy-gke-iceberg-kafka-2019081012595876540-76ebb654-z7xx 1/1 Running 0 217d
kube-proxy-gke-iceberg-kafka-2019081012595876540-c3abee6e-4q76 1/1 Running 0 217d
kube-proxy-gke-iceberg-rabbitmq-2019081012595876-552d6676-8z2k 1/1 Running 0 217d
kube-proxy-gke-iceberg-rabbitmq-2019081012595876-662980f7-76jc 1/1 Running 0 217d
kube-proxy-gke-iceberg-rabbitmq-2019081012595876-b269df22-6zqj 1/1 Running 0 217d
kube-proxy-gke-iceberg-redis-2019081012595877180-38264a5e-c0ch 1/1 Running 0 217d
kube-proxy-gke-iceberg-redis-2019081012595877180-9412d5f5-pt3w 1/1 Running 0 217d
kube-proxy-gke-iceberg-redis-2019081012595877180-947dc20b-c002 1/1 Running 0 217d
kube-state-metrics-67b67d8fdd-nkpt4 2/2 Running 0 24d
l7-default-backend-fd59995cd-cvqwb 1/1 Running 0 24d
metrics-server-v0.3.1-5c8f664b95-sthjz
答案 0 :(得分:3)
从您的描述看来,您正在运行KubeDNS。我给您的第一条建议是migrate到CoreDNS,因为KubeDNS位于deprecation path上。
第二,两件事突然出现在我身上。
您正在谈论在Pod之间而不是services之间进行呼叫。虽然Kubernetes确实在您的应用程序之间提供了服务发现,但众所周知,它是通过DNS进行的。但是,仅因为Pod可以相互解析doesn't mean,容器的端口才会暴露在Pod的外部。为此,即使对于群集中无法解决的应用程序,也必须为每个Pod或Controller声明一个Service资源。
在谈论进行引用您的B pod /服务的FQDN的呼叫时,您没有指定默认的FQDN模式,也没有提到要对其进行自定义。
首先,请问kubectl get svc -n NAMESPACE
是否同时运行了A和B容器的两个名称空间,并确认已经创建了ClusterIP类型的服务,并且该服务已关联了IP地址?
第二,您可以尝试通过specifying the following FQDN format来执行从应用程序A到应用程序B的服务的连接尝试吗?
some-service.b.svc.cluster.local
注意 svc 部分。您在OP中提到了some-service.b.cluster.local
。
最后,如果一切恢复正常,我们可以开始进行故障排除kube-dns
。看来所有三个Pod都在运行。但是,您是否尝试过describe和/或grab their logs?如果有什么有趣的地方,您可以尝试以下内容并分享摘要吗?
kubectl describe pod -n kube-system kube-dns-6cd7bbdf65-jnntn
kubectl describe pod -n kube-system kube-dns-6cd7bbdf65-txmlj
kubectl describe pod -n kube-system kube-dns-autoscaler-8687c64fc-29jgq
kubectl logs -n kube-system kube-dns-6cd7bbdf65-jnntn
kubectl logs -n kube-system kube-dns-6cd7bbdf65-txmlj
kubectl logs -n kube-system kube-dns-autoscaler-8687c64fc-29jgq
我想象logs
命令将为您提供所需的答案。让我知道您是否需要进一步澄清或帮助解决此问题。我很乐意提供帮助。