Skip to content

Commit

Permalink
Enable proxy caching
Browse files Browse the repository at this point in the history
  • Loading branch information
meezaan committed Dec 29, 2022
1 parent 44e648e commit 167577e
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 51 deletions.
49 changes: 34 additions & 15 deletions .k8s/manifest-dallas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,6 @@ spec:
- port: "metrics"
interval: 30s
---
# Service
apiVersion: v1
kind: Service
metadata:
name: alquran-cloud-api
namespace: alquran-cloud
annotations:
konghq.com/plugins: rate-limiting-alquran-api
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: alquran-cloud-api
---
apiVersion: v1
kind: Service
metadata:
Expand Down Expand Up @@ -105,7 +90,26 @@ config:
policy: redis
redis_host: redis-master
redis_port: 6379
limit_by: ip
plugin: rate-limiting
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: proxy-cache-alquran-api
namespace: alquran-cloud
config:
response_code:
- 200
- 400
- 301
request_method:
- GET
content_type:
- application/json
cache_ttl: 86400
strategy: memory
plugin: proxy-cache
# Deployment
---
apiVersion: apps/v1
Expand Down Expand Up @@ -194,6 +198,21 @@ spec:
- containerPort: 8080
protocol: TCP
---
# Service
apiVersion: v1
kind: Service
metadata:
name: alquran-cloud-api
namespace: alquran-cloud
annotations:
konghq.com/plugins: rate-limiting-alquran-api, proxy-cache-alquran-api
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: alquran-cloud-api
---
# HPA
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
Expand Down
65 changes: 42 additions & 23 deletions .k8s/manifest-london.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,63 @@ spec:
- port: "metrics"
interval: 30s
---
# Service
apiVersion: v1
kind: Service
metadata:
name: alquran-cloud-api
name: alquran-cloud-api-memcached
namespace: alquran-cloud
annotations:
konghq.com/plugins: rate-limiting-alquran-api
spec:
ports:
- port: 80
targetPort: 8080
- port: 11211
targetPort: 11211
selector:
app: alquran-cloud-api
app: alquran-cloud-api-memcached
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: rate-limiting-alquran-api
namespace: alquran-cloud
config:
second: 5 # 2 Ingress Pods. 60 requests per minute per IP - so 4 requests per IP per second, effectively.
policy: redis
redis_host: redis-master
redis_port: 6379
limit_by: ip
plugin: rate-limiting
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: proxy-cache-alquran-api
namespace: alquran-cloud
config:
response_code:
- 200
- 400
- 301
request_method:
- GET
content_type:
- application/json
cache_ttl: 86400
strategy: memory
plugin: proxy-cache
---
# Service
apiVersion: v1
kind: Service
metadata:
name: alquran-cloud-api-memcached
name: alquran-cloud-api
namespace: alquran-cloud
annotations:
konghq.com/plugins: rate-limiting-alquran-api, proxy-cache-alquran-api
spec:
ports:
- port: 11211
targetPort: 11211
- port: 80
targetPort: 8080
selector:
app: alquran-cloud-api-memcached
app: alquran-cloud-api
---
apiVersion: v1
kind: Service
Expand All @@ -94,18 +125,6 @@ spec:
- name: metrics
port: 9117
targetPort: 9117
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: rate-limiting-alquran-api
namespace: alquran-cloud
config:
second: 5 # 2 Ingress Pods. 60 requests per minute per IP - so 4 requests per IP per second, effectively.
policy: redis
redis_host: redis-master
redis_port: 6379
plugin: rate-limiting
# Deployment
---
apiVersion: apps/v1
Expand Down
45 changes: 32 additions & 13 deletions .k8s/manifest-singapore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,45 @@ spec:
- port: "metrics"
interval: 30s
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: rate-limiting-alquran-api
namespace: alquran-cloud
config:
second: 5 # 2 Ingress Pods. 60 requests per minute per IP - so 4 requests per IP per second, effectively.
policy: redis
redis_host: redis-master
redis_port: 6379
limit_by: ip
plugin: rate-limiting
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: proxy-cache-alquran-api
namespace: alquran-cloud
config:
response_code:
- 200
- 400
- 301
request_method:
- GET
content_type:
- application/json
cache_ttl: 86400
strategy: memory
plugin: proxy-cache
---
# Service
apiVersion: v1
kind: Service
metadata:
name: alquran-cloud-api
namespace: alquran-cloud
annotations:
konghq.com/plugins: rate-limiting-alquran-api
konghq.com/plugins: rate-limiting-alquran-api, proxy-cache-alquran-api
spec:
ports:
- port: 80
Expand Down Expand Up @@ -94,18 +125,6 @@ spec:
- name: metrics
port: 9117
targetPort: 9117
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: rate-limiting-alquran-api
namespace: alquran-cloud
config:
second: 5 # 2 Ingress Pods. 60 requests per minute per IP - so 4 requests per IP per second, effectively.
policy: redis
redis_host: redis-master
redis_port: 6379
plugin: rate-limiting
# Deployment
---
apiVersion: apps/v1
Expand Down

0 comments on commit 167577e

Please sign in to comment.