简体   繁体   English

如何从 kubernetes 中的另一个命名空间访问服务

[英]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.

相关问题 Kubernetes如何从另一个命名空间访问服务 - Kubernetes how to access a service from another namespace Kubernetes - 如何从另一个命名空间访问 statefulset 无头服务? - Kubernetes - how to access statefulset headless service from another namespace? 如何从 yaml 文件访问 kubernetes 命名空间 - How to access kubernetes namespace from a yaml file Kubernetes:无法从其他名称空间访问mongodb副本集服务 - Kubernetes: Cannot access mongodb replicaset service from a different namespace 如何让所有 Kubernetes 服务帐户访问特定命名空间? - How to give all Kubernetes service accounts access to a specific namespace? 如何访问在另一个命名空间中创建的服务 - How to access service created in another namespace 如何使用网络策略仅允许从特定名称空间访问 pods 到 kubernetes 中的另一个名称空间? - How to use network policy to allow access to pods only from a specific namespace to another in kubernetes? 限制Kubernetes服务帐户访问特定的名称空间 - Limit the Kubernetes service account access specific namespace 无法从Kubernetes中的其他服务访问Spring Boot后端服务 - Not able to access Spring Boot backend service from another service in Kubernetes Kubernetes,自动服务回退到另一个名称空间 - Kubernetes, Automatic Service fallback to another namespace
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM