Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kustomize #65

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
uses: Informasjonsforvaltning/workflows/.github/workflows/codeql.yaml@main
with:
language: java
java_version: '17'
java_version: '21'
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 17 additions & 6 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
java_version: '17'
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
28 changes: 19 additions & 9 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
java_version: '17'
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: '17'
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
java_version: '21'
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM maven:3-openjdk-17-slim AS build
FROM maven:3.9.9-eclipse-temurin-21-jammy AS build
WORKDIR /app
COPY pom.xml ./
COPY src ./src
RUN mvn clean package --no-transfer-progress -DskipTests
RUN mvn versions:display-dependency-updates --no-transfer-progress

FROM eclipse-temurin:17-jre-jammy
FROM eclipse-temurin:21-jre-jammy
ENV TZ=Europe/Oslo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app
Expand Down
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
24 changes: 12 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.3</version>
<version>3.4.0</version>
<relativePath/>
</parent>

<properties>
<java.release>17</java.release>
<java.release>21</java.release>
<java.encoding>UTF-8</java.encoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>${java.release}</maven.compiler.source>
<maven.compiler.target>${java.release}</maven.compiler.target>

<kotlin.version>2.0.20</kotlin.version>
<jena.version>5.1.0</jena.version>
<jackson.version>2.17.2</jackson.version>
<kotlin.version>2.1.0</kotlin.version>
<jena.version>5.2.0</jena.version>
<jackson.version>2.18.2</jackson.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -95,7 +95,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.11.0</version>
<version>1.12.0</version>
</dependency>

<!-- Excel -->
Expand All @@ -113,7 +113,7 @@
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>2.9.2</version>
<version>3.0.0</version>
</dependency>

<!-- Test -->
Expand All @@ -137,13 +137,13 @@
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-standalone</artifactId>
<version>3.9.1</version>
<version>3.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.3.1</version>
<version>5.4.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -155,7 +155,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
<version>2.18.0</version>
<scope>compile</scope>
</dependency>

Expand Down Expand Up @@ -224,7 +224,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
<version>3.5.2</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<groups>unit</groups>
Expand All @@ -237,7 +237,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.0</version>
<version>3.5.2</version>
<configuration>
<groups>integration</groups>
<excludedGroups>unit</excludedGroups>
Expand Down
Loading