the sample ingress spec error

This commit is contained in:
Hui Chen 2018-10-19 11:44:45 +08:00
parent 85424d4af3
commit 32b95be1bb

View file

@ -12,22 +12,22 @@ kind: Ingress
metadata: metadata:
name: test-ingress name: test-ingress
annotations: annotations:
nginx.ingress.kubernetes.io/use-regex: true nginx.ingress.kubernetes.io/use-regex: "true"
spec: spec:
host: test.com
rules: rules:
- http: - host: test.com
paths: http:
- path: /foo/.* paths:
backend: - path: /foo/.*
serviceName: test backend:
servicePort: 80 serviceName: test
servicePort: 80
``` ```
The preceding ingress definition would translate to the following location block within the NGINX configuration for the `test.com` server: The preceding ingress definition would translate to the following location block within the NGINX configuration for the `test.com` server:
```txt ```txt
location ~* ^/foo/.* { location ~* "^/foo/.*" {
... ...
} }
``` ```
@ -48,18 +48,18 @@ kind: Ingress
metadata: metadata:
name: test-ingress-1 name: test-ingress-1
spec: spec:
host: test.com
rules: rules:
- http: - host: test.com
paths: http:
- path: /foo/bar paths:
backend: - path: /foo/bar
serviceName: test backend:
servicePort: 80 serviceName: test
- path: /foo/bar/ servicePort: 80
backend: - path: /foo/bar/
serviceName: test backend:
servicePort: 80 serviceName: test
servicePort: 80
``` ```
```yaml ```yaml
@ -70,37 +70,37 @@ metadata:
annotations: annotations:
nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/rewrite-target: /
spec: spec:
host: test.com
rules: rules:
- http: - host: test.com
paths: http:
- path: /foo/bar/.+ paths:
backend: - path: /foo/bar/.+
serviceName: test backend:
servicePort: 80 serviceName: test
servicePort: 80
``` ```
The ingress controller would define the following location blocks, in order of descending length, within the NGINX template for the `test.com` server: The ingress controller would define the following location blocks, in order of descending length, within the NGINX template for the `test.com` server:
```txt ```txt
location ~* ^/foo/bar/.+\/?(?<baseuri>.*) { location ~* "^/foo/bar/.+\/?(?<baseuri>.*)" {
... ...
} }
location ~* ^/foo/bar/ { location ~* "^/foo/bar/" {
... ...
} }
location ~* ^/foo/bar { location ~* "^/foo/bar" {
... ...
} }
``` ```
The following request URI's would match the corresponding location blocks: The following request URI's would match the corresponding location blocks:
- `test.com/foo/bar/1` matches `~* ^/foo/bar/.+\/?(?<baseuri>.*)` - `test.com/foo/bar/1` matches `~* "^/foo/bar/.+\/?(?<baseuri>.*)"`
- `test.com/foo/bar/` matches `~* ^/foo/bar/` - `test.com/foo/bar/` matches `~* "^/foo/bar/"`
- `test.com/foo/bar` matches `~* ^/foo/bar` - `test.com/foo/bar` matches `~* "^/foo/bar"`
**IMPORTANT NOTES**: **IMPORTANT NOTES**:
@ -121,32 +121,32 @@ Let the following ingress be defined:
apiVersion: extensions/v1beta1 apiVersion: extensions/v1beta1
kind: Ingress kind: Ingress
metadata: metadata:
name: test-ingress-1 name: test-ingress-3
annotations: annotations:
nginx.ingress.kubernetes.io/use-regex: true nginx.ingress.kubernetes.io/use-regex: "true"
spec: spec:
host: test.com
rules: rules:
- http: - host: test.com
paths: http:
- path: /foo/bar/bar paths:
backend: - path: /foo/bar/bar
serviceName: test backend:
servicePort: 80 serviceName: test
- path: /foo/bar/[A-Z0-9]{3} servicePort: 80
backend: - path: /foo/bar/[A-Z0-9]{3}
serviceName: test backend:
servicePort: 80 serviceName: test
servicePort: 80
``` ```
The ingress controller would define the following location blocks (in this order) within the NGINX template for the `test.com` server: The ingress controller would define the following location blocks (in this order) within the NGINX template for the `test.com` server:
```txt ```txt
location ~* ^/foo/bar/[A-Z0-9]{3} { location ~* "^/foo/bar/[A-Z0-9]{3}" {
... ...
} }
location ~* ^/foo/bar/bar { location ~* "^/foo/bar/bar" {
... ...
} }
``` ```