我已使用 kubenet 插件配置了 Azure AKS 集群。之后创建具有相同资源组和相同 vnet 的应用程序网关。
之后,我更新了用于从应用程序网关到 AKS 服务的通信的路由表条目。
我的 NSG 组规则
我正在使用默认的运行状况探测。仅部署 nginx 应用程序来首先测试连接。单个资源组中的所有资源。
那么在这个流程中我们有哪些可能的方式呢?
谢谢
确保应用程序网关和 AKS 之间的通信,解决潜在的 502 错误。
您可以按照以下步骤进行操作并交叉检查您的设置。
创建您的应用程序网关
并获取以下设置您的 AGIC 的详细信息
az network vnet subnet show
az aks 秀
现在在 AKS 中启用应用程序网关入口控制器 (AGIC)
az aks enable-addons \
--resource-group arkorg \
--name AGIC \
--addons ingress-appgw \
--appgw-name myAppGateway \
--appgw-subnet-id
kubectl get pods -n kube-system
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
现在对于这个应用程序,我们需要一个入口来公开它
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,您可以看到您的应用程序已部署。
如果您想对自己的设置进行故障排除,您可以查看 MS 的这些文档