带有应用程序网关的 AKS - 始终为 502

问题描述 投票:0回答:1

我遵循了 ms 和 k8s 教程,并尝试使用应用程序网关为 2 个演示 REST API 配置入口。 我希望在

/chat
拥有聊天服务,在
/session
拥有会话服务,但请求总是以 502 bad gateway 结束。

我使用 MS ingress 演示应用程序测试了我的集群,并且它有效。看起来和我的一样,除了只有一项服务。

...
apiVersion: apps/v1
kind: Deployment
metadata:
  name: session-service
spec:
  replicas: 2
  selector:
    matchLabels:
      app: session-service
  template:
    metadata:
      labels:
        app: session-service
    spec:
      nodeSelector:
        app: scalable
      containers:
      - name: session-service-container
        imagePullPolicy: Always
        image: myacr.azurecr.io/scalable/session-service:latest
        ports:
        - containerPort: 8080
        env:
        - name: REDIS
          value: "scalable-redis.default.svc.cluster.local"
        resources:
          requests:
            cpu: 1m
            memory: 128Mi
          limits:
            cpu: 30m
            memory: 512Mi
---
apiVersion: v1
kind: Service
metadata:
  name: session-service
spec:
  ports:
  - port: 8080
    targetPort: 8080
    protocol: TCP
  type: ClusterIP
  selector:
    app: session-service
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: chat-service
spec:
  replicas: 2
  selector:
    matchLabels:
      app: chat-service
  template:
    metadata:
      labels:
        app: chat-service
    spec:
      nodeSelector:
        app: scalable
      containers:
      - name: chat-service-container
        imagePullPolicy: Always
        image: myacr.azurecr.io/scalable/chat-service:latest
        ports:
        - containerPort: 8080
        env:
        - name: REDIS
          value: "scalable-redis.default.svc.cluster.local"
        resources:
          requests:
            cpu: 1m
            memory: 128Mi
          limits:
            cpu: 30m
            memory: 512Mi
---
apiVersion: v1
kind: Service
metadata:
  name: chat-service
spec:
  type: ClusterIP
  ports:
  - port: 8080
    targetPort: 8080
    protocol: TCP
  selector:
    app: chat-service
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: scalable-ingress
spec:
  ingressClassName: azure-application-gateway
  rules:
  - http:
      paths:
      - path: /chat
        pathType: Prefix
        backend:
          service:
            name: chat-service
            port: 
              number: 8080
      - path: /session
        pathType: Prefix
        backend:
          service:
            name: session-service
            port: 
              number: 8080

如果我将这些 Pod 端口转发到本地并发出请求,它们就可以正常工作。 我缺少什么?健康探测显示为“不健康”,这会影响路线吗?

$ kubectl get pods,svc,ingress
NAME                                   READY   STATUS    RESTARTS   AGE
pod/chat-front-5647f964bf-kt86z        1/1     Running   0          12h
pod/chat-front-5647f964bf-vkxhg        1/1     Running   0          12h
pod/chat-service-77cc84cf45-5ns8q      1/1     Running   0          12h
pod/chat-service-77cc84cf45-lqf6g      1/1     Running   0          12h
pod/scalable-redis-9f69d9f96-v7d69     1/1     Running   0          12h
pod/session-service-5b66cddcbf-sfmbg   1/1     Running   0          12h
pod/session-service-5b66cddcbf-z9v4h   1/1     Running   0          12h

NAME                      TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)        AGE
service/chat-front-lb     LoadBalancer   10.0.146.62    20.250.xxx.yyy   80:31316/TCP   12h
service/chat-service      ClusterIP      10.0.166.152   <none>           8080/TCP       12h
service/kubernetes        ClusterIP      10.0.0.1       <none>           443/TCP        12h
service/scalable-redis    ClusterIP      10.0.90.162    <none>           6379/TCP       12h
service/session-service   ClusterIP      10.0.55.242    <none>           8080/TCP       12h

NAME                                         CLASS                       HOSTS   ADDRESS        PORTS   AGE
ingress.networking.k8s.io/scalable-ingress   azure-application-gateway   *       4.226.xxx.yyy   80      12h
kubernetes azure-aks azure-application-gateway
1个回答
0
投票

啊,是关于探测器的。自动配置搞砸了。

© www.soinside.com 2019 - 2024. All rights reserved.