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

Deployer parallelle server-instanser med versjonering #377

Merged
merged 57 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
23a3cfd
Tar inn build-id env-var logikk fra annen branch
anders-nom Jul 5, 2024
480fc53
Proxy til intern app
anders-nom Jul 5, 2024
254818e
Setter build-id parameter på request-url'er
anders-nom Jul 5, 2024
3a1a20e
Config for internal app
anders-nom Jul 5, 2024
4e8a707
Deployer internal app
anders-nom Jul 5, 2024
f88e3d0
Outbound rules for vanlig app
anders-nom Jul 5, 2024
4f4dc3e
Revert irrelevant endring
anders-nom Jul 5, 2024
020a4e9
Fikser test
anders-nom Jul 5, 2024
6e95872
Gjør noe visuelle endringer for å teste!
anders-nom Jul 5, 2024
5189a65
Fjerner log-støy
anders-nom Jul 5, 2024
c3710e9
Setter headere på proxy response
anders-nom Jul 5, 2024
78de3ed
Revert rød header
anders-nom Jul 5, 2024
d26ec42
Wildcard namespace
anders-nom Jul 5, 2024
7ef9ca4
Wildcard namespace for internal
anders-nom Jul 5, 2024
10ef1bb
Bruker ekstern ingress
anders-nom Jul 5, 2024
c8fb26c
Typo i app config
anders-nom Jul 5, 2024
8a537e2
Gjør noen random endringer
anders-nom Jul 5, 2024
0835b14
Gjør noen CSS endringer
anders-nom Jul 5, 2024
0546f2b
Fikser ingress
anders-nom Jul 5, 2024
44d2d47
Fikser outbound hosts
anders-nom Jul 5, 2024
784c68c
Gjør noen endringer!
anders-nom Jul 5, 2024
ba5114b
Setter https
anders-nom Jul 5, 2024
e8994d1
loopback sjekk
anders-nom Jul 5, 2024
0ea5fa5
Gjør flere endringer
anders-nom Jul 5, 2024
5af5412
Setter label for internal instans av appen
anders-nom Jul 5, 2024
ba6f598
Setter label for external app. Config for networkpolicy
anders-nom Jul 5, 2024
e77e7c8
Bruker service host igjen...
anders-nom Jul 5, 2024
9a8ae91
Revert routing endring for ekstern ingress
anders-nom Jul 5, 2024
fa53016
Gjør random endringer!
anders-nom Jul 5, 2024
9bc8893
Setter env var for app-name. BUILD_ID -> VERSION_ID
anders-nom Jul 8, 2024
549bef2
Revert varsel api url inntil videre
anders-nom Jul 8, 2024
1d6a683
Test endringer
anders-nom Jul 8, 2024
1fa6c6f
Setter min replicas til 1 for internal apps
anders-nom Jul 8, 2024
c16c754
Rydder
anders-nom Jul 8, 2024
3d0d1f8
Setter ttl per miljø
anders-nom Jul 8, 2024
577c502
Setter app_name på external app
anders-nom Jul 8, 2024
29019bf
Test endring
anders-nom Jul 8, 2024
bb5f6c2
Fjerner prod-next
anders-nom Jul 8, 2024
adf1477
Merge remote-tracking branch 'origin/main' into multi-server-deploy
anders-nom Jul 8, 2024
f38b82b
lockfile
anders-nom Jul 8, 2024
312623c
Bruker alltid endpointUrlWithParams ved kall til endepunkter som retu…
anders-nom Jul 8, 2024
49375d1
Workflow for deploy spesifikt image til intern app
anders-nom Jul 8, 2024
497ddc1
Tweaker ny workflow
anders-nom Jul 8, 2024
4fbc00f
Description
anders-nom Jul 8, 2024
e6e23c1
Description
anders-nom Jul 8, 2024
62be4e3
Fjerner test-tekster
anders-nom Jul 8, 2024
5b76e32
Fjerner test-constant
anders-nom Jul 8, 2024
af04641
Fjerner logging
anders-nom Jul 8, 2024
fd18db0
Revert headers middleware endringer
anders-nom Jul 8, 2024
a00e827
Håndterer requests fra tidligere versjoner
anders-nom Jul 8, 2024
a7aeb63
Refactor midlertidig fallback
anders-nom Jul 8, 2024
36ba9a2
Bruker igjen service host for tms-varsel-api
anders-nom Jul 8, 2024
b459a48
Deployer network-policy
anders-nom Jul 8, 2024
c4f5b77
Step names
anders-nom Jul 8, 2024
37a6fa9
Logger error som error
anders-nom Jul 8, 2024
570d614
Feilmelding
anders-nom Jul 8, 2024
8d53b9a
Bedre logging
anders-nom Jul 8, 2024
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
12 changes: 10 additions & 2 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ jobs:
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
image_suffix: ${{ inputs.DEPLOY_INSTANCE }}
- uses: nais/deploy/actions/deploy@v2
- name: Deploy external app
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: ${{ inputs.CLUSTER }}
RESOURCE: .nais/config.yml
VAR: image=${{ steps.docker-push.outputs.image }}
VAR: image=${{ steps.docker-push.outputs.image }},versionId=${{ github.sha }}
VARS: .nais/vars/${{ inputs.DEPLOY_INSTANCE }}.yml
- name: Deploy internal versioned app
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: ${{ inputs.CLUSTER }}
RESOURCE: .nais/config-internal.yml
VAR: image=${{ steps.docker-push.outputs.image }},versionId=${{ github.sha }}
VARS: .nais/vars/${{ inputs.DEPLOY_INSTANCE }}.yml
39 changes: 39 additions & 0 deletions .github/workflows/deploy-internal-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy intern app-versjon
on:
workflow_dispatch:
inputs:
image:
description: "Image version (last segment of GAR tag)"
required: true
type: string
versionId:
description: "App version id"
required: true
type: string
deployInstance:
description: 'Deploy instance'
required: true
type: choice
options:
- dev-beta-navno
- dev-stable
- prod

jobs:
deploy_internal:
name: Deploy intern app-versjon
runs-on: ubuntu-latest
environment: ${{ inputs.DEPLOY_INSTANCE }}
permissions:
contents: read
id-token: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Deploy internal versioned app
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: ${{ inputs.deployInstance == 'prod' && 'prod-gcp' || 'dev-gcp' }}
RESOURCE: .nais/config-internal.yml
VAR: image=europe-north1-docker.pkg.dev/nais-management-233d/personbruker/${{ inputs.image }},versionId=${{ inputs.versionId }}
VARS: .nais/vars/${{ inputs.deployInstance }}.yml
33 changes: 26 additions & 7 deletions .github/workflows/deploy.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ jobs:
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}

deploy-network-policy:
runs-on: ubuntu-latest
needs: build-and-test
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Deploy to prod
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: prod-gcp
RESOURCE: .nais/network-policy.yml
- name: Deploy to dev
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
RESOURCE: .nais/network-policy.yml

deploy-dev:
runs-on: ubuntu-latest
needs: build-and-test
Expand All @@ -58,7 +77,7 @@ jobs:
env:
CLUSTER: dev-gcp
RESOURCE: .nais/config.yml
VAR: image=${{ needs.build-and-test.outputs.image }}
VAR: image=${{ needs.build-and-test.outputs.image }},versionId=${{ github.sha }}
VARS: .nais/vars/dev-stable.yml

deploy-beta-navno:
Expand All @@ -73,10 +92,10 @@ jobs:
env:
CLUSTER: dev-gcp
RESOURCE: .nais/config.yml
VAR: image=${{ needs.build-and-test.outputs.image }}
VAR: image=${{ needs.build-and-test.outputs.image }},versionId=${{ github.sha }}
VARS: .nais/vars/dev-beta-navno.yml

deploy-prod-next:
deploy-prod-internal:
runs-on: ubuntu-latest
needs: build-and-test
permissions:
Expand All @@ -87,9 +106,9 @@ jobs:
- uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: prod-gcp
RESOURCE: .nais/config.yml
VAR: image=${{ needs.build-and-test.outputs.image }}
VARS: .nais/vars/prod-next.yml
RESOURCE: .nais/config-internal.yml
VAR: image=${{ needs.build-and-test.outputs.image }},versionId=${{ github.sha }}
VARS: .nais/vars/prod.yml

deploy-prod:
runs-on: ubuntu-latest
Expand All @@ -103,5 +122,5 @@ jobs:
env:
CLUSTER: prod-gcp
RESOURCE: .nais/config.yml
VAR: image=${{ needs.build-and-test.outputs.image }}
VAR: image=${{ needs.build-and-test.outputs.image }},versionId=${{ github.sha }}
VARS: .nais/vars/prod.yml
71 changes: 71 additions & 0 deletions .nais/config-internal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
apiVersion: nais.io/v1alpha1
kind: Application
metadata:
name: {{appName}}-{{versionId}}
namespace: personbruker
labels:
team: personbruker
dekoratorenType: internal
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "256M"
nginx.ingress.kubernetes.io/proxy-buffer-size: "16k"
nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
spec:
image: {{image}}
port: 8089
ttl: {{ttlInternal}}
liveness:
path: /api/isAlive
initialDelay: 10
readiness:
path: /api/isReady
initialDelay: 10
prometheus:
enabled: true
path: /metrics
accessPolicy:
outbound:
rules:
- application: nav-dekoratoren-api
- application: navno-search-api
- application: tms-varsel-api
namespace: min-side
external:
{{#each outboundHosts as |host|}}
- host: {{host}}
{{/each}}
inbound:
rules:
- application: {{appName}}
namespace: personbruker
env:
- name: APP_NAME
value: {{appName}}
- name: VERSION_ID
value: {{versionId}}
- name: IS_INTERNAL_APP
value: "true"
{{#each env as |var|}}
- name: {{var.name}}
value: {{var.value}}
{{/each}}
envFrom:
- secret: nav-dekoratoren
- secret: nav-dekoratoren-unleash-api-token
filesFrom:
- configmap: dekoratoren-config
mountPath: /app/config
replicas:
{{#with replicas}}
min: 1
max: {{max}}
{{/with}}
resources:
{{#with resources}}
requests:
cpu: {{requests.cpu}}
memory: {{requests.memory}}
limits:
memory: {{limits.memory}}
{{/with}}
5 changes: 5 additions & 0 deletions .nais/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
namespace: personbruker
labels:
team: personbruker
dekoratorenType: external
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "256M"
nginx.ingress.kubernetes.io/proxy-buffer-size: "16k"
Expand Down Expand Up @@ -42,6 +43,10 @@ spec:
- application: "*"
namespace: "*"
env:
- name: APP_NAME
value: {{appName}}
- name: VERSION_ID
value: {{versionId}}
{{#each env as |var|}}
- name: {{var.name}}
value: {{var.value}}
Expand Down
18 changes: 18 additions & 0 deletions .nais/network-policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: nav-dekoratoren-internal
namespace: personbruker
labels:
team: personbruker
spec:
podSelector:
matchLabels:
dekoratorenType: external
policyTypes:
- Egress
egress:
- to:
- podSelector:
matchLabels:
dekoratorenType: internal
2 changes: 2 additions & 0 deletions .nais/vars/dev-beta-navno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ingresses:
outboundHosts:
- www.nav.no
- www.intern.dev.nav.no
- dekoratoren-beta.intern.dev.nav.no
- www-q6.nav.no
- navno-unleash-api.nav.cloud.nais.io
- tokendings.dev-gcp.nais.io
Expand Down Expand Up @@ -41,6 +42,7 @@ env:
value: "navtest"
- name: PUZZEL_CUSTOMER_ID
value: C1302192-8BEC-4EA2-84AB-F4EDE8AC6230
ttlInternal: 1h
replicas:
min: 1
max: 1
Expand Down
1 change: 1 addition & 0 deletions .nais/vars/dev-beta-tms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ env:
value: "navtest"
- name: PUZZEL_CUSTOMER_ID
value: C1302192-8BEC-4EA2-84AB-F4EDE8AC6230
ttlInternal: 1h
replicas:
min: 1
max: 1
Expand Down
1 change: 1 addition & 0 deletions .nais/vars/dev-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ env:
value: "navtest"
- name: PUZZEL_CUSTOMER_ID
value: 83BD7664-B38B-4EEE-8D99-200669A32551
ttlInternal: 1h
replicas:
min: 1
max: 4
Expand Down
50 changes: 0 additions & 50 deletions .nais/vars/prod-next.yml

This file was deleted.

1 change: 1 addition & 0 deletions .nais/vars/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ env:
value: "nav"
- name: PUZZEL_CUSTOMER_ID
value: 83BD7664-B38B-4EEE-8D99-200669A32551
ttlInternal: 1w
replicas:
min: 2
max: 40
Expand Down
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion packages/client/src/helpers/urls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe("Endpoint urls", () => {
},
env: {
APP_URL: "http://localhost:3000",
VERSION_ID: "1234",
},
} as typeof window.__DECORATOR_DATA__;

Expand All @@ -19,7 +20,7 @@ describe("Endpoint urls", () => {
});

expect(url).toBe(
"http://localhost:3000/user-menu?simple=true&feedback=true",
"http://localhost:3000/user-menu?simple=true&feedback=true&version-id=1234",
);
});
});
3 changes: 2 additions & 1 deletion packages/client/src/helpers/urls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Params } from "decorator-shared/params";
import { formatParams } from "decorator-shared/json";
import { env } from "../params";
import { VERSION_ID_PARAM } from "decorator-shared/constants";

export const endpointUrlWithParams = (
endpointUrl: `/${string}`,
Expand All @@ -11,7 +12,7 @@ export const endpointUrlWithParams = (
...params,
});

return `${env("APP_URL")}${endpointUrl}?${formattedParams}`;
return `${env("APP_URL")}${endpointUrl}?${formattedParams}&${VERSION_ID_PARAM}=${env("VERSION_ID")}`;
};

export const cdnUrl = (url: string) => `${env("CDN_URL")}${url}`;
9 changes: 4 additions & 5 deletions packages/client/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="./client.d.ts" />
import { formatParams } from "decorator-shared/json";
import { type Context, type ParamKey } from "decorator-shared/params";
import Cookies from "js-cookie";
import "vite/modulepreload-polyfill";
Expand All @@ -13,7 +12,7 @@ import { env, param, updateDecoratorParams } from "./params";
import { useLoadIfActiveSession } from "./screensharing";
import { getHeadAssetsProps } from "decorator-shared/head";
import { buildHtmlElement } from "./helpers/html-element-builder";
import { cdnUrl } from "./helpers/urls";
import { cdnUrl, endpointUrlWithParams } from "./helpers/urls";

import.meta.glob("./styles/*.css", { eager: true });
import.meta.glob(["./views/**/*.ts", "!./views/**/*.test.ts"], { eager: true });
Expand All @@ -24,9 +23,9 @@ window.addEventListener("paramsupdated", (e) => {
if (e.detail.params.language) {
Promise.all(
["header", "footer"].map((key) =>
fetch(
`${env("APP_URL")}/${key}?${formatParams(window.__DECORATOR_DATA__.params)}`,
).then((res) => res.text()),
fetch(endpointUrlWithParams(`/${key}`)).then((res) =>
res.text(),
),
),
).then(([header, footer]) => {
const headerEl = document.getElementById("decorator-header");
Expand Down
Loading