Yaml 路由到内部IP?AKS

Yaml 路由到内部IP?AKS,yaml,microservices,azure-aks,Yaml,Microservices,Azure Aks,我使用Azure Kubernetes服务来提供我的微服务。当我登录到API网关时,它会工作。但是当我试图通过Api网关联系另一个微服务时,我得到了一个错误(500内部服务器错误)。我还在Kubernetes建立了一个Eureka命名服务器,我提供的所有微服务都在那里注册。但是为什么我的API网关不能与我的微服务通信呢? 它也可以在本地机器上工作 我的Yaml文件 apiVersion: apps/v1 kind: Deployment metadata: name: discoveryse

我使用Azure Kubernetes服务来提供我的微服务。当我登录到API网关时,它会工作。但是当我试图通过Api网关联系另一个微服务时,我得到了一个错误(500内部服务器错误)。我还在Kubernetes建立了一个Eureka命名服务器,我提供的所有微服务都在那里注册。但是为什么我的API网关不能与我的微服务通信呢? 它也可以在本地机器上工作

我的Yaml文件

apiVersion: apps/v1
kind: Deployment
metadata:
  name: discoveryservice-front
spec:
  replicas: 1
  selector:
    matchLabels:
      app: discoveryservice-front
  template:
    metadata:
      labels:
        app: discoveryservice-front
    spec:
      nodeSelector:
        "beta.kubernetes.io/os": linux
      containers:
        - name: discoveryservice-front
          image: containerregistry.azurecr.io/discoveryservice:16
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 250m
              memory: 512Mi
          ports:
          - containerPort: 8762
            name: discovery
            
---
apiVersion: v1
kind: Service
metadata:
  name: eureka
spec:
  type: LoadBalancer
  ports:
  - port: 8762
  selector:
    app: discoveryservice-front

我所有的微服务都在同一个节点上运行。我的想法可能是在API网关中重新安装路由。但是否可以路由到内部IP?有人能告诉我我做错了什么吗?

因为您正在集群内运行API网关,所以进程应该能够使用其服务定义访问所有其他pod

假设所有服务/部署都部署在同一命名空间中。api网关应该能够通过服务名称引用它们

e、 g(fqdn)

contacts back..svc.cluster.local:8100

由于您在集群内运行API网关,因此进程应该能够使用其服务定义访问所有其他pod

假设所有服务/部署都部署在同一命名空间中。api网关应该能够通过服务名称引用它们

e、 g(fqdn)

contacts back..svc.cluster.local:8100

您是否检查了服务的IP?运行这个,
kubectl get svc
是的,我做了。每个微服务都有一个集群IP。我可以在API网关中路由到它们吗?或者我应该为每个微服务配置一个外部IP吗?如果它们在同一个节点中,那么可以。只需使用群集IP列下的IP地址和端口。我不建议使用外部IP,它可以在internet上访问。您可以阅读有关K8s服务的链接,您是否检查了服务的IP?运行这个,
kubectl get svc
是的,我做了。每个微服务都有一个集群IP。我可以在API网关中路由到它们吗?或者我应该为每个微服务配置一个外部IP吗?如果它们在同一个节点中,那么可以。只需使用群集IP列下的IP地址和端口。我不建议使用外部IP,它可以在internet上访问。您可以阅读有关K8s服务的链接,问题已解决。我将丢失的路由放入API网关,并引用集群IP zuul.routes.templates.path=/templates/**zuul.routes.templates.url=http://Problem 解决了的。我将丢失的路由放入API网关,并引用集群IP zuul.routes.templates.path=/templates/**zuul.routes.templates.url=http://
apiVersion: apps/v1
kind: Deployment
metadata:
  name: apigateway-front
spec:
  replicas: 1
  selector:
    matchLabels:
      app: apigateway-front
  template:
    metadata:
      labels:
        app: apigateway-front
    spec:
      nodeSelector:
        "beta.kubernetes.io/os": linux
      containers:
        - name: apigateway-front
          image: containerregistry.azurecr.io/apigateway:27
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 250m
              memory: 512Mi
          ports:
          - containerPort: 8800
            name: apigateway
            
---
apiVersion: v1
kind: Service
metadata:
  name: apigateway-front
spec:
  type: LoadBalancer
  ports:
  - port: 8800
  selector:
    app: apigateway-front
    
    
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: contacts-back
spec:
  replicas: 1
  selector:
    matchLabels:
      app: contacts-back
  template:
    metadata:
      labels:
        app: contacts-back
    spec:
      nodeSelector:
        "beta.kubernetes.io/os": linux
      containers:
      - name: contacts-back
        image: containerregistry.azurecr.io/contacts:26
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 250m
            memory: 512Mi
        ports:
        - containerPort: 8100
          name: contacts-back
          
---
apiVersion: v1
kind: Service
metadata:
  name: contacts-back
spec:
  ports:
  - port: 8100
  selector:
    app: contacts-back
---


apiVersion: apps/v1
kind: Deployment
metadata:
  name: templates-back
spec:
  replicas: 1
  selector:
    matchLabels:
      app: templates-back
  template:
    metadata:
      labels:
        app: templates-back
    spec:
      nodeSelector:
        "beta.kubernetes.io/os": linux
      containers:
      - name: templates-back
        image: containerregistry.azurecr.io/templates:25
        resources:
         requests:
            cpu: 100m
            memory: 128Mi
         limits:
            cpu: 250m
            memory: 512Mi
        ports:
         - containerPort: 8200
           name: templates-back
---
apiVersion: v1
kind: Service
metadata:
  name: templates-back
spec:
  ports:
  - port: 8200
  selector:
    app: templates-back
contacts-back.<namespace>.svc.cluster.local:8100