访问服务的另一个豆荚kubernetes

发布于 2025-02-10 15:19:16 字数 987 浏览 1 评论 0原文

我的K8有两个服务。
我正在尝试从我的用户服务访问我的钱包服务,但我的卷发CMD刚刚返回504 Gateway超时。

这是我的入学,

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: dev-ingress
  namespace: dev
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    # nginx.ingress.kubernetes.io/use-regex: "true"
    # nginx.ingress.kubernetes.io/rewrite-target: /api/v1$uri
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /api/v1/wallet
        pathType: Prefix
        backend:
          service:
            name: wallet-service
            port:
              number: 80
      - path: /api/v1/user
        pathType: Prefix
        backend:
          service:
            name: accounts-service
            port:
              number: 80

这是我在帐户服务中通过ENV的方式。

http:// Wallet-Service:3007

端点时记录URL

在登录我的

,然后 非相关端点有效。

感谢

我正在运行Azure Kubernetes

I have two services running in my k8s.
I am trying to access my wallet service from my user service but my curl cmd just returns 504 gateway timeout.

here is my ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: dev-ingress
  namespace: dev
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    # nginx.ingress.kubernetes.io/use-regex: "true"
    # nginx.ingress.kubernetes.io/rewrite-target: /api/v1$uri
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /api/v1/wallet
        pathType: Prefix
        backend:
          service:
            name: wallet-service
            port:
              number: 80
      - path: /api/v1/user
        pathType: Prefix
        backend:
          service:
            name: accounts-service
            port:
              number: 80

this is the way I passed the env in my account service.

http://wallet-service:3007

and I log the URL when hitting my endpoint

curl http://EXTERNAL_IP/api/v1/user/health/wallet

every other non-related endpoint works.

Any help is appreciated

I am running Azure Kubernetes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱*していゐ 2025-02-17 15:19:16

我在K8S中运行了两个服务。

  1. 您有实际的K8S服务吗?

      apiverison:...
    善良:服务
     
    • 使用kubectl获取SVC -A检查它,您应该在那里看到您的服务
  2. 检查您的豆荚已接触到服务

      kubectl获取端点-a
     
  3. 您是否在云提供商(GCP,Azure,AWS等)上运行,如果是这样,请检查您的安全配置(NSG for Azure,AWS的安全策略,适用于AWS的安全策略,等)

  4. 检查内部通信:

     #登录到其中一个豆荚 
    kubectl exec -n<名称空间> < pod name> sh
    
    #尝试通过FQDN连接到其他服务
    curl -sv< serviceName>。名称空间> .svc.cluster.local
     

更新:

  • 您评论说您在Azure上运行,检查所需的端口是在NSG下打开的。
  • 假设您正在运行AKS,则需要找出MS_XXXX资源,而您的NSG组将位于此资源组下,进行编辑并打开

您试图连接到http://的 所需端口钱包服务:3007/api/v1/Wallet/Health-您从哪里获得3007端口?

I have two services running in my k8s.

  1. Do you have an actual K8S service?

    apiVerison: ...
    kind: Service
    
    • Check it with kubectl get svc -A and you should see your services there
  2. Check to see that your pods are exposed to the services

    kubectl get endpoints -A
    
  3. Are you running on a cloud provider (GCP, Azure, AWS, etc), if so check your security configuration as well (NSG for Azure, a security policy for AWS, etc)

  4. Check inner communication :

    # Log into one of the pods 
    kubectl exec -n <namespace> <pod name> sh
    
    # Try to connect to the other service with the FQDN
    curl -sv <servicename>.<namespace>.svc.cluster.local
    

Update:

  • You commented that you are running on Azure, check the desired ports are opened under the NSG.
  • Assuming that you are running AKS you need to find out the MS_xxxx resource and your NSG group will be located under this resource group, edit it and open the desired ports

You are trying to connect to http://wallet-service:3007/api/v1/wallet/health - Where did you get the 3007 port?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文