Skip to content

Commit

Permalink
Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
fkneier-bikeleasing committed May 22, 2024
1 parent 592a5d1 commit 44def24
Show file tree
Hide file tree
Showing 46 changed files with 1,555 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: build

on:
workflow_dispatch:
branches: [ main ]
push:
branches: [ main ]
paths:
- '**'
- '!docs/**'
- '!README.md'
pull_request:
branches: [ main ]

permissions:
packages: write

env:
REPO: "ghcr.io/${{ github.repository }}"

jobs:
version:
name: Calculate Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Calculate version
id: version
run: curl -Ls https://solugo.github.io/gitversion/run.sh | GITVERSION=v1.1.0 bash
build:
name: Build
runs-on: ubuntu-latest
needs:
- version
env:
VERSION: ${{ needs.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Build
run: |
./gradlew test jib \
-Djib.to.image=$REPO \
-Djib.to.tags=$VERSION \
-Djib.to.auth.username=${{ github.actor }} \
-Djib.to.auth.password=${{ secrets.GITHUB_TOKEN }} \
--console=plain \
--no-daemon \
;
publish:
name: Publish to Titan01
runs-on: ubuntu-latest
needs:
- version
- build
env:
VERSION: ${{ needs.version.outputs.version }}
steps:
- name: Configure Kubernetes
run: mkdir ~/.kube && echo '${{ secrets.KUBE_CONFIG_TITAN_01 }}' > ~/.kube/config
- name: Deploy to Kubernetes
run: |
helm upgrade -i oauth-mock ./chart \
--set ingress.enabled=true \
--set ingress.domain=oauth-mock.solugo.de \
--set ingress.annotations."kubernetes\.io/ingress\.class"=public \
--set ingress.annotations."cert-manager\.io/cluster-issuer"=letsencrypt \
;
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gradle/**
.idea/**
build/**
62 changes: 62 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
plugins {
id("org.jetbrains.kotlin.jvm") version "1.9.24"
id("org.jetbrains.kotlin.plugin.spring") version "1.9.24"
id("org.springframework.boot") version "3.2.4"
id("com.google.cloud.tools.jib") version "3.4.2"
}

group = "de.solugo"

repositories {
mavenCentral()
}

dependencies {
implementation(platform("org.springframework.boot:spring-boot-dependencies:3.2.4"))
implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.0"))

implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation("org.bitbucket.b_c:jose4j:0.9.6")

testImplementation(platform("org.junit:junit-bom:5.10.1"))
testImplementation(platform("org.testcontainers:testcontainers-bom:1.19.3"))
testImplementation(platform("io.kotest:kotest-bom:5.8.0"))
testImplementation(platform("io.ktor:ktor-bom:2.3.7"))

testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("io.ktor:ktor-client-java")
testImplementation("io.ktor:ktor-client-content-negotiation")
testImplementation("io.ktor:ktor-serialization-jackson")
testImplementation("io.kotest:kotest-assertions-core")
testImplementation("io.kotest:kotest-assertions-json")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")

}

kotlin {
jvmToolchain(21)
}

springBoot {
buildInfo()
}

jib {
from {
image = "openjdk:23-slim-bullseye"
}
container {
mainClass = "OidcServer"
}
to {
image = "oidc-server"
}
}

tasks.withType<Test> {
useJUnitPlatform()
}
27 changes: 27 additions & 0 deletions chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

#--- Ignore env-specific templates used not during packaging (build) but during deployment
*.njk
nj.json
6 changes: 6 additions & 0 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: oauth-mock
description: Service for persistence of session information.
version: 1.0.0
appVersion: 0.0.0
type: application
58 changes: 58 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "chart.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "chart.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "chart.labels" -}}
helm.sh/chart: {{ include "chart.chart" . }}
{{ include "chart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Get the secret name.
*/}}
{{- define "chart.auth.secretName" -}}
{{- printf "%s-ingress-basic-auth" .Release.Name -}}
{{- end -}}
48 changes: 48 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- $fullName := include "chart.fullname" . -}}

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $fullName }}
labels:
{{- include "chart.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "chart.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "chart.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
37 changes: 37 additions & 0 deletions chart/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "chart.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- $domain := tpl .Values.ingress.domain $ -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "chart.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.className }}
tls:
- hosts:
- "{{ $domain }}"
secretName: {{ .Release.Name }}-tls-secret
rules:
- host: "{{ $domain }}"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- end }}
14 changes: 14 additions & 0 deletions chart/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- $fullName := include "chart.fullname" . -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "chart.fullname" . }}
labels: {{- include "chart.labels" . | nindent 4}}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 8080
protocol: TCP
name: http
selector: {{- include "chart.selectorLabels" . | nindent 4}}
18 changes: 18 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
replicaCount: 1

resources:
requests:
cpu: 250m
memory: 250Mi
limits:
cpu: 500m
memory: 500Mi

image:
repository: 'ghcr.io/solugo/oauth-mock'

service:
port: 80

ingress:
enabled: false
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
kotlin.code.style=official
version=99-SNAPSHOT
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Wed Apr 03 20:25:46 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 44def24

Please sign in to comment.