diff --git a/.k8s/manifest-dallas.yml b/.k8s/manifest-dallas.yml index 6e3e33a..57f9c87 100644 --- a/.k8s/manifest-dallas.yml +++ b/.k8s/manifest-dallas.yml @@ -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: @@ -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 @@ -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 diff --git a/.k8s/manifest-london.yml b/.k8s/manifest-london.yml index 1341882..53d6633 100644 --- a/.k8s/manifest-london.yml +++ b/.k8s/manifest-london.yml @@ -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 @@ -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 diff --git a/.k8s/manifest-singapore.yml b/.k8s/manifest-singapore.yml index b20ccf2..4c41b97 100644 --- a/.k8s/manifest-singapore.yml +++ b/.k8s/manifest-singapore.yml @@ -52,6 +52,37 @@ 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 @@ -59,7 +90,7 @@ 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 @@ -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