在Kubernetes的多个pod中通信多个容器

inb24sb2  于 2022-12-11  发布在  Kubernetes
关注(0)|答案(1)|浏览(136)

I was left to a configuration of Kubernetes which contains two distinct instances of a master-replica service. The pods of both the master and the replicas contain both the container of the service and a metric collection container (therefore for each pod there are two different containers). In addition, I have a service headless that aims at all three that will then be used by other components. The point is that the "replicas" need to access the Master, and the classic DNS nomenclature "Master-Pod-Name.Service-Name.Namespace.Svc.Cluster.local" is not working (it was already set in this way in variables) I did some lookup tests etc and obviously it only works if I use "service-name.Namespace.svc.cluster.local", however, that service aims at all 3 instances and I have to point only to the master. My doubt is that I cannot solve it because there are several containers in that pod but I do not find references to how to indicate the correct DNS in the documentation.
I also tried to configure

dnsConfig:
        options:
        - name: ndots
          value: "6"

Then putting as DNS Container-Name.pod-Name.Service-Name.Namespace.Svc.Cluster.local but nothing has changed anyway.
The environment I am working on is a gke cluster (Kubernetes on Google Cloud).

a64a0gku

a64a0gku1#

确保您的应用程序部署为有状态集和无头服务。只有有状态集才能保证您要在DNS查找中使用的稳定网络ID:
https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id

相关问题