diff --git a/.github/workflows/deploy-prod&demo.yaml b/.github/workflows/deploy-prod&demo.yaml index 8bc3593..5c900b3 100644 --- a/.github/workflows/deploy-prod&demo.yaml +++ b/.github/workflows/deploy-prod&demo.yaml @@ -1,4 +1,4 @@ -name: Deploy to production +name: Deploy to production & demo on: push: @@ -6,25 +6,36 @@ on: - 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 diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-staging.yaml index 37d7a6a..a613205 100644 --- a/.github/workflows/deploy-staging.yaml +++ b/.github/workflows/deploy-staging.yaml @@ -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 }} diff --git a/deploy/base/dataset-catalog-deployment.yaml b/deploy/base/dataset-catalog-deployment.yaml new file mode 100644 index 0000000..0eb6a0f --- /dev/null +++ b/deploy/base/dataset-catalog-deployment.yaml @@ -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: {} diff --git a/deploy/base/dataset-catalog-service.yaml b/deploy/base/dataset-catalog-service.yaml new file mode 100644 index 0000000..7be9526 --- /dev/null +++ b/deploy/base/dataset-catalog-service.yaml @@ -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: {} diff --git a/deploy/base/kustomization.yaml b/deploy/base/kustomization.yaml new file mode 100644 index 0000000..3fd05d3 --- /dev/null +++ b/deploy/base/kustomization.yaml @@ -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) diff --git a/deploy/demo/env.yaml b/deploy/demo/env.yaml new file mode 100644 index 0000000..ced9e1b --- /dev/null +++ b/deploy/demo/env.yaml @@ -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 diff --git a/deploy/demo/kustomization.yaml b/deploy/demo/kustomization.yaml new file mode 100644 index 0000000..3fa6792 --- /dev/null +++ b/deploy/demo/kustomization.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: demo +resources: + - ../base + +patchesStrategicMerge: + - env.yaml diff --git a/deploy/prod/env.yaml b/deploy/prod/env.yaml new file mode 100644 index 0000000..358a918 --- /dev/null +++ b/deploy/prod/env.yaml @@ -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 diff --git a/deploy/prod/kustomization.yaml b/deploy/prod/kustomization.yaml new file mode 100644 index 0000000..1451cae --- /dev/null +++ b/deploy/prod/kustomization.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: prod +resources: + - ../base + +patchesStrategicMerge: + - env.yaml diff --git a/deploy/staging/env.yaml b/deploy/staging/env.yaml new file mode 100644 index 0000000..f92ca37 --- /dev/null +++ b/deploy/staging/env.yaml @@ -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-staging + key: MONGO_USERNAME + - name: MONGO_PASSWORD + valueFrom: + secretKeyRef: + name: mongo-staging + key: MONGO_PASSWORD + - name: MONGO_HOST + valueFrom: + secretKeyRef: + name: mongo-staging + key: MONGODB_HOST + - name: ORGANIZATION_CATALOG_HOST + valueFrom: + secretKeyRef: + name: commonurl-staging + key: ORGANIZATION_CATALOG_BASE_URI + - name: FDK_BASE_HOST + valueFrom: + secretKeyRef: + name: commonurl-staging + key: FDK_BASE_URI + - name: FDK_REGISTRATION_BASE_URI + valueFrom: + secretKeyRef: + name: commonurl-staging + key: FDK_REGISTRATION_BASE_URI + - name: OIDC_ISSUER + valueFrom: + secretKeyRef: + name: sso-staging + key: SSO_OIDC_ISSUER + - name: OIDC_JWKS + valueFrom: + secretKeyRef: + name: sso-staging + key: SSO_OIDC_JWKS + - name: RABBIT_USERNAME + valueFrom: + secretKeyRef: + name: rabbitmq-staging + key: RABBITMQ_USERNAME + - name: RABBIT_PASSWORD + valueFrom: + secretKeyRef: + name: rabbitmq-staging + key: RABBITMQ_PASSWORD + - name: RABBIT_HOST + valueFrom: + secretKeyRef: + name: rabbitmq-staging + key: RABBITMQ_HOST + - name: SEARCH_FULLTEXT_HOST + valueFrom: + secretKeyRef: + name: commonurl-staging + key: FDK_FULLTEXT_SEARCH_BASE_URI + - name: DATASET_CATALOG_URI + valueFrom: + secretKeyRef: + name: commonurl-staging + key: DATASET_CATALOG_BASE_URI diff --git a/deploy/staging/kustomization.yaml b/deploy/staging/kustomization.yaml new file mode 100644 index 0000000..f1a9989 --- /dev/null +++ b/deploy/staging/kustomization.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: staging +resources: + - ../base + +patchesStrategicMerge: + - env.yaml