我已经按照此处的文档在AKS中安装了HAProxy控制器https://www.haproxy.com/documentation/kubernetes/latest/installation/community/azure/.当我尝试按预期浏览外部负载均衡器IP时,我得到了404。然后,我使用helloworld映像将一个新的应用程序部署到同一个命名空间中。
apiVersion: apps/v1
kind: Deployment
metadata:
name: aks-helloworld-one
spec:
replicas: 1
selector:
matchLabels:
app: aks-helloworld-one
template:
metadata:
labels:
app: aks-helloworld-one
spec:
containers:
- name: aks-helloworld-one
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
ports:
- containerPort: 80
env:
- name: TITLE
value: "Welcome to Azure Kubernetes Service (AKS)"
---
apiVersion: v1
kind: Service
metadata:
name: aks-helloworld-one
annotations:
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
spec:
ports:
- name: http-port
port: 8000
protocol: TCP
targetPort: 80
selector:
app: aks-helloworld-one
然后我用下面的添加了入口文件的路径
kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
name: test
spec:
ingressClassName: haproxy
rules:
- http:
paths:
- path: /helloworld
pathType: Prefix
backend:
service:
name: aks-helloworld-one
port:
number: 80
并部署。帖子称,如果我导航到外部负载均衡器,ip/helloworld仍然返回404。我不确定我做错了什么。这是名称空间中的当前服务列表
PS\HA代理>kubectl get-svc—命名空间haproxy控制器
名称类型集群-IP外部IP端口
aks helloworld one集群IP 10.0.206.176 8000/TCP
haproxy kubernetes入口LoadBalancer 10.0.138.212**.**8 80:3078/TCP,443:32570/TCP,1024:31481/TCP
Ingress将重定向到服务,并将服务重定向到pod。
因此,在Ingress service.port中,它需要设置为8000(即在服务中设置的端口,pod的目标端口为80(。