Skip to content

Commit ebe34ec

Browse files
committed
feat: add support for static cache config
1 parent 7bd3266 commit ebe34ec

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

drydock/patches/kustomization-resources

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- plugins/drydock/k8s/ingress/cms.yml
1313
- plugins/drydock/k8s/ingress/mfe.yml
1414
- plugins/drydock/k8s/ingress/extra-hosts.yml
15+
{% if DRYDOCK_NGINX_STATIC_CACHE_CONFIG %}- plugins/drydock/k8s/ingress/static-cache.yml{%- endif %}
1516
{%- endif %}
1617
{% if DRYDOCK_DEBUG -%}
1718
- plugins/drydock/k8s/debug/deployments.yml

drydock/patches/static-cache-config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Cache settings
2+
proxy_cache_valid 404 10m;
3+
proxy_cache_use_stale error timeout updating http_404 http_500 http_502 http_503 http_504;
4+
proxy_cache static-cache;
5+
proxy_cache_valid any 120m;
6+
proxy_cache_bypass $http_x_purge;
7+
add_header X-Cache-Status $upstream_cache_status;

drydock/plugin.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@ def get_sync_waves_for_resource(resource_name: str) -> SYNC_WAVES_ORDER_ATTRS_TY
162162
"lms-worker",
163163
"cms-worker",
164164
],
165+
"NGINX_STATIC_CACHE_CONFIG": {
166+
"lms": {
167+
"host": "{{ LMS_HOST }}",
168+
"path": "/static/",
169+
"port": 8000,
170+
},
171+
"cms": {
172+
"host": "{{ CMS_HOST }}",
173+
"path": "/static/",
174+
"port": 8000,
175+
},
176+
},
165177
},
166178
# Add here settings that don't have a reasonable default for all users. For
167179
# instance: passwords, secret keys, etc.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{%- for service, config in DRYDOCK_NGINX_STATIC_CACHE_CONFIG.items() %}
2+
---
3+
apiVersion: networking.k8s.io/v1
4+
kind: Ingress
5+
metadata:
6+
name: ingress-static-{{ service }}
7+
namespace: {{ K8S_NAMESPACE }}
8+
annotations:
9+
nginx.ingress.kubernetes.io/proxy-body-size: 8m
10+
nginx.ingress.kubernetes.io/proxy-buffering: "on"
11+
nginx.ingress.kubernetes.io/configuration-snippet: |
12+
{{ patch("static-cache-config") | indent(6)}}
13+
spec:
14+
ingressClassName: nginx
15+
rules:
16+
- host: {{ config["host"] }}
17+
http:
18+
paths:
19+
- pathType: Prefix
20+
path: {{ config["path"]}}
21+
backend:
22+
service:
23+
name: {% if DRYDOCK_BYPASS_CADDY -%}{{ service }}{% else -%}caddy{% endif %}
24+
port:
25+
number: {% if DRYDOCK_BYPASS_CADDY -%}{{ config["port"] }}{% else -%}80{% endif %}
26+
{%- endfor %}

0 commit comments

Comments
 (0)