Azure AGIC 使用 AKS 提供 502 错误网关

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

我已使用 kubenet 插件配置了 Azure AKS 集群。之后创建具有相同资源组和相同 vnet 的应用程序网关。

之后,我更新了用于从应用程序网关到 AKS 服务的通信的路由表条目。

enter image description here

我的 NSG 组规则

enter image description here

故障排除 enter image description here

我正在使用默认的运行状况探测。仅部署 nginx 应用程序来首先测试连接。单个资源组中的所有资源。 enter image description here

那么在这个流程中我们有哪些可能的方式呢?

谢谢

azure azure-aks azure-application-gateway http-status-code-502
1个回答
0
投票

确保应用程序网关和 AKS 之间的通信,解决潜在的 502 错误。

您可以按照以下步骤进行操作并交叉检查您的设置。

创建您的应用程序网关

application gateway here

并获取以下设置您的 AGIC 的详细信息

az network vnet subnet show

check your subnet name

az aks 秀

check your vnet name here

现在在 AKS 中启用应用程序网关入口控制器 (AGIC)

az aks enable-addons \
    --resource-group arkorg \
    --name AGIC \
    --addons ingress-appgw \
    --appgw-name myAppGateway \
    --appgw-subnet-id

enable AGIC here

kubectl get pods -n kube-system

AGIC pods are up

ingress-appgw
Pod 正在运行,这意味着 AGIC 已正确设置为在应用程序网关和 AKS 中部署的服务之间路由流量。

通过部署示例应用程序来测试它

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
  type: ClusterIP

deployed your application

现在对于这个应用程序,我们需要一个入口来公开它

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: nginx-service
            port:
              number: 80

现在转到您为应用程序网关创建的公共IP,您可以看到您的应用程序已部署。

App is up and running on your public IP

如果您想对自己的设置进行故障排除,您可以查看 MS 的这些文档

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