Skip to content

Commit

Permalink
feat: add deployment with kustomize
Browse files Browse the repository at this point in the history
  • Loading branch information
hegeaal committed Jun 13, 2024
1 parent 338e50c commit cc24ad8
Show file tree
Hide file tree
Showing 11 changed files with 372 additions and 12 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/deploy-prod&demo.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
name: Deploy to production
name: Deploy to production & demo

on:
push:
branches:
- main

jobs:
build-and-deploy-production:
name: Deploy to prod on merge to main branch
uses: Informasjonsforvaltning/workflows/.github/workflows/build-deploy-maven.yaml@main
build-dataset-catalog:
name: Build when pull request is created
uses: Informasjonsforvaltning/workflows/.github/workflows/build-push.yaml@main
with:
app_name: dataset-catalog
java_version: '17'
coverage_file_path: ./target/site/jacoco/jacoco.xml
environment: prod
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GCP_SA_DIGDIR_FDK_GCR_KEY: ${{ secrets.GCP_SA_DIGDIR_FDK_GCR_KEY }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

deploy-prod:
name: Deploy to prod environment
needs: [ build-dataset-catalog ]
uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main
with:
app_name: dataset-catalog
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: dataset-catalog
environment: demo
Expand Down
22 changes: 17 additions & 5 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,31 @@ on:
- main

jobs:
build-and-deploy-staging:
name: Call reusable workflow 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
build-dataset-catalog:
name: Build when pull request is created
if: github.event.pull_request.draft == false
uses: Informasjonsforvaltning/workflows/.github/workflows/build-push.yaml@main
with:
app_name: dataset-catalog
java_version: '17'
coverage_file_path: ./target/site/jacoco/jacoco.xml
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 }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

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

Expand Down
49 changes: 49 additions & 0 deletions deploy/base/fdk-concept-harvester-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
fdk.service: dataset-catalog
name: dataset-catalog
spec:
replicas: 1
selector:
matchLabels:
fdk.service: dataset-catalog
strategy:
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
fdk.service: dataset-catalog
spec:
containers:
- env:

name: dataset-catalog
image: dataset-catalog
imagePullPolicy: Always
ports:
- containerPort: 8080
resources:
requests:
memory: "550Mi"
livenessProbe:
httpGet:
path: /ping
port: 8080
initialDelaySeconds: 20
periodSeconds: 30
successThreshold: 1
failureThreshold: 5
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 20
periodSeconds: 30
successThreshold: 1
failureThreshold: 5
restartPolicy: Always
status: {}
17 changes: 17 additions & 0 deletions deploy/base/fdk-concept-harvester-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
fdk.service: dataset-catalog
name: dataset-catalog
spec:
type: NodePort
ports:
- name: "8080"
port: 8080
targetPort: 8080
selector:
fdk.service: dataset-catalog
status:
loadBalancer: {}
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:
- dataset-catalog-deployment.yaml
- dataset-catalog-service.yaml
images:
- name: dataset-catalog
newName: eu.gcr.io/digdir-fdk-infra/dataset-catalog
newTag: $(GIT_COMMIT_SHA)
78 changes: 78 additions & 0 deletions deploy/demo/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: dataset-catalog
labels:
app: dataset-catalog
spec:
template:
spec:
containers:
- name: dataset-catalog
env:
- name: MONGO_USERNAME
valueFrom:
secretKeyRef:
name: mongo-demo
key: MONGO_USERNAME
- name: MONGO_PASSWORD
valueFrom:
secretKeyRef:
name: mongo-demo
key: MONGO_PASSWORD
- name: MONGO_HOST
valueFrom:
secretKeyRef:
name: mongo-demo
key: MONGODB_HOST
- name: ORGANIZATION_CATALOG_HOST
valueFrom:
secretKeyRef:
name: commonurl-demo
key: ORGANIZATION_CATALOG_BASE_URI
- name: FDK_BASE_HOST
valueFrom:
secretKeyRef:
name: commonurl-demo
key: FDK_BASE_URI
- name: FDK_REGISTRATION_BASE_URI
valueFrom:
secretKeyRef:
name: commonurl-demo
key: FDK_REGISTRATION_BASE_URI
- name: OIDC_ISSUER
valueFrom:
secretKeyRef:
name: sso-demo
key: SSO_OIDC_ISSUER
- name: OIDC_JWKS
valueFrom:
secretKeyRef:
name: sso-demo
key: SSO_OIDC_JWKS
- name: RABBIT_USERNAME
valueFrom:
secretKeyRef:
name: rabbitmq-demo
key: RABBITMQ_USERNAME
- name: RABBIT_PASSWORD
valueFrom:
secretKeyRef:
name: rabbitmq-demo
key: RABBITMQ_PASSWORD
- name: RABBIT_HOST
valueFrom:
secretKeyRef:
name: rabbitmq-demo
key: RABBITMQ_HOST
- name: SEARCH_FULLTEXT_HOST
valueFrom:
secretKeyRef:
name: commonurl-demo
key: FDK_FULLTEXT_SEARCH_BASE_URI
- name: DATASET_CATALOG_URI
valueFrom:
secretKeyRef:
name: commonurl-demo
key: DATASET_CATALOG_BASE_URI
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

patchesStrategicMerge:
- env.yaml
78 changes: 78 additions & 0 deletions deploy/prod/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: dataset-catalog
labels:
app: dataset-catalog
spec:
template:
spec:
containers:
- name: dataset-catalog
env:
- name: MONGO_USERNAME
valueFrom:
secretKeyRef:
name: mongo-prod
key: MONGO_USERNAME
- name: MONGO_PASSWORD
valueFrom:
secretKeyRef:
name: mongo-prod
key: MONGO_PASSWORD
- name: MONGO_HOST
valueFrom:
secretKeyRef:
name: mongo-prod
key: MONGODB_HOST
- name: ORGANIZATION_CATALOG_HOST
valueFrom:
secretKeyRef:
name: commonurl-prod
key: ORGANIZATION_CATALOG_BASE_URI
- name: FDK_BASE_HOST
valueFrom:
secretKeyRef:
name: commonurl-prod
key: FDK_BASE_URI
- name: FDK_REGISTRATION_BASE_URI
valueFrom:
secretKeyRef:
name: commonurl-prod
key: FDK_REGISTRATION_BASE_URI
- name: OIDC_ISSUER
valueFrom:
secretKeyRef:
name: sso-prod
key: SSO_OIDC_ISSUER
- name: OIDC_JWKS
valueFrom:
secretKeyRef:
name: sso-prod
key: SSO_OIDC_JWKS
- name: RABBIT_USERNAME
valueFrom:
secretKeyRef:
name: rabbitmq-prod
key: RABBITMQ_USERNAME
- name: RABBIT_PASSWORD
valueFrom:
secretKeyRef:
name: rabbitmq-prod
key: RABBITMQ_PASSWORD
- name: RABBIT_HOST
valueFrom:
secretKeyRef:
name: rabbitmq-prod
key: RABBITMQ_HOST
- name: SEARCH_FULLTEXT_HOST
valueFrom:
secretKeyRef:
name: commonurl-prod
key: FDK_FULLTEXT_SEARCH_BASE_URI
- name: DATASET_CATALOG_URI
valueFrom:
secretKeyRef:
name: commonurl-prod
key: DATASET_CATALOG_BASE_URI
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

patchesStrategicMerge:
- env.yaml
Loading

0 comments on commit cc24ad8

Please sign in to comment.