Skip to content

Commit 30ebe68

Browse files
authored
Add SnippetsFilter guide (#2721)
Add SnippetsFilters guide. Problem: We want a guide for using SnippetsFilters. Solution: Add a SnippetsFilters guide. Testing: Verified using make watch Hugo command.
1 parent a48a1ea commit 30ebe68

File tree

8 files changed

+607
-87
lines changed

8 files changed

+607
-87
lines changed

examples/snippets-filter/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# SnippetsFilter
22

3-
This directory contains example YAMLs for testing SnippetsFilter. Eventually, this will be converted into a how-to guide.
3+
This directory contains the YAML files used in the [SnippetsFilter API](https://docs.nginx.com/nginx-gateway-fabric/how-to/traffic-management/snippets/) guide.

examples/snippets-filter/app.yaml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: coffee
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: coffee
10+
template:
11+
metadata:
12+
labels:
13+
app: coffee
14+
spec:
15+
containers:
16+
- name: coffee
17+
image: nginxdemos/nginx-hello:plain-text
18+
ports:
19+
- containerPort: 8080
20+
---
21+
apiVersion: v1
22+
kind: Service
23+
metadata:
24+
name: coffee
25+
spec:
26+
ports:
27+
- port: 80
28+
targetPort: 8080
29+
protocol: TCP
30+
name: http
31+
selector:
32+
app: coffee
33+
---
34+
apiVersion: apps/v1
35+
kind: Deployment
36+
metadata:
37+
name: tea
38+
spec:
39+
replicas: 1
40+
selector:
41+
matchLabels:
42+
app: tea
43+
template:
44+
metadata:
45+
labels:
46+
app: tea
47+
spec:
48+
containers:
49+
- name: tea
50+
image: nginxdemos/nginx-hello:plain-text
51+
ports:
52+
- containerPort: 8080
53+
---
54+
apiVersion: v1
55+
kind: Service
56+
metadata:
57+
name: tea
58+
spec:
59+
ports:
60+
- port: 80
61+
targetPort: 8080
62+
protocol: TCP
63+
name: http
64+
selector:
65+
app: tea

examples/snippets-filter/example.yaml

-86
This file was deleted.

examples/snippets-filter/gateway.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: Gateway
3+
metadata:
4+
name: gateway
5+
spec:
6+
gatewayClassName: nginx
7+
listeners:
8+
- name: http
9+
port: 80
10+
protocol: HTTP
11+
hostname: "*.example.com"
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: HTTPRoute
3+
metadata:
4+
name: coffee
5+
spec:
6+
parentRefs:
7+
- name: gateway
8+
sectionName: http
9+
hostnames:
10+
- "cafe.example.com"
11+
rules:
12+
- matches:
13+
- path:
14+
type: PathPrefix
15+
value: /coffee
16+
backendRefs:
17+
- name: coffee
18+
port: 80
19+
---
20+
apiVersion: gateway.networking.k8s.io/v1
21+
kind: HTTPRoute
22+
metadata:
23+
name: tea
24+
spec:
25+
parentRefs:
26+
- name: gateway
27+
sectionName: http
28+
hostnames:
29+
- "cafe.example.com"
30+
rules:
31+
- matches:
32+
- path:
33+
type: PathPrefix
34+
value: /tea
35+
backendRefs:
36+
- name: tea
37+
port: 80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: gateway.nginx.org/v1alpha1
2+
kind: SnippetsFilter
3+
metadata:
4+
name: no-delay-rate-limiting-sf
5+
spec:
6+
snippets:
7+
- context: http
8+
value: limit_req_zone $binary_remote_addr zone=no-delay-rate-limiting-sf:10m rate=1r/s;
9+
- context: http.server.location
10+
value: limit_req zone=no-delay-rate-limiting-sf burst=3 nodelay;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: gateway.nginx.org/v1alpha1
2+
kind: SnippetsFilter
3+
metadata:
4+
name: rate-limiting-sf
5+
spec:
6+
snippets:
7+
- context: http
8+
value: limit_req_zone $binary_remote_addr zone=rate-limiting-sf:10m rate=1r/s;
9+
- context: http.server.location
10+
value: limit_req zone=rate-limiting-sf burst=3;

0 commit comments

Comments
 (0)