azure - Ingress 不适用于 AKS 的应用程序网关入口 Controller (AGIC) 附加组件

标签 azure kubernetes kubernetes-ingress azure-aks

我在 Azure 门户中启用了 AGIC,然后创建了 Fanout Ingress 。但这不起作用。我检查了规则(ingress-appgateway > 规则 > 基于路径的路由),并且路径以正确的后端池为目标。

当我测试运行状况探针时,它失败(“MC_...”资源组 > ingress-appgateway > 运行状况探针 > 单击测试) - 显示错误:

One or more of your backend instances are unhealthy. It is recommended to address this health issue first before attaching the probe

我尝试过:

  • 禁用和启用 AGIC -> 不起作用
  • 使用 pathType: ImplementSpecific(而不是 pathType: Prefix)-> 不起作用
  • nginx.ingress.kubernetes.io/rewrite-target:/$1 & /foo(/|$)(.*) -> 没有工作

在“ingress-appgateway”(Azure 门户)的概述页面顶部,显示错误:

All the instances in one or more of your backend pools are unhealthy. This will result in a 502 error when you try to access your application hosted behind the Application Gateway. Please check the backend health and resolve the issue.

仅当我删除路径(/foo/bar)并定位单个服务时,它才有效。

仅供引用,我正在使用 Azure CNI 网络和现有 VNet(专用子网)。

deployment.yaml

apiVersion: v1
kind: Service
metadata:
  name: demo-web-app1
  namespace: demo
spec:
  selector:
    app: demo-web-app1
  type: ClusterIP
  ports:
  - protocol: TCP
    port: 4200
    targetPort: 80
    
---

apiVersion: v1
kind: Service
metadata:
  name: demo-web-app2
  namespace: demo
spec:
  selector:
    app: demo-web-app2
  type: ClusterIP
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 80

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo-web-app1
  namespace: demo
spec:
  replicas: 2
  selector:
    matchLabels:
      app: demo-web-app1
  template:
    metadata:
      labels:
        app: demo-web-app1
    spec:
      containers:
      - name: demo-web-app1
        image: myacr.azurecr.io/myacr6472:375
        ports:
        - containerPort: 80
        
---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo-web-app2
  namespace: demo
spec:
  replicas: 3
  selector:
    matchLabels:
      app: demo-web-app2
  template:
    metadata:
      labels:
        app: demo-web-app2
    spec:
      containers:
      - name: demo-web-app2
        image: myacr.azurecr.io/myacr6472:375
        ports:
        - containerPort: 80

---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-demo-web-app
  namespace: demo
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
    appgw.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - http:
      paths:
      - path: /foo
        pathType: Prefix
        backend:
          service:
            name: demo-web-app1
            port:
              number: 4200
      - path: /bar
        pathType: Prefix
        backend:
          service:
            name: demo-web-app2
            port:
              number: 8080

最佳答案

使用appgw.ingress.kubernetes.io/backend-path-prefix: "/"我们将能够指定多个规则。

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: gateway-ingress
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
    appgw.ingress.kubernetes.io/backend-path-prefix: "/"
spec:
  rules:
  - http:
      paths:
      - path: /service1/*
        pathType: Prefix
        backend:
          service:
            name: k8-boot-graphql-rest-aks-apm-test
            port:
              number: 8081
      - path: /service2/*
        pathType: Prefix
        backend:
          service:
            name: k8-sboot-restapi-test
            port:
              number: 8080

http://host/service1/actuator/health ---> Microservice 1
http://host/service2/actuator/health ---> Microservice 2

我使用过的示例部署脚本

apiVersion: v1
kind: Pod
metadata:
  name: k8-boot-graphql-rest-aks-apm-test
  labels:
    app: k8-boot-graphql-rest-aks-apm-test
spec:
  containers:
  - image: sreyasvpariyath/k8-boot-graphql-rest-aks-apm-test:latest #CHANGE
    imagePullPolicy: Always
    name: k8-boot-graphql-rest-aks-apm-test
    ports:
    - containerPort: 8081
      protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: k8-boot-graphql-rest-aks-apm-test
spec:
  selector:
    app: k8-boot-graphql-rest-aks-apm-test
  ports:
  - protocol: TCP
    port: 8081
    targetPort: 8081

关于azure - Ingress 不适用于 AKS 的应用程序网关入口 Controller (AGIC) 附加组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67573856/

相关文章:

azure - Windows Azure 存储表中的事务和延续 token

kubernetes - GKE:将服务配置为可从同一VPC访问

kubernetes - 使用 istio 连接到 Nodejs TLS 服务器时出现 NR filter_chain_not_found

azure - 有关使用 Azure Functions 扩展 OptaPlanner 的建议

c# - 如何使用 .Net 2 C# 的 REST API 实现 Azure 表服务的批量启动

kubernetes - 如何在 Kubernetes 中找到 cronjobs 的所有者并杀死它?

nginx - 无法通过高级网络在 AKS 中获取真正的远程 IP

kubernetes - traefik 1.7.11 基于子域的访问规则设置

kubernetes - Nginx入口 Controller -调用Webhook失败

azure - 如何在Azure辅助角色中使用证书?