Skip to content

Commit

Permalink
Add SnippetsFilter guide (#2721)
Browse files Browse the repository at this point in the history
Add SnippetsFilters guide.

Problem: We want a guide for using SnippetsFilters.

Solution: Add a SnippetsFilters guide.

Testing: Verified using make watch Hugo command.
  • Loading branch information
bjee19 authored Nov 12, 2024
1 parent a48a1ea commit 30ebe68
Show file tree
Hide file tree
Showing 8 changed files with 607 additions and 87 deletions.
2 changes: 1 addition & 1 deletion examples/snippets-filter/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SnippetsFilter

This directory contains example YAMLs for testing SnippetsFilter. Eventually, this will be converted into a how-to guide.
This directory contains the YAML files used in the [SnippetsFilter API](https://docs.nginx.com/nginx-gateway-fabric/how-to/traffic-management/snippets/) guide.
65 changes: 65 additions & 0 deletions examples/snippets-filter/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: coffee
spec:
replicas: 1
selector:
matchLabels:
app: coffee
template:
metadata:
labels:
app: coffee
spec:
containers:
- name: coffee
image: nginxdemos/nginx-hello:plain-text
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: coffee
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
name: http
selector:
app: coffee
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tea
spec:
replicas: 1
selector:
matchLabels:
app: tea
template:
metadata:
labels:
app: tea
spec:
containers:
- name: tea
image: nginxdemos/nginx-hello:plain-text
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: tea
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
name: http
selector:
app: tea
86 changes: 0 additions & 86 deletions examples/snippets-filter/example.yaml

This file was deleted.

11 changes: 11 additions & 0 deletions examples/snippets-filter/gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: gateway
spec:
gatewayClassName: nginx
listeners:
- name: http
port: 80
protocol: HTTP
hostname: "*.example.com"
37 changes: 37 additions & 0 deletions examples/snippets-filter/httproutes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: coffee
spec:
parentRefs:
- name: gateway
sectionName: http
hostnames:
- "cafe.example.com"
rules:
- matches:
- path:
type: PathPrefix
value: /coffee
backendRefs:
- name: coffee
port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: tea
spec:
parentRefs:
- name: gateway
sectionName: http
hostnames:
- "cafe.example.com"
rules:
- matches:
- path:
type: PathPrefix
value: /tea
backendRefs:
- name: tea
port: 80
10 changes: 10 additions & 0 deletions examples/snippets-filter/no-delay-rate-limiting-sf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: gateway.nginx.org/v1alpha1
kind: SnippetsFilter
metadata:
name: no-delay-rate-limiting-sf
spec:
snippets:
- context: http
value: limit_req_zone $binary_remote_addr zone=no-delay-rate-limiting-sf:10m rate=1r/s;
- context: http.server.location
value: limit_req zone=no-delay-rate-limiting-sf burst=3 nodelay;
10 changes: 10 additions & 0 deletions examples/snippets-filter/rate-limiting-sf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: gateway.nginx.org/v1alpha1
kind: SnippetsFilter
metadata:
name: rate-limiting-sf
spec:
snippets:
- context: http
value: limit_req_zone $binary_remote_addr zone=rate-limiting-sf:10m rate=1r/s;
- context: http.server.location
value: limit_req zone=rate-limiting-sf burst=3;
Loading

0 comments on commit 30ebe68

Please sign in to comment.