[英]nginx ingress redirect traffic
I deployed nginx ingress controller and randomApp to minikube cluster.我将 nginx 入口 controller 和 randomApp 部署到 minikube 集群。 I have 2 requirements:
我有两个要求:
This configuration is correct?这个配置正确吗?
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: path-rule-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
defaultBackend:
service:
name: ingress-nginx-controller
port:
number: 80
rules:
- host: random.localdev.me
http:
paths:
- path: /random/(.*)
backend:
service:
name: random
port:
number: 8000
pathType: Prefix
You also need to add metadata.annotations: kubernetes.io/ingress.class: "nginx"
or spec.ingressClassName: nginx
to allow nginx-ingress-controller to discover the ingress.您还需要添加
metadata.annotations: kubernetes.io/ingress.class: "nginx"
或spec.ingressClassName: nginx
以允许 ingress.nginx-ingress-controller 发现
Also you shouldn't define default backend service as ingress-nginx-controller.此外,您不应将默认后端服务定义为 ingress-nginx-controller。 Because you will get
503 Service Temporarily Unavailable
since nginx-ingress-controller
's nginx.conf
didn't be configured for this.因为你会得到
503 Service Temporarily Unavailable
因为nginx-ingress-controller
的nginx.conf
没有为此配置。 You can give another nginx server's service for it.您可以为它提供另一个 nginx 服务器的服务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.