我的 k8s 中有兩個服務正在運行。
我正在嘗試從我的用戶服務訪問我的錢包服務,但我的 curl cmd 只回傳 504 網關超時。
這是我的入口
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
curl http://EXTERNAL_IP/api/v1/user/health/wallet
所有其他非相關端點都有效。
任何幫助表示贊賞
我正在運行 Azure Kubernetes
uj5u.com熱心網友回復:
我的 k8s 中有兩個服務正在運行。
你有實際的 K8S 服務嗎?
apiVerison: ... kind: Service- 檢查它,
kubectl get svc -A你應該在那里看到你的服務
- 檢查它,
檢查您的 pod 是否暴露在服務中
kubectl get endpoints -A您是否在云提供商(GCP、Azure、AWS 等)上運行,如果是,請檢查您的安全配置(Azure 的 NSG、AWS 的安全策略等)
檢查內部溝通:
# 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
更新:
- 您評論說您在 Azure 上運行,請檢查 NSG 下是否打開了所需的埠。
- 假設您正在運行 AKS,您需要找出
MS_xxxx資源并且您的 NSG 組將位于此資源組下,對其進行編輯并打開所需的埠
您正在嘗試連接到 http://wallet-service:3007/api/v1/wallet/health - 您從哪里獲得 3007 埠?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/495823.html
