[英]How to access a service from another namespace in kubernetes
I have the zipkin deployment and service below as you can see zipkin is located under monitoring namespace the, i have an env variable called ZIPKIN_URL in each of my pods which are running under default namespace, this varibale takes this URL http://zipkin:9411/api/v2/spans but since zipkin is running in another namespace i tried this:我有下面的 zipkin 部署和服务,您可以看到 zipkin 位于监视命名空间下,我在每个在默认命名空间下运行的 pod 中都有一个名为ZIPKIN_URL的 env 变量,此变量采用此 URL http://zipkin: 9411/api/v2/spans但由于 zipkin 在另一个命名空间中运行,我尝试了这个:
http://zipkin.monitoring.svc.cluster.local:9411/api/v2/spanshttp://zipkin.monitoring.svc.cluster.local:9411/api/v2/spans
i also tried this format:我也试过这种格式:
http://zipkin.monitoring:9411/api/v2/spans http://zipkin.monitoring:9411/api/v2/spans
but when i check the logs of my pods, i see connection refused exception但是当我检查我的豆荚的日志时,我看到连接被拒绝异常
when i exec into one of my pods and try curl http://zipkin.tools.svc.cluster.local:9411/api/v2/spans当我执行到我的一个 pod 并尝试 curl http://zipkin.tools.svc.cluster.local:9411/api/v2/spans
its shows me Mandatory parameter is missing: serviceNameroot它向我展示了强制参数缺失:serviceNameroot
Here is zipkin resource:这是zipkin资源:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: zipkin
namespace: monitoring
spec:
template:
metadata:
labels:
app: zipkin
spec:
containers:
- name: zipkin
image: openzipkin/zipkin:2.19.3
ports:
- containerPort: 9411
---
apiVersion: v1
kind: Service
metadata:
name: zipkin
namespace: monitoring
spec:
selector:
app: zipkin
ports:
- name: http
port: 9411
protocol: TCP
type: ClusterIP
What you have is correct, your issue is likely not DNS.您所拥有的是正确的,您的问题可能不是 DNS。 You can confirm by doing just a DNS lookup and comparing that to the IP of the Service.
您可以通过仅进行 DNS 查找并将其与服务的 IP 进行比较来确认。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.