Skip to content

Commit 5d244cb

Browse files
committed
Redis deploy tweaks
1 parent ba42bcb commit 5d244cb

File tree

6 files changed

+26
-23
lines changed

6 files changed

+26
-23
lines changed

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ jobs:
3737
CLUSTER: ${{ inputs.cluster }}
3838
RESOURCE: .nais/redis.yml
3939
VARS: .nais/vars/${{ inputs.vars_file }}
40-
- name: Set HPA resource if specified
40+
- name: Deploy HPA
4141
if: ${{ inputs.hpa_file }}
42-
run: |
43-
echo "HPA_RESOURCE=,.nais/hpa/${{inputs.hpa_file}}" >> $GITHUB_ENV
44-
- name: Deploy to nais
4542
uses: nais/deploy/actions/deploy@v2
4643
env:
4744
CLUSTER: ${{ inputs.cluster }}
48-
RESOURCE: .nais/${{ inputs.config_file }}${{env.HPA_RESOURCE}}
45+
RESOURCE: .nais/hpa/${{inputs.hpa_file}}
46+
VARS: .nais/vars/${{ inputs.vars_file }}
47+
- name: Deploy application
48+
uses: nais/deploy/actions/deploy@v2
49+
env:
50+
CLUSTER: ${{ inputs.cluster }}
51+
RESOURCE: .nais/${{ inputs.config_file }}
4952
VAR: image=${{ inputs.image }}
5053
VARS: .nais/vars/${{ inputs.vars_file }}

.nais/config.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ spec:
2727
prometheus:
2828
enabled: true
2929
path: /internal/metrics
30-
redis:
31-
- instance: {{ redisInstance }}
32-
access: readwrite
3330
leaderElection: true
31+
{{#with redis}}
32+
redis:
33+
- instance: {{ instance }}
34+
access: readwrite
35+
{{/with}}
3436
ingresses:
3537
{{#each ingresses as |url|}}
3638
- {{url}}

.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-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

server/cache/redis.ts

-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ const clientOptions: { [key in AppEnv]?: RedisClientOptions } = {
1414
username: process.env.REDIS_USERNAME_PAGECACHE_DEV1,
1515
password: process.env.REDIS_PASSWORD_PAGECACHE_DEV1,
1616
},
17-
dev2: {
18-
url: process.env.REDIS_URI_PAGECACHE_DEV2,
19-
username: process.env.REDIS_USERNAME_PAGECACHE_DEV2,
20-
password: process.env.REDIS_PASSWORD_PAGECACHE_DEV2,
21-
},
2217
prod: {
2318
url: process.env.REDIS_URI_PAGECACHE,
2419
username: process.env.REDIS_USERNAME_PAGECACHE,

server/leader.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ export const isLeaderPod = async (): Promise<boolean> => {
1212
if (res.ok) {
1313
return res.json();
1414
}
15+
console.error(
16+
`Error fetching leader, assuming I'm leader - ${res.status} ${res.statusText}`
17+
);
18+
return true;
1519
})
1620
.then((json) => {
17-
const hostname = os.hostname();
18-
console.log(
19-
`Leader election result, comparing with my hostname: ${hostname} `,
20-
json
21-
);
22-
return json.name === hostname;
21+
return json.name === os.hostname();
2322
})
2423
.catch((e) => {
2524
console.error(

0 commit comments

Comments
 (0)