![](/img/trans.png)
[英]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.