[英]nginx-ingress controller for Azure Kubernetes Service 502 Bad Gateway
[英]Azure Kubernetes Ingress : 502 Bad Gateway while using Path inside ingress configuration
我在我的应用程序网关中面临 502 Bad gateway 问题。
我正在使用 Azure Kubernetes 服务来部署连接到 Ingress 应用程序网关的集群。
配置文件:
kube-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myApp
namespace: en02
labels:
app: myApp
spec:
selector:
matchLabels:
app: myApp
replicas: 1
template:
metadata:
labels:
app: myApp
spec:
containers:
- name: myApp
image: somecr.azurecr.io/myApp:1.0.0.30
resources:
limits:
memory: "64Mi"
cpu: "100m"
ports:
- containerPort: 5100
env:
- name: ASPNETCORE_HOSTINGSTARTUPASSEMBLIES
value: "Microsoft.AspNetCore.ApplicationInsights.HostingStartup"
- name: "ApplicationInsights__ConnectionString"
value: "myKey"
---
apiVersion: v1
kind: Service
metadata:
namespace: en02
name: myApp
spec:
selector:
app: myApp
ports:
- port: 30153
targetPort: 5100
protocol: TCP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: en02
name: etopia
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/health-probe-path: "/api/home"
spec:
rules:
- http:
paths:
- path: /myApp/
backend:
service:
name: myApp
port:
number: 30153
pathType: Exact
kubectl describe ingress -n en02
的结果
Name: ingress
Labels: <none>
Namespace: en02
Address: public-ip
Ingress Class: <none>
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
*
/myApp/ myApp:30153 (10.0.0.106:5100)
Annotations: appgw.ingress.kubernetes.io/health-probe-path: /api/home
kubernetes.io/ingress.class: azure/application-gateway
Events: <none>
我从10.0.0.106:5100/api/home
获得预期结果,应用程序网关健康状态为 200。
无论我做什么,我总是得到 Bad Gateway 错误,我能够访问端口 80(入口路径是 /)上的示例应用程序,但是如果我在入口路径(/cashify/)中指定任何内容,它总是给我不好网关。
我尝试将 readinessProbe 添加到容器,但它不起作用(但是我已经在应用程序网关健康状态下获得 200)。
请帮忙。
请检查以下是否可以解决。
请尝试更新部署 yaml 以使用通配符路径规范来访问具有不同路径的 api。
部署.yml
apiVersion: extensions/v1beta1
kind: Ingress
....
annotations:
kubernetes.io/ingress.class: azure/application-gateway
spec:
rules:
- host: xxx
http:
paths:
- path: /api/* #wild card path
backend:
serviceName: apiservice
servicePort: 80
- backend:
.....
servicePort: 80
MS 文档中的注释:如果您希望应用程序网关探测不同的协议、主机名或路径并将不同的状态代码识别为健康,请配置自定义探测并将其与 HTTP 设置相关联。
正如您所说,您已经定义了readinessProbe ,请检查这些探针的路径是否正确。
检查与 1. livenessProbe 2. readinessProbe 相同
参考:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.