Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vsr route selector #6803

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ba3cc97
Attach VSR to VS by labels
haywoodsh Sep 12, 2024
d03be9f
add policy, location snippet, error page from VS to VSR for route sel…
haywoodsh Nov 13, 2024
aaaa4df
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 13, 2024
ef5dd51
fix linting issues
jjngx Nov 13, 2024
6440451
Use a separate example for testing VSR functionality
jjngx Nov 18, 2024
211dc33
Keep vsr tests separate for now
jjngx Nov 18, 2024
3f41c4f
WIP - create minimum example for VSR
jjngx Nov 18, 2024
5306def
WIP - keep VRS tests separate for now
jjngx Nov 18, 2024
8b2981d
WIP - update codegen
jjngx Nov 18, 2024
aa7e417
WIP - fix linting issues
jjngx Nov 18, 2024
bb37add
WIP - test steps cleanup
jjngx Nov 18, 2024
dde0237
WIP - make the test pass - TestAddVirtualServerVSR
jjngx Nov 18, 2024
080af69
WIP - make the test pass - TestAddVirtualServerVSR
jjngx Nov 18, 2024
b5f22b9
WIP - fix return expression
jjngx Nov 18, 2024
ecd5c62
WIP - reflect tested functionality in the test name
jjngx Nov 18, 2024
eda974b
WIP - invalid case for adding VSR
jjngx Nov 19, 2024
83df813
WIP - compare status update, not the message
jjngx Nov 19, 2024
83f508d
WIP - Add VSR to VS
jjngx Nov 19, 2024
38653ef
WIP - keep TS config tests tegether
jjngx Nov 19, 2024
6387ed4
WIP - update test steps
jjngx Nov 20, 2024
962781d
WIP - Add test for maching VSR with VS
jjngx Nov 20, 2024
d27d9b9
WIP - simplify VSR/VS examples
jjngx Nov 25, 2024
b6af91d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 25, 2024
74106db
WIP - example VSR selector basic
jjngx Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions config/crd/bases/k8s.nginx.org_virtualserverroutes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,55 @@ spec:
type: array
route:
type: string
routeSelector:
description: |-
A label selector is a label query over a set of resources. The result of matchLabels and
matchExpressions are ANDed. An empty label selector matches all objects. A null
label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: |-
A label selector requirement is a selector that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: |-
values is an array of string values. If the operator is In or NotIn,
the values array must be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
description: |-
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is "key", the
operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
splits:
items:
description: Split defines a split.
Expand Down
49 changes: 49 additions & 0 deletions config/crd/bases/k8s.nginx.org_virtualservers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,55 @@ spec:
type: array
route:
type: string
routeSelector:
description: |-
A label selector is a label query over a set of resources. The result of matchLabels and
matchExpressions are ANDed. An empty label selector matches all objects. A null
label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: |-
A label selector requirement is a selector that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: |-
values is an array of string values. If the operator is In or NotIn,
the values array must be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
description: |-
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is "key", the
operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
splits:
items:
description: Split defines a split.
Expand Down
98 changes: 98 additions & 0 deletions deploy/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,55 @@ spec:
type: array
route:
type: string
routeSelector:
description: |-
A label selector is a label query over a set of resources. The result of matchLabels and
matchExpressions are ANDed. An empty label selector matches all objects. A null
label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: |-
A label selector requirement is a selector that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: |-
values is an array of string values. If the operator is In or NotIn,
the values array must be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
description: |-
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is "key", the
operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
splits:
items:
description: Split defines a split.
Expand Down Expand Up @@ -2129,6 +2178,55 @@ spec:
type: array
route:
type: string
routeSelector:
description: |-
A label selector is a label query over a set of resources. The result of matchLabels and
matchExpressions are ANDed. An empty label selector matches all objects. A null
label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: |-
A label selector requirement is a selector that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: |-
values is an array of string values. If the operator is In or NotIn,
the values array must be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
description: |-
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is "key", the
operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
splits:
items:
description: Split defines a split.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: k8s.nginx.org/v1
kind: Policy
metadata:
name: api-key-policy
namespace: cafe
spec:
apiKey:
suppliedIn:
header:
- "X-header-name"
query:
- "queryName"
clientSecret: api-key-client-secret
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: api-key-client-secret
namespace: cafe
type: nginx.org/apikey
data:
client1: cGFzc3dvcmQ= # password
client2: YW5vdGhlci1wYXNzd29yZA== # another-password
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,28 @@ spec:
host: cafe.example.com
tls:
secret: cafe-secret
server-snippets: |
# snippet defined in VS server block
proxy_set_header X-VS-Name "Cafe";
routes:
- path: /tea
route: tea/tea
- path: /coffee
route: coffee/coffee
# - path: /tea
# route: tea/tea
# policies:
# - name: rate-limit-policy
# - path: /coffee
# route: coffee/coffee
- path: /
routeSelector:
matchLabels:
app: cafe
# route: tea
policies:
- name: api-key-policy
location-snippets: |
# snippet defined in VS
proxy_set_header X-VS-Name "Cafe";
errorPages:
- codes: [ 502, 503 ]
redirect:
code: 301
url: https://nginx.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: VirtualServerRoute
metadata:
name: coffee
namespace: coffee
labels:
app: cafe
route: coffee
spec:
host: cafe.example.com
upstreams:
Expand All @@ -13,3 +16,13 @@ spec:
- path: /coffee
action:
pass: coffee
policies:
- name: rate-limit-policy
location-snippets: |
# snippet defined in VSR
proxy_set_header X-VSR-Name "Coffee";
errorPages:
- codes: [404]
return:
code: 200
body: "Original resource not found, but success!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: k8s.nginx.org/v1
kind: Policy
metadata:
name: rate-limit-policy
namespace: coffee
spec:
rateLimit:
rate: 1r/s
key: ${binary_remote_addr}
zoneSize: 10M
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: VirtualServerRoute
metadata:
name: tea
namespace: tea
labels:
route: tea
app: cafe
spec:
host: cafe.example.com
upstreams:
Expand All @@ -13,3 +16,6 @@ spec:
- path: /tea
action:
pass: tea
# location-snippets: |
# # snippet defined in VSR
# proxy_set_header X-VSR-Name "Tea";
Loading
Loading