Skip to content

Commit e803c5b

Browse files
committed
Deploy til nais via GHA
navikt/dagpenger#531
1 parent 1f09861 commit e803c5b

17 files changed

+269
-334
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Build and deploy
2+
3+
on: [push]
4+
5+
env:
6+
IMAGE: docker.pkg.github.com/${{ github.repository }}/dp-inntekt-api:${{ github.sha }}
7+
jobs:
8+
build:
9+
name: Build and publish Docker image
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
15+
- name: Set up Java
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: '13.x'
19+
20+
- name: Cache gradle dependencies
21+
uses: actions/cache@v1
22+
with:
23+
path: ~/.gradle/caches
24+
key: ${{ runner.os }}-gradle-${{ hashFiles('build.gradle.kts', 'buildSrc/src/main/kotlin/Constants.kt') }}
25+
restore-keys: |
26+
${{ runner.os }}-gradle-
27+
- name: Build with Gradle
28+
run: ./gradlew build --info
29+
30+
- name: Build and Publish Docker image
31+
if: github.ref == 'refs/heads/master'
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
run: |
35+
docker build -t $IMAGE .
36+
docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN}
37+
docker push $IMAGE
38+
- name: Archive NAIS yaml
39+
if: github.ref == 'refs/heads/master'
40+
uses: actions/upload-artifact@v1
41+
with:
42+
name: nais-yaml
43+
path: nais
44+
45+
deploy-dev:
46+
name: Deploy to dev
47+
needs: [build]
48+
if: github.ref == 'refs/heads/master'
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Fetch NAIS yaml
52+
uses: actions/download-artifact@v1
53+
with:
54+
name: nais-yaml
55+
path: nais
56+
57+
- uses: nais/deploy/actions/deploy@v1
58+
env:
59+
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
60+
CLUSTER: dev-fss
61+
RESOURCE: nais/alerts.yaml,nais/grpc-svc.yaml,nais/dev/nais.yaml
62+
VARS: nais/vars.yaml
63+
VAR: alerts_slack_channel=#team-dagpenger-alerts-non-prod
64+
PRINT_PAYLOAD: true
65+
66+
deploy-q2:
67+
name: Deploy to q2
68+
needs: [build]
69+
if: github.ref == 'refs/heads/master'
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: Fetch NAIS yaml
73+
uses: actions/download-artifact@v1
74+
with:
75+
name: nais-yaml
76+
path: nais
77+
78+
- uses: nais/deploy/actions/deploy@v1
79+
env:
80+
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
81+
CLUSTER: dev-fss
82+
RESOURCE: nais/alerts.yaml,nais/grpc-svc.yaml,nais/q2/nais.yaml
83+
VARS: nais/vars.yaml
84+
VAR: alerts_slack_channel=#team-dagpenger-alerts-non-prod,namespace=q2
85+
PRINT_PAYLOAD: true
86+
87+
acceptance-tests:
88+
name: Run acceptance tests
89+
needs: [deploy-dev]
90+
runs-on: ubuntu-latest
91+
steps:
92+
- name: Checkout code
93+
uses: actions/checkout@v2
94+
with:
95+
repository: navikt/dagpenger-funksjonelle-tester
96+
- id: repo-name
97+
name: Split owner from repository name
98+
run: |
99+
echo ::set-output name=name::$(echo ${{github.repository}} | sed -e "s/^navikt\///" )
100+
- uses: nais/deploy/actions/deploy@v1
101+
name: Run tests
102+
env:
103+
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
104+
CLUSTER: dev-fss
105+
VAR: GITHUB_REPO=${{ steps.repo-name.outputs.name }}
106+
RESOURCE: nais/tests.yml
107+
timeout-minutes: 5
108+
109+
deploy-prod:
110+
name: Deploy to Production
111+
needs: [acceptance-tests]
112+
if: github.ref == 'refs/heads/master'
113+
runs-on: ubuntu-latest
114+
steps:
115+
- name: Fetch NAIS yaml
116+
uses: actions/download-artifact@v1
117+
with:
118+
name: nais-yaml
119+
path: nais
120+
121+
- uses: nais/deploy/actions/deploy@v1
122+
env:
123+
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
124+
CLUSTER: prod-fss
125+
RESOURCE: nais/alerts.yaml,nais/grpc-svc.yaml,nais/prod/nais.yaml
126+
VARS: nais/vars.yaml
127+
VAR: alerts_slack_channel=#team-dagpenger-alerts
128+
PRINT_PAYLOAD: true

Jenkinsfile

Lines changed: 0 additions & 194 deletions
This file was deleted.

nais/alerts.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: nais.io/v1
2+
kind: Alert
3+
metadata:
4+
name: {{app}}
5+
namespace: {{namespace}}
6+
labels:
7+
team: {{team}}
8+
spec:
9+
alerts:
10+
- action: '`kubectl describe pod -l app=\{{ $labels.deployment }} -n \{{ $labels.namespace }}` for events og `kubectl get pods -l app=\{{ $labels.deployment }} -n \{{ $labels.namespace }}` for å se feilende podder'
11+
alert: applikasjon nede
12+
description: '\{{ $labels.deployment }} har utilgjengelige podder i \{{ $labels.namespace }}'
13+
expr: kube_deployment_status_replicas_unavailable{deployment="{{app}}",job="kubernetes-service-endpoints"} > 0
14+
for: 2m
15+
16+
- action: Sjekk loggene til \{{ $labels.log_app }} i \{{ $labels.log_namespace }}, for å se hvorfor det er så mye feil
17+
alert: høy feilrate i logger
18+
expr: (100 * sum by (log_app, log_namespace) (rate(logd_messages_total{log_app="{{app}}",log_level="Error"}[3m])) / sum by (log_app, log_namespace) (rate(logd_messages_total{log_app="{{app}}"}[3m]))) > 90
19+
for: 3m
20+
21+
- action: Sjekk \{{ $labels.app }} i \{{ $labels.kubernetes_namespace }} sine selftest for å se hva som er galt
22+
alert: feil i selftest
23+
expr: selftests_aggregate_result_status{app="{{app}}"} > 0
24+
for: 1m
25+
26+
receivers:
27+
slack:
28+
channel: '{{alerts_slack_channel}}'
29+
prependText: '<!here> | '

nais/base/alerts.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

nais/base/kustomization.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)