@annotations @router.header @release-1.22

Feature: Header rules

An Ingress may define routing rules based on the request path and header. If the HTTP request path matches the paths and header info in the Ingress objects, the traffic is routed to its backend service.

Scenarios
Status Progress

Passed

100.00%

Failed

0.00%
check_circle
Given 10s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: "h_key:h_value"
spec:
rules:
- host: "exact-path-header-key"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: exact-h-key
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://exact-path-header-key/ with header +Show Parameter
{"h_key": ["h_value"]}
check_circle
Then 0s the response status-code must be 200
check_circle
And 0s the response must be served by the exact-h-key service
check_circle
Given 5s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: "h_key:h_value"
spec:
rules:
- host: "exact-path-no-header"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: exact-h-key
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://exact-path-no-header/
check_circle
Then 0s the response status-code must be 500
check_circle
Given 10s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: ""
spec:
rules:
- host: "header-null"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: h-key-null
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://header-null/ with header +Show Parameter
{"h_key": ["h_value"]}
check_circle
Then 0s the response status-code must be 200
check_circle
And 0s the response must be served by the h-key-null service
check_circle
Given 5s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: ""
spec:
rules:
- host: "header-null"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: h-key-null-without-header
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://header-null/
check_circle
Then 0s the response status-code must be 200
check_circle
And 0s the response must be served by the h-key-null-without-header service
Scenario: An Ingress with path rules and header should send traffic to the matching backend service

(exact / and header only key matches request / with header only key)

check_circle
Given 5s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: "h-key"
spec:
rules:
- host: "header-only-key"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: header-only-key
port:
number: 3000
check_circle
And 3s The Ingress status should not be success
check_circle
Given 10s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: "h-key"
spec:
rules:
- host: "header-only-key"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: header-only-key-no-header
port:
number: 3000
check_circle
And 0s The Ingress status should not be success
check_circle
Given 10s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: "User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
spec:
rules:
- host: "header-normal-user-agent"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: header-normal-right
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://header-normal-user-agent/ with header +Show Parameter
{"User-Agent": ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"]}
check_circle
Then 0s the response status-code must be 200
check_circle
And 0s the response must be served by the header-normal-right service
Scenario: An Ingress with path rules and header should send traffic to the matching backend service

(exact / and header normal dose not matches request / without header)

check_circle
Given 10s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: "user-agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
spec:
rules:
- host: "header-normal"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: header-normal-right
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://header-normal/
check_circle
Then 0s the response status-code must be 500
check_circle
Given 5s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: "a:b:c"
spec:
rules:
- host: "header-a-b-c"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: header-a-b-c-right
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://header-a-b-c/ with header +Show Parameter
{"a": ["b:c"]}
check_circle
Then 0s the response status-code must be 200
check_circle
And 0s the response must be served by the header-a-b-c-right service
Scenario: An Ingress with path rules and header should send traffic to the matching backend service

(exact / and header a:b:c dose not matches request / without header)

check_circle
Given 5s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: "a:b:c"
spec:
rules:
- host: "header-a-b-c-without"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: without-header-a-b-c
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://header-a-b-c-without/
check_circle
Then 0s the response status-code must be 500
check_circle
Given 5s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: "a:+/?%#&"
spec:
rules:
- host: "header-special-character"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: header-special-character-right
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://header-special-character/ with header +Show Parameter
{"a": ["+/?%#&"]}
check_circle
Then 0s the response status-code must be 200
check_circle
And 0s the response must be served by the header-special-character-right service
check_circle
Given 10s an Ingress resource in a new random namespace +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: header-rules
annotations:
bfe.ingress.kubernetes.io/router.header: "a:+/?%#&"
spec:
rules:
- host: "header-special-character-no"
http:
paths:
- path: /
pathType: Exact
backend:
service:
name: header-special-character-no
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://header-special-character-no/
check_circle
Then 0s the response status-code must be 500