Skip to content

Commit a8940cc

Browse files
authored
Merge pull request #1701 from navikt/redis-page-cache-impl
Tar i bruk Redis som distribuert page cache
2 parents 12aecb5 + 4271289 commit a8940cc

33 files changed

+517
-241
lines changed

.env.development

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ NODE_ENV=development
22
ENV=localhost
33
SERVICE_SECRET=dummyToken
44
DOCKER_HOST_ADDRESS=host.docker.internal
5-
PAGE_CACHE_DIR=../.next/page-cache
65
IMAGE_CACHE_DIR=../.next/image-cache
76
ADMIN_ORIGIN=http://localhost:8080
87
APP_ORIGIN=http://localhost:3000

.env.prod-local

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ NODE_ENV=production
22
ENV=localhost
33
SERVICE_SECRET=dummyToken
44
DOCKER_HOST_ADDRESS=host.docker.internal
5-
PAGE_CACHE_DIR=../.next/page-cache
65
IMAGE_CACHE_DIR=../.next/image-cache
76
ADMIN_ORIGIN=http://localhost:8080
87
APP_ORIGIN=http://localhost:3000

.github/workflows/build-and-test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
run: npm ci --ignore-scripts
2020
env:
2121
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
22+
- name: Run linting
23+
run: npm run lint
2224
- name: Build application
2325
run: npm run build-local
2426
- name: Run tests

.github/workflows/build-image.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ jobs:
9494
INNLOGGINGSSTATUS_URL=${{ inputs.INNLOGGINGSSTATUS_URL }}
9595
NAVNO_API_URL=${{ inputs.NAVNO_API_URL }}
9696
ASSET_PREFIX=https://cdn.nav.no/personbruker/nav-enonicxp-frontend
97-
PAGE_CACHE_DIR=/tmp/pages
9897
IMAGE_CACHE_DIR=/tmp/images
9998
NEXT_TELEMETRY_DISABLED=1
10099
EOF
@@ -107,6 +106,8 @@ jobs:
107106
run: npm ci
108107
env:
109108
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
109+
- name: Run linting
110+
run: npm run lint
110111
- name: Run tests
111112
run: npm run test
112113
- name: Build application

.github/workflows/deploy-redis.yml

-28
This file was deleted.

.github/workflows/deploy-to-nais.yml

+22-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ on:
1717
hpa_file:
1818
required: false
1919
type: string
20+
deploy_redis:
21+
required: false
22+
type: boolean
2023

2124
jobs:
2225
deploy:
@@ -26,15 +29,28 @@ jobs:
2629
id-token: "write"
2730
steps:
2831
- name: Checkout repo
29-
uses: actions/checkout@v3
30-
- name: Set HPA resource if specified
32+
uses: actions/checkout@v4
33+
- name: Deploy Redis
34+
if: ${{ inputs.deploy_redis == true }}
35+
uses: nais/deploy/actions/deploy@v2
36+
timeout-minutes: 1
37+
continue-on-error: true
38+
env:
39+
CLUSTER: ${{ inputs.cluster }}
40+
RESOURCE: .nais/redis.yml
41+
VARS: .nais/vars/${{ inputs.vars_file }}
42+
- name: Deploy HPA
3143
if: ${{ inputs.hpa_file }}
32-
run: |
33-
echo "HPA_RESOURCE=,.nais/hpa/${{inputs.hpa_file}}" >> $GITHUB_ENV
34-
- name: Deploy to nais
44+
uses: nais/deploy/actions/deploy@v2
45+
timeout-minutes: 1
46+
continue-on-error: true
47+
env:
48+
CLUSTER: ${{ inputs.cluster }}
49+
RESOURCE: .nais/hpa/${{inputs.hpa_file}}
50+
- name: Deploy application
3551
uses: nais/deploy/actions/deploy@v2
3652
env:
3753
CLUSTER: ${{ inputs.cluster }}
38-
RESOURCE: .nais/${{ inputs.config_file }}${{env.HPA_RESOURCE}}
54+
RESOURCE: .nais/${{ inputs.config_file }}
3955
VAR: image=${{ inputs.image }}
4056
VARS: .nais/vars/${{ inputs.vars_file }}

.github/workflows/deploy.dev1.yml

+1
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ jobs:
4747
vars_file: vars-dev1.yml
4848
config_file: config.yml
4949
hpa_file: hpa-dev1.yml
50+
deploy_redis: true

.github/workflows/deploy.dev2.yml

+1
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ jobs:
4747
vars_file: vars-dev2.yml
4848
config_file: config.yml
4949
hpa_file: hpa-dev2.yml
50+
deploy_redis: true

.github/workflows/deploy.prod.yml

+1
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ jobs:
4040
vars_file: vars-prod.yml
4141
config_file: config.yml
4242
hpa_file: hpa-prod.yml
43+
deploy_redis: true

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ yarn-error.log*
5252

5353
# VS Code
5454
.vscode
55+
/.env.prod-local.local

.husky/pre-push

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npm run typeCheck && npm run lint
4+
npm run lint

.nais/config.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ spec:
2727
prometheus:
2828
enabled: true
2929
path: /internal/metrics
30-
# redis:
31-
# - instance: {{ redisInstance }}
32-
# access: readwrite
30+
leaderElection: true
31+
redis:
32+
- instance: {{ redis.instance }}
33+
access: readwrite
3334
ingresses:
3435
{{#each ingresses as |url|}}
3536
- {{url}}

.nais/hpa/hpa-dev1.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ kind: HorizontalPodAutoscaler
33
metadata:
44
name: nav-enonicxp-frontend-dev1
55
namespace: personbruker
6+
labels:
7+
team: personbruker
68
ownerReferences:
79
- apiVersion: nais.io/v1alpha1
810
kind: Application

.nais/hpa/hpa-dev2.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ kind: HorizontalPodAutoscaler
33
metadata:
44
name: nav-enonicxp-frontend-dev2
55
namespace: personbruker
6+
labels:
7+
team: personbruker
68
ownerReferences:
79
- apiVersion: nais.io/v1alpha1
810
kind: Application

.nais/hpa/hpa-prod-failover.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ kind: HorizontalPodAutoscaler
33
metadata:
44
name: nav-enonicxp-frontend-failover
55
namespace: personbruker
6+
labels:
7+
team: personbruker
68
ownerReferences:
79
- apiVersion: nais.io/v1alpha1
810
kind: Application

.nais/hpa/hpa-prod.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ kind: HorizontalPodAutoscaler
33
metadata:
44
name: nav-enonicxp-frontend
55
namespace: personbruker
6+
labels:
7+
team: personbruker
68
ownerReferences:
79
- apiVersion: nais.io/v1alpha1
810
kind: Application

.nais/redis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ metadata:
44
labels:
55
app: nav-enonicxp-frontend
66
team: personbruker
7-
name: redis-personbruker-{{ redisInstance }}
7+
name: redis-personbruker-{{ redis.instance }}
88
namespace: personbruker
99
spec:
10-
plan: {{ redisPlan }}
11-
project: {{ redisProject }}
10+
plan: {{ redis.plan }}
11+
project: {{ redis.project }}

.nais/vars/vars-dev1.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ resources:
1818
replicas:
1919
min: 2
2020
max: 2
21-
redisPlan: startup-4
22-
redisProject: nav-dev
23-
redisInstance: pagecache-dev1
21+
redis:
22+
plan: hobbyist
23+
project: nav-dev
24+
instance: pagecache-dev1

.nais/vars/vars-dev2.yml

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ resources:
1818
replicas:
1919
min: 1
2020
max: 2
21+
redis:
22+
plan: hobbyist
23+
project: nav-dev
24+
instance: pagecache-dev2

.nais/vars/vars-prod.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ resources:
1515
memory: 2500Mi
1616
replicas:
1717
min: 3
18-
max: 3
18+
max: 3
19+
redis:
20+
plan: startup-4
21+
project: nav-prod
22+
instance: pagecache

nodeenv.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ declare global {
1212
SERVICE_SECRET: string;
1313
REVALIDATOR_PROXY_ORIGIN: string;
1414
INNLOGGINGSSTATUS_URL: string;
15-
PAGE_CACHE_DIR: string;
1615
IMAGE_CACHE_DIR: string;
1716
FAILOVER_ORIGIN: string;
1817
IS_FAILOVER_INSTANCE: string;

0 commit comments

Comments
 (0)