Skip to content

Commit

Permalink
chore: kustomize deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsOveTen committed Nov 29, 2024
1 parent 68b1752 commit 8004871
Show file tree
Hide file tree
Showing 11 changed files with 216 additions and 12 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/deploy-prod&demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,35 @@ on:
workflow_dispatch:

jobs:
build-and-deploy-production:
build-fdk-dataset-preview-service:
name: Deploy to prod on merge to main branch
uses: Informasjonsforvaltning/workflows/.github/workflows/build-deploy-maven.yaml@main
uses: Informasjonsforvaltning/workflows/.github/workflows/build-push.yaml@main
with:
app_name: fdk-dataset-preview-service
java_version: '21'
coverage_file_path: ./target/site/jacoco/jacoco.xml
environment: prod
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

deploy-prod:
name: Deploy to prod environment
needs: [ build-fdk-dataset-preview-service ]
uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main
with:
app_name: fdk-dataset-preview-service
environment: prod
cluster: digdir-fdk-prod
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GCP_SA_DIGDIR_FDK_GCR_KEY: ${{ secrets.GCP_SA_DIGDIR_FDK_GCR_KEY }}
DIGDIR_FDK_AUTODEPLOY: ${{ secrets.DIGDIR_FDK_PROD_AUTODEPLOY }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

deploy-to-demo:
needs: build-and-deploy-production
needs: deploy-prod
name: Deploy to demo if prod-deploy is successful
uses: Informasjonsforvaltning/workflows/.github/workflows/deploy.yaml@main
uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main
with:
app_name: fdk-dataset-preview-service
environment: demo
Expand Down
24 changes: 17 additions & 7 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,36 @@ on:
- main

jobs:
build-and-deploy-staging:
name: Call reusable workflow when pull request is created
build-fdk-dataset-preview-service:
name: Build when pull request is created
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.draft == false }}
uses: Informasjonsforvaltning/workflows/.github/workflows/build-deploy-maven.yaml@main
uses: Informasjonsforvaltning/workflows/.github/workflows/build-push.yaml@main
with:
app_name: fdk-dataset-preview-service
java_version: '21'
coverage_file_path: ./target/site/jacoco/jacoco.xml
environment: staging
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

deploy-to-staging:
name: Deploy to staging environment
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.draft == false }}
needs: [ build-fdk-dataset-preview-service ]
uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main
with:
app_name: fdk-dataset-preview-service
environment: staging
cluster: digdir-fdk-dev
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GCP_SA_DIGDIR_FDK_GCR_KEY: ${{ secrets.GCP_SA_DIGDIR_FDK_GCR_KEY }}
DIGDIR_FDK_AUTODEPLOY: ${{ secrets.DIGDIR_FDK_DEV_AUTODEPLOY }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

dependabot-build:
name: Build image on PR from dependabot
if: ${{ github.actor == 'dependabot[bot]' }}
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }}
uses: Informasjonsforvaltning/workflows/.github/workflows/build.yaml@main
with:
java_version: '21'
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 changes: 48 additions & 0 deletions deploy/base/fdk-dataset-preview-service-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
fdk.service: fdk-dataset-preview-service
name: fdk-dataset-preview-service
spec:
replicas: 1
selector:
matchLabels:
fdk.service: fdk-dataset-preview-service
strategy:
type: RollingUpdate
template:
metadata:
labels:
fdk.service: fdk-dataset-preview-service
spec:
containers:
- name: fdk-dataset-preview-service
image: fdk-dataset-preview-service
imagePullPolicy: Always
ports:
- containerPort: 8080
resources:
requests:
memory: "750Mi"
cpu: "10m"
limits:
memory: "750Mi"
livenessProbe:
httpGet:
path: /ping
port: 8080
initialDelaySeconds: 20
periodSeconds: 30
successThreshold: 1
failureThreshold: 5
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 150
periodSeconds: 30
successThreshold: 1
failureThreshold: 5
restartPolicy: Always
14 changes: 14 additions & 0 deletions deploy/base/fdk-dataset-preview-service-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
labels:
fdk.service: fdk-dataset-preview-service
name: fdk-dataset-preview-service
spec:
type: NodePort
ports:
- name: "8080"
port: 8080
targetPort: 8080
selector:
fdk.service: fdk-dataset-preview-service
10 changes: 10 additions & 0 deletions deploy/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- fdk-dataset-preview-service-deployment.yaml
- fdk-dataset-preview-service-service.yaml
images:
- name: fdk-dataset-preview-service
newName: ghcr.io/informasjonsforvaltning/fdk-dataset-preview-service
newTag: $(GIT_COMMIT_SHA)
28 changes: 28 additions & 0 deletions deploy/demo/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fdk-dataset-preview-service
labels:
app: fdk-dataset-preview-service
spec:
template:
spec:
containers:
- name: fdk-dataset-preview-service
env:
- name: NAMESPACE
valueFrom:
secretKeyRef:
name: common-demo
key: NAMESPACE
- name: API_KEY
valueFrom:
secretKeyRef:
name: common-demo
key: FDK_DATASET_PREVIEW_API_KEY
- name: ALLOWED_ORIGINS
valueFrom:
secretKeyRef:
name: common-demo
key: FDK_DATASET_PREVIEW_ALLOWED_ORIGINS
9 changes: 9 additions & 0 deletions deploy/demo/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: demo
resources:
- ../base

patches:
- path: env.yaml
28 changes: 28 additions & 0 deletions deploy/prod/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fdk-dataset-preview-service
labels:
app: fdk-dataset-preview-service
spec:
template:
spec:
containers:
- name: fdk-dataset-preview-service
env:
- name: NAMESPACE
valueFrom:
secretKeyRef:
name: common-prod
key: NAMESPACE
- name: API_KEY
valueFrom:
secretKeyRef:
name: common-prod
key: FDK_DATASET_PREVIEW_API_KEY
- name: ALLOWED_ORIGINS
valueFrom:
secretKeyRef:
name: common-prod
key: FDK_DATASET_PREVIEW_ALLOWED_ORIGINS
9 changes: 9 additions & 0 deletions deploy/prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: prod
resources:
- ../base

patches:
- path: env.yaml
28 changes: 28 additions & 0 deletions deploy/staging/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fdk-dataset-preview-service
labels:
app: fdk-dataset-preview-service
spec:
template:
spec:
containers:
- name: fdk-dataset-preview-service
env:
- name: NAMESPACE
valueFrom:
secretKeyRef:
name: common-staging
key: NAMESPACE
- name: API_KEY
valueFrom:
secretKeyRef:
name: common-staging
key: FDK_DATASET_PREVIEW_API_KEY
- name: ALLOWED_ORIGINS
valueFrom:
secretKeyRef:
name: common-staging
key: FDK_DATASET_PREVIEW_ALLOWED_ORIGINS
9 changes: 9 additions & 0 deletions deploy/staging/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: staging
resources:
- ../base

patches:
- path: env.yaml

0 comments on commit 8004871

Please sign in to comment.