Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for static cache config (palm) #115

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/environments/enabled/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,19 @@ DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS_WORKER: 50
DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS: 50
DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS_WORKER: 50
DRYDOCK_MIGRATE_FROM: 13
LMS_HOST: local.edly.io
CMS_HOST: studio.local.edly.io
MFE_HOST: apps.local.edly.io
NGINX_STATIC_CACHE_CONFIG:
lms:
host: "{{LMS_HOST}}"
path: /static/
port: 8000
cms:
host: "{{CMS_HOST}}"
path: /static/
port: 8000
mfe:
host: "{{MFE_HOST}}"
path: /
port: 8002
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ The following configuration options are available:
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_LMS_WORKER` : The minimum available percentage for the LMS WORKER's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS` : The minimum available percentage for the CMS's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `DRYDOCK_PDB_MINAVAILABLE_PERCENTAGE_CMS_WORKER` : The minimum available percentage for the worker's PodDisruptionBudget. To disable the PodDisruptionBudget, set `0`. Defaults to `0`.
- `NGINX_STATIC_CACHE_CONFIG`: A list of dictionaries with settings for different services to cache their assets in NGINX.
The following is an example of the expected values:
```yaml
NGINX_STATIC_CACHE_CONFIG:
{{service_name}}:
host: {{service_host}} # e.g: {{LMS_HOST}}
path: /static/ # you can specify a different path
port: {{service_port}} # only needed if you have DRYDOCK_BYPASS_CADDY enabled
```

.. note::
You also need to set `DRYDOCK_INIT_JOBS` to `true` to enable the release-specific upgrade jobs in the case of a platform migration.
Expand Down
1 change: 1 addition & 0 deletions drydock/patches/kustomization-resources
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- plugins/drydock/k8s/ingress/cms.yml
- plugins/drydock/k8s/ingress/mfe.yml
- plugins/drydock/k8s/ingress/extra-hosts.yml
- plugins/drydock/k8s/ingress/static-cache.yml
{%- endif %}
{% if DRYDOCK_DEBUG -%}
- plugins/drydock/k8s/debug/deployments.yml
Expand Down
Empty file.
1 change: 1 addition & 0 deletions drydock/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def get_sync_waves_for_resource(resource_name: str) -> SYNC_WAVES_ORDER_ATTRS_TY
"PDB_MINAVAILABLE_PERCENTAGE_MFE": 0,
"PDB_MINAVAILABLE_PERCENTAGE_FORUM": 0,
"PDB_MINAVAILABLE_PERCENTAGE_CADDY": 0,
"NGINX_STATIC_CACHE_CONFIG": {},
},
# Add here settings that don't have a reasonable default for all users. For
# instance: passwords, secret keys, etc.
Expand Down
33 changes: 33 additions & 0 deletions drydock/templates/drydock/k8s/ingress/static-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{%- for service, config in DRYDOCK_NGINX_STATIC_CACHE_CONFIG.items() %}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-static-{{ service }}
namespace: {{ K8S_NAMESPACE }}
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: 8m
nginx.ingress.kubernetes.io/proxy-buffering: "on"
nginx.ingress.kubernetes.io/configuration-snippet: |
# Cache settings
proxy_cache_valid 404 10m;
proxy_cache_use_stale error timeout updating http_404 http_500 http_502 http_503 http_504;
proxy_cache static-cache;
proxy_cache_valid any 120m;
proxy_cache_bypass $http_x_purge;
add_header X-Cache-Status $upstream_cache_status;
{{ patch("static-cache-config") | indent(6)}}
spec:
ingressClassName: nginx
rules:
- host: {{ config["host"] }}
http:
paths:
- pathType: Prefix
path: {{ config["path"]}}
backend:
service:
name: {% if DRYDOCK_BYPASS_CADDY -%}{{ service }}{% else -%}caddy{% endif %}
port:
number: {% if DRYDOCK_BYPASS_CADDY -%}{{ config["port"] }}{% else -%}80{% endif %}
{%- endfor %}
Loading