Skip to content

Commit

Permalink
chore: kustomize deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsOveTen committed Jun 12, 2024
1 parent 79a610b commit b1f77ae
Show file tree
Hide file tree
Showing 14 changed files with 396 additions and 8 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/deploy-prod&demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,37 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

build-and-deploy-production:
build-and-push-image:
needs: run-tests
name: Deploy to prod on merge to main branch
uses: Informasjonsforvaltning/workflows/.github/workflows/build-deploy.yaml@main
uses: Informasjonsforvaltning/workflows/.github/workflows/build-push.yaml@main
with:
app_name: fdk-harvest-admin
environment: prod
cluster: digdir-fdk-prod
build_env: true
build_env_name: BINARY
build_env_value: fdk-harvest-admin
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GCP_SA_DIGDIR_FDK_GCR_KEY: ${{ secrets.GCP_SA_DIGDIR_FDK_GCR_KEY }}

deploy-to-prod:
needs: build-and-push-image
name: Deploy to prod if prod-deploy is successful
uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main
with:
app_name: fdk-harvest-admin
environment: prod
cluster: digdir-fdk-prod
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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-to-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-harvest-admin
environment: demo
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,31 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

build-and-deploy-staging:
build-and-push-image:
needs: run-tests
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.yaml@main
uses: Informasjonsforvaltning/workflows/.github/workflows/build-push.yaml@main
with:
app_name: fdk-harvest-admin
environment: staging
cluster: digdir-fdk-dev
build_env: true
build_env_name: BINARY
build_env_value: fdk-harvest-admin
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GCP_SA_DIGDIR_FDK_GCR_KEY: ${{ secrets.GCP_SA_DIGDIR_FDK_GCR_KEY }}

deploy:
name: Deploy to staging environment with reusable workflow
if: github.event.pull_request.draft == false
needs: [ run-tests, build-and-push-image ]
uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main
with:
app_name: fdk-harvest-admin
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 }}
46 changes: 46 additions & 0 deletions deploy/base/deployment-fdk-harvest-admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fdk-harvest-admin
labels:
app: fdk-harvest-admin
spec:
replicas: 1
selector:
matchLabels:
app: fdk-harvest-admin
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: fdk-harvest-admin
annotations:
prometheus.io/scrape: "false"
spec:
containers:
- name: fdk-harvest-admin
image: fdk-harvest-admin
imagePullPolicy: Always
ports:
- containerPort: 8080
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
volumeMounts:
- mountPath: /var/secrets/google
name: error-reporting-sa
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:
- deployment-fdk-harvest-admin.yaml
- service-fdk-harvest-admin.yaml
images:
- name: fdk-harvest-admin
newName: eu.gcr.io/digdir-fdk-infra/fdk-harvest-admin
newTag: $(GIT_COMMIT_SHA)
14 changes: 14 additions & 0 deletions deploy/base/service-fdk-harvest-admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: v1
kind: Service
metadata:
name: fdk-harvest-admin
spec:
selector:
app: fdk-harvest-admin
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 8080
type: NodePort
69 changes: 69 additions & 0 deletions deploy/demo/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fdk-harvest-admin
labels:
app: fdk-harvest-admin
spec:
template:
spec:
containers:
- name: fdk-harvest-admin
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /var/secrets/google/error-reporting-sa-key.json
- name: MONGO_HOST
valueFrom:
secretKeyRef:
name: mongo-demo
key: MONGO_HOST
- name: MONGO_USERNAME
valueFrom:
secretKeyRef:
name: mongo-demo
key: MONGO_USERNAME
- name: MONGO_PASSWORD
valueFrom:
secretKeyRef:
name: mongo-demo
key: MONGO_PASSWORD
- 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: RABBIT_PORT
valueFrom:
secretKeyRef:
name: rabbitmq-demo
key: RABBITMQ_PORT
- name: SSO_AUTH_URI
valueFrom:
secretKeyRef:
name: commonurl-demo
key: SSO_AUTH_URI
- name: PROJECT_ID_GCP
valueFrom:
secretKeyRef:
name: common-demo
key: PROJECT_ID
- name: API_KEY
valueFrom:
secretKeyRef:
name: fdk-harvest-admin
key: API_KEY
volumes:
- name: error-reporting-sa
secret:
secretName: error-reporting-sa-demo
18 changes: 18 additions & 0 deletions deploy/demo/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: fdk-harvest-admin
spec:
ingressClassName: nginx
rules:
- host: admin-api.demo.fellesdatakatalog.digdir.no
http:
paths:
- backend:
service:
name: fdk-harvest-admin
port:
number: 8080
path: /
pathType: Prefix
10 changes: 10 additions & 0 deletions deploy/demo/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: demo
resources:
- ../base
- ingress.yaml

patchesStrategicMerge:
- env.yaml
69 changes: 69 additions & 0 deletions deploy/prod/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fdk-harvest-admin
labels:
app: fdk-harvest-admin
spec:
template:
spec:
containers:
- name: fdk-harvest-admin
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /var/secrets/google/error-reporting-sa-key.json
- name: MONGO_HOST
valueFrom:
secretKeyRef:
name: mongo-prod
key: MONGO_HOST
- name: MONGO_USERNAME
valueFrom:
secretKeyRef:
name: mongo-prod
key: MONGO_USERNAME
- name: MONGO_PASSWORD
valueFrom:
secretKeyRef:
name: mongo-prod
key: MONGO_PASSWORD
- 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: RABBIT_PORT
valueFrom:
secretKeyRef:
name: rabbitmq-prod
key: RABBITMQ_PORT
- name: SSO_AUTH_URI
valueFrom:
secretKeyRef:
name: commonurl-prod
key: SSO_AUTH_URI
- name: PROJECT_ID_GCP
valueFrom:
secretKeyRef:
name: common-prod
key: PROJECT_ID
- name: API_KEY
valueFrom:
secretKeyRef:
name: fdk-harvest-admin
key: API_KEY
volumes:
- name: error-reporting-sa
secret:
secretName: error-reporting-sa-prod
18 changes: 18 additions & 0 deletions deploy/prod/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: fdk-harvest-admin
spec:
ingressClassName: nginx
rules:
- host: admin-api.fellesdatakatalog.digdir.no
http:
paths:
- backend:
service:
name: fdk-harvest-admin
port:
number: 8080
path: /
pathType: Prefix
10 changes: 10 additions & 0 deletions deploy/prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: prod
resources:
- ../base
- ingress.yaml

patchesStrategicMerge:
- env.yaml
Loading

0 comments on commit b1f77ae

Please sign in to comment.