[英]Kubernetes Postgres Pod not reachable
I have a K8s Cluster with couple of pods.我有一个带有几个 pod 的 K8s 集群。 I have a postgres pod of type Deployment which simply runs a "postgres:12" image
我有一个部署类型的 postgres pod,它只运行一个“postgres:12”图像
docker pull postgres:12
the pod is named "metadatadb" pod 被命名为“metadatadb”
there are other pods of type Cronjob that are dependent on it.还有其他依赖于它的 Cronjob 类型的 pod。 from time to time I see some of these cronjob instances failing with the below error
我不时看到其中一些 cronjob 实例失败并出现以下错误
ERROR [08001] could not translate host name "metadatadb" to address: Name or service not known
错误 [08001] 无法将主机名“metadatadb”转换为地址:名称或服务未知
This error happens rarely (which means in most of the times the cronjob runs and connects successfully).此错误很少发生(这意味着在大多数情况下 cronjob 运行并成功连接)。 I can't figure out why.
我不知道为什么。
Thank you谢谢
The error is the result of a missing Service
or a problem with the Cluster DNS.该错误是由于缺少
Service
或集群 DNS 问题造成的。
Background: A pod does not get a DNS entry, if you want to connect to a pod you need the internal IP of it.背景:Pod 没有 DNS 条目,如果要连接到 Pod,则需要它的内部 IP。 To create DNS names (and internal load balancing with a service ip) you need to create a service.
要创建 DNS 名称(以及使用服务 ip 进行内部负载平衡),您需要创建一个服务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.