fix ingress syntax. (#7867)

This commit is contained in:
counter2015 2021-11-02 08:12:58 +08:00 committed by GitHub
parent e34ca93ad6
commit ed34f6c93d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 204 additions and 105 deletions

View file

@ -100,7 +100,7 @@ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main
## Create an ingress (please add any additional annotation required) ## Create an ingress (please add any additional annotation required)
echo " echo "
apiVersion: networking.k8s.io/v1beta1 apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
metadata: metadata:
name: foo-bar name: foo-bar
@ -109,10 +109,13 @@ echo "
- host: foo.bar - host: foo.bar
http: http:
paths: paths:
- backend: - path: /
serviceName: http-svc pathType: Prefix
servicePort: 80 backend:
path: / service:
name: http-svc
port:
number: 80
" | kubectl apply -f - " | kubectl apply -f -
## make a request ## make a request

View file

@ -15,10 +15,13 @@ spec:
- host: stickyingress-samesite-none.example.com - host: stickyingress-samesite-none.example.com
http: http:
paths: paths:
- backend: - path: /
serviceName: http-svc pathType: Prefix
servicePort: 80 backend:
path: / service:
name: http-svc
port:
number: 80
--- ---
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
@ -35,7 +38,10 @@ spec:
- host: stickyingress-samesite-strict.example.com - host: stickyingress-samesite-strict.example.com
http: http:
paths: paths:
- backend: - path: /
serviceName: http-svc pathType: Prefix
servicePort: 80 backend:
path: / service:
name: http-svc
port:
number: 80

View file

@ -13,7 +13,10 @@ spec:
- host: stickyingress.example.com - host: stickyingress.example.com
http: http:
paths: paths:
- backend: - path: /
serviceName: http-svc pathType: Prefix
servicePort: 80 backend:
path: / service:
name: http-svc
port:
number: 80

View file

@ -47,9 +47,12 @@ spec:
http: http:
paths: paths:
- path: / - path: /
pathType: Prefix
backend: backend:
serviceName: http-svc service:
servicePort: 80 name: http-svc
port:
number: 80
" | kubectl create -f - " | kubectl create -f -
``` ```

View file

@ -19,10 +19,13 @@ spec:
- host: mydomain.com - host: mydomain.com
http: http:
paths: paths:
- backend: - path: /
serviceName: http-svc pathType: Prefix
servicePort: 80 backend:
path: / service:
name: http-svc
port:
number: 80
tls: tls:
- hosts: - hosts:
- mydomain.com - mydomain.com

View file

@ -30,10 +30,13 @@ spec:
- host: external-auth-01.sample.com - host: external-auth-01.sample.com
http: http:
paths: paths:
- backend: - path: /
serviceName: http-svc pathType: Prefix
servicePort: 80 backend:
path: / service:
name: http-svc
port:
number: 80
status: status:
loadBalancer: loadBalancer:
ingress: ingress:

View file

@ -9,7 +9,10 @@ spec:
- host: external-auth-01.sample.com - host: external-auth-01.sample.com
http: http:
paths: paths:
- backend: - path: /
serviceName: http-svc pathType: Prefix
servicePort: 80 backend:
path: / service:
name: http-svc
port:
number: 80

View file

@ -11,11 +11,13 @@ spec:
- host: __INGRESS_HOST__ - host: __INGRESS_HOST__
http: http:
paths: paths:
- backend: - path: /
serviceName: kubernetes-dashboard pathType: Prefix
servicePort: 80 backend:
path: / service:
name: kubernetes-dashboard
port:
number: 80
--- ---
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
@ -28,10 +30,13 @@ spec:
- host: __INGRESS_HOST__ - host: __INGRESS_HOST__
http: http:
paths: paths:
- backend: - path: /oauth2
serviceName: oauth2-proxy pathType: Prefix
servicePort: 4180 backend:
path: /oauth2 service:
name: oauth2-proxy
port:
number: 4180
tls: tls:
- hosts: - hosts:
- __INGRESS_HOST__ - __INGRESS_HOST__

View file

@ -64,7 +64,15 @@ metadata:
name: nginxhello-ingress name: nginxhello-ingress
namespace: default namespace: default
spec: spec:
rules:
- host: foo.bar.com
http:
paths:
- path: /
pathType: Prefix
backend: backend:
serviceName: nginxhello service:
servicePort: 80 name: nginxhello
port:
number: 80

View file

@ -10,7 +10,10 @@ spec:
- host: custom.configuration.com - host: custom.configuration.com
http: http:
paths: paths:
- backend: - path: /
serviceName: http-svc pathType: Prefix
servicePort: 80 backend:
path: / service:
name: http-svc
port:
number: 80

View file

@ -56,10 +56,13 @@ spec:
- host: public-demo-echo-service.kube.local - host: public-demo-echo-service.kube.local
http: http:
paths: paths:
- backend: - path: /
serviceName: demo-echo-service pathType: Prefix
servicePort: 80 backend:
path: / service:
name: demo-echo-service
port:
number: 80
--- ---
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
@ -74,7 +77,10 @@ spec:
- host: secure-demo-echo-service.kube.local - host: secure-demo-echo-service.kube.local
http: http:
paths: paths:
- backend: - path: /
serviceName: demo-echo-service pathType: Prefix
servicePort: 80 backend:
path: / service:
name: demo-echo-service
port:
number: 80

View file

@ -17,7 +17,10 @@ spec:
- host: registry.<your domain> - host: registry.<your domain>
http: http:
paths: paths:
- backend: - path: /
serviceName: docker-registry pathType: Prefix
servicePort: 5000 backend:
path: / service:
name: docker-registry
port:
number: 5000

View file

@ -12,7 +12,10 @@ spec:
- host: registry.<your domain> - host: registry.<your domain>
http: http:
paths: paths:
- backend: - path: /
serviceName: docker-registry pathType: Prefix
servicePort: 5000 backend:
path: / service:
name: docker-registry
port:
number: 5000

View file

@ -115,14 +115,20 @@ spec:
- host: foo.bar.com - host: foo.bar.com
http: http:
paths: paths:
- backend: - path: /
serviceName: http-svc pathType: Prefix
servicePort: 80 backend:
path: / service:
name: http-svc
port:
number: 80
- host: bar.baz.com - host: bar.baz.com
http: http:
paths: paths:
- backend: - path: /
serviceName: nginx pathType: Prefix
servicePort: 80 backend:
path: / service
name: nginx
port:
number: 80

View file

@ -46,10 +46,13 @@ spec:
- host: rewrite.bar.com - host: rewrite.bar.com
http: http:
paths: paths:
- backend: - path: /something(/|$)(.*)
serviceName: http-svc pathType: Prefix
servicePort: 80 backend:
path: /something(/|$)(.*) service:
name: http-svc
port:
number: 80
' | kubectl create -f - ' | kubectl create -f -
``` ```
@ -78,10 +81,13 @@ spec:
- host: approot.bar.com - host: approot.bar.com
http: http:
paths: paths:
- backend: - path: /
serviceName: http-svc pathType: Prefix
servicePort: 80 backend:
path: / service:
name: http-svc
port:
number: 80
" | kubectl create -f - " | kubectl create -f -
``` ```

View file

@ -9,7 +9,11 @@ spec:
rules: rules:
- http: - http:
paths: paths:
- backend: - path: /
pathType: Prefix
backend:
# This assumes http-svc exists and routes to healthy endpoints. # This assumes http-svc exists and routes to healthy endpoints.
serviceName: http-svc service:
servicePort: 80 name: http-svc
port:
number: 80

View file

@ -27,10 +27,13 @@ spec:
http: http:
paths: paths:
- path: / - path: /
pathType: Prefix
backend: backend:
# This assumes http-svc exists and routes to healthy endpoints # This assumes http-svc exists and routes to healthy endpoints
serviceName: http-svc service:
servicePort: 80 name: http-svc
port:
number: 80
``` ```
The following command instructs the controller to terminate traffic using the provided The following command instructs the controller to terminate traffic using the provided

View file

@ -14,7 +14,10 @@ spec:
http: http:
paths: paths:
- path: / - path: /
pathType: Prefix
backend: backend:
# This assumes http-svc exists and routes to healthy endpoints # This assumes http-svc exists and routes to healthy endpoints
serviceName: http-svc service:
servicePort: 80 name: http-svc
port:
number: 80

View file

@ -74,9 +74,13 @@ spec:
- host: app.example.com - host: app.example.com
http: http:
paths: paths:
- backend: - path: /
serviceName: example-service pathType: Prefix
servicePort: fastcgi backend:
service:
name: example-service
port:
name: fastcgi
``` ```
## FastCGI Ingress Annotations ## FastCGI Ingress Annotations

View file

@ -27,9 +27,12 @@ spec:
http: http:
paths: paths:
- path: /foo/.* - path: /foo/.*
pathType: Prefix
backend: backend:
serviceName: test service:
servicePort: 80 name: test
port:
number: 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:
@ -61,13 +64,19 @@ spec:
http: http:
paths: paths:
- path: /foo/bar - path: /foo/bar
pathType: Prefix
backend: backend:
serviceName: service1 service:
servicePort: 80 name: service1
port:
number: 80
- path: /foo/bar/ - path: /foo/bar/
pathType: Prefix
backend: backend:
serviceName: service2 service:
servicePort: 80 name: service2
port:
number: 80
``` ```
```yaml ```yaml
@ -83,9 +92,12 @@ spec:
http: http:
paths: paths:
- path: /foo/bar/(.+) - path: /foo/bar/(.+)
pathType: Prefix
backend: backend:
serviceName: service3 service:
servicePort: 80 name: service3
port:
number: 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:
@ -137,13 +149,19 @@ spec:
http: http:
paths: paths:
- path: /foo/bar/bar - path: /foo/bar/bar
pathType: Prefix
backend: backend:
serviceName: test service:
servicePort: 80 name: test
port:
number: 80
- path: /foo/bar/[A-Z0-9]{3} - path: /foo/bar/[A-Z0-9]{3}
pathType: Prefix
backend: backend:
serviceName: test service:
servicePort: 80 name: test
port:
number: 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:

View file

@ -189,10 +189,13 @@ In the Zipkin interface we can see the details:
- host: example.com - host: example.com
http: http:
paths: paths:
- backend: - path: /echo
serviceName: echoheaders-x pathType: Prefix
servicePort: 80 backend:
path: /echo service:
name: echoheaders-x
port:
number: 80
' | kubectl apply -f - ' | kubectl apply -f -
``` ```