-
Notifications
You must be signed in to change notification settings - Fork 111
/
ingress-hellok8s.yaml
30 lines (29 loc) · 1.2 KB
/
ingress-hellok8s.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hellok8s-ingress
annotations: # 通过注解来进一步控制nginx控制器的行为,参考 https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/
nginx.ingress.kubernetes.io/rewrite-target: / # 匹配路由后,重写为 /; 比如 /hello 重写为 /
spec:
ingressClassName: nginx # 指定ingress控制器
rules:
- http:
paths:
- path: /hello # 默认不区分大小写,匹配/hello/123 不匹配/hello123
# 路径匹配类型
# - Prefix:前缀匹配,路由直接透传不会截断;另外还有 Exact、ImplementationSpecific类型
# - Exact:精确匹配 URL 路径,且区分大小写
# - ImplementationSpecific:默认匹配方式,具体由 ingressClass 决定
pathType: Prefix
backend:
service:
name: service-hellok8s-clusterip
port:
number: 3000
- path: /httpd
pathType: Prefix
backend:
service:
name: service-httpd
port:
number: 8080