有点背景是我已经设置了Azure Kubernetes服务群集并部署了基本的.Net Core api作为部署对象。然后,我部署了一个节点端口服务以公开api,然后部署了一个nginx-controller和一个入口对象来对其进行配置。我使用入口控制器的IP路由请求,并且可以正常工作,例如http://1.2.3.4/hello-world-one/api/values。 但是,当我用生成的dns替换Ip时,以某种方式忽略了该路径,并且得到了默认的后端-从nginx控制器返回的404。预期的行为是dns将解析,然后将路径“ api / values”发送到我的服务。
有人可以帮我吗? 预先感谢。
我的部署,服务和入口配置如下。
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: test-deployment
labels:
app: test
spec:
replicas: 1
selector:
matchLabels:
app: test
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
app: test
spec:
containers:
- name: test-service
image: <my-repo>.azurecr.io/testservice
imagePullPolicy: Always
ports:
- name: tcp
containerPort: 80
imagePullSecrets:
- name: regsecret
---
apiVersion: v1
kind: Service
metadata:
name: frontend
spec:
type: NodePort
selector:
app: test
ports:
- name: http
port: 32768
targetPort: 80
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hello-world-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.global-static-ip-name: dev-pip-usw-qa-aks
kubernetes.io/ingress.class: addon-http-application-routing
spec:
rules:
- host: hello-world-ingress.be543d4af69d4c7ca489.westus.aksapp.io
- http:
paths:
- path: /
backend:
serviceName: frontend
servicePort: http
- path: /hello-world-one
backend:
serviceName: frontend
servicePort: http
- path: /hello-world-two
backend:
serviceName: frontend
servicePort: http
答案 0 :(得分:1)
非常确定rules
应该看起来像这样:
rules:
- host: hello-world-ingress.be543d4af69d4c7ca489.westus.aksapp.io
http:
paths:
- path: /
backend:
serviceName: frontend
servicePort: http
- path: /hello-world-one
backend:
serviceName: frontend
servicePort: http
- path: /hello-world-two
backend:
serviceName: frontend
servicePort: http
阅读:https://kubernetes.io/docs/concepts/services-networking/ingress/#types-of-ingress