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

Feat: Generate helm charts #291

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
4 changes: 2 additions & 2 deletions .github/workflows/create-deploy-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
distribution: temurin
cache: maven

- name: Create k8s resources
- name: Create k8s resources and helm charts
shell: bash
run: scripts/generate-k8s-resources.sh

Expand All @@ -61,6 +61,6 @@ jobs:
with:
default_author: github_actions
message: "Generate deploy resources (from ${{ github.workflow }} run # ${{ github.run_number }})"
add: '["**/deploy/k8s/*.yml", "deploy/k8s/*.yml", "**/deploy/docker-compose/*.yml", "deploy/docker-compose/*.yml", "deploy/db-init/**"]'
add: '["**/deploy/k8s/*.yml", "deploy/k8s/*.yml", "**/deploy/docker-compose/*.yml", "deploy/docker-compose/*.yml", "deploy/db-init/**", "**/deploy/helm/**]'
pathspec_error_handling: exitImmediately
new_branch: ${{ env.BRANCH }}
6 changes: 6 additions & 0 deletions event-statistics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<assertj.version>3.24.2</assertj.version>
<awaitility.version>4.1.1</awaitility.version>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<helm.version>1.0.8</helm.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -87,6 +88,11 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.helm</groupId>
<artifactId>quarkus-helm</artifactId>
<version>${helm.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand Down
6 changes: 6 additions & 0 deletions rest-fights/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<properties>
<assertj.version>3.24.2</assertj.version>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<helm.version>1.0.8</helm.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.release>17</maven.compiler.release>
Expand Down Expand Up @@ -159,6 +160,11 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.helm</groupId>
<artifactId>quarkus-helm</artifactId>
<version>${helm.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand Down
38 changes: 38 additions & 0 deletions rest-fights/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,41 @@ quarkus.knative.labels.system=${quarkus.kubernetes.labels.system}
%minikube.quarkus.config.profile.parent=prod
%minikube.quarkus.kubernetes.deployment-target=minikube
%minikube-17.quarkus.config.profile.parent=minikube

# Helm
## Version labels
quarkus.helm.values."version".paths=\
(metadata.labels.app == ${quarkus.application.name}).*.labels.'app.kubernetes.io/version',\
(metadata.labels.app == ${quarkus.application.name}).*.selector.'app.kubernetes.io/version',\
(metadata.labels.app == ${quarkus.application.name}).*.matchLabels.'app.kubernetes.io/version',\
(kind == Role).metadata.'app.kubernetes.io/version',\
(kind == RoleBinding).metadata.'app.kubernetes.io/version'

## Memory limits
quarkus.helm.values."resources.limits.memory".paths=\
(metadata.labels.app == ${quarkus.application.name}).*.resources.limits.memory
quarkus.helm.values."resources.requests.memory".paths=\
(metadata.labels.app == ${quarkus.application.name}).*.resources.requests.memory

# OpenShift ImageStreams
quarkus.helm.expressions.0.path=\
(kind == DeploymentConfig && metadata.labels.app == ${quarkus.application.name}).spec.template.spec.containers.(name == ${quarkus.application.name}).image
quarkus.helm.expressions.0.expression=\
${quarkus.application.name}:{{ .Values.app.version }}

# OpenShift triggers
quarkus.helm.expressions.1.path=\
(kind == DeploymentConfig && metadata.labels.app == ${quarkus.application.name}).spec.triggers.imageChangeParams.from.name
quarkus.helm.expressions.1.expression=\
${quarkus.application.name}:{{ .Values.app.version }}

# K8S Deployment Image & KNative Service Image
quarkus.helm.expressions.2.path=\
(kind == Deployment && metadata.labels.app == ${quarkus.application.name}).spec.template.spec.containers.(name == ${quarkus.application.name}).image
quarkus.helm.expressions.2.expression=\
${quarkus.container-image.registry}/${quarkus.container-image.group}/${quarkus.container-image.name}:{{ .Values.app.version }}

quarkus.helm.expressions.3.path=\
(kind == Service && metadata.labels.app == ${quarkus.application.name}).spec.template.spec.containers.(name == ${quarkus.application.name}).image
quarkus.helm.expressions.3.expression=\
${quarkus.container-image.registry}/${quarkus.container-image.group}/${quarkus.container-image.name}:{{ .Values.app.version }}
6 changes: 6 additions & 0 deletions rest-heroes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<properties>
<assertj.version>3.24.2</assertj.version>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<helm.version>1.0.8</helm.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<maven.compiler.release>17</maven.compiler.release>
<pact.version>1.0.1.Final</pact.version>
Expand Down Expand Up @@ -100,6 +101,11 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.helm</groupId>
<artifactId>quarkus-helm</artifactId>
<version>${helm.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand Down
21 changes: 21 additions & 0 deletions rest-heroes/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ quarkus:
app: "${quarkus.kubernetes.labels.app}"
application: "${quarkus.openshift.part-of}"
system: "${quarkus.kubernetes.labels.system}"
helm:
values:
"version":
paths: "(metadata.labels.app == ${quarkus.application.name}).*.labels.'app.kubernetes.io/version',(metadata.labels.app == ${quarkus.application.name}).*.selector.'app.kubernetes.io/version',(metadata.labels.app == ${quarkus.application.name}).*.matchLabels.'app.kubernetes.io/version',(kind == Role).metadata.'app.kubernetes.io/version',(kind == RoleBinding).metadata.'app.kubernetes.io/version'"
"resources.requests.memory":
paths: "(metadata.labels.app == ${quarkus.application.name}).*.resources.requests.memory"
"resources.limits.memory":
paths: "(metadata.labels.app == ${quarkus.application.name}).*.resources.limits.memory"
expressions:
'0':
path: "(kind == DeploymentConfig && metadata.labels.app == ${quarkus.application.name}).spec.template.spec.containers.(name == ${quarkus.application.name}).image"
expression: "${quarkus.application.name}:{{ .Values.app.version }}"
'1':
path: "(kind == DeploymentConfig && metadata.labels.app == ${quarkus.application.name}).spec.triggers.imageChangeParams.from.name"
expression: "${quarkus.application.name}:{{ .Values.app.version }}"
'2':
path: "(kind == Deployment && metadata.labels.app == ${quarkus.application.name}).spec.template.spec.containers.(name == ${quarkus.application.name}).image"
expression: "${quarkus.container-image.registry}/${quarkus.container-image.group}/${quarkus.container-image.name}:{{ .Values.app.version }}"
'3':
path: "(kind == Service && metadata.labels.app == ${quarkus.application.name}).spec.template.spec.containers.(name == ${quarkus.application.name}).image"
expression: "${quarkus.container-image.registry}/${quarkus.container-image.group}/${quarkus.container-image.name}:{{ .Values.app.version }}"

"%dev":
quarkus:
Expand Down
6 changes: 6 additions & 0 deletions rest-villains/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<properties>
<assertj.version>3.24.2</assertj.version>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<helm.version>1.0.8</helm.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<maven.compiler.release>17</maven.compiler.release>
<pact.version>1.0.1.Final</pact.version>
Expand Down Expand Up @@ -100,6 +101,11 @@
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-jdbc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.helm</groupId>
<artifactId>quarkus-helm</artifactId>
<version>${helm.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand Down
42 changes: 42 additions & 0 deletions rest-villains/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,45 @@ quarkus.knative.labels.system=${quarkus.kubernetes.labels.system}
# Minikube
%minikube.quarkus.config.profile.parent=prod
%minikube.quarkus.kubernetes.deployment-target=minikube

# Helm
## Version labels
quarkus.helm.values."version".paths=\
(metadata.labels.app == ${quarkus.application.name}).*.labels.'app.kubernetes.io/version',\
(metadata.labels.app == ${quarkus.application.name}).*.selector.'app.kubernetes.io/version',\
(metadata.labels.app == ${quarkus.application.name}).*.matchLabels.'app.kubernetes.io/version',\
(kind == Role).metadata.'app.kubernetes.io/version',\
(kind == RoleBinding).metadata.'app.kubernetes.io/version'

## Memory limits
quarkus.helm.values."resources.limits.memory".paths=\
(metadata.labels.app == ${quarkus.application.name}).*.resources.limits.memory
quarkus.helm.values."resources.requests.memory".paths=\
(metadata.labels.app == ${quarkus.application.name}).*.resources.requests.memory

# OpenShift ImageStreams
quarkus.helm.expressions.0.path=\
(kind == DeploymentConfig && metadata.labels.app == ${quarkus.application.name}).spec.template.spec.containers.(name == ${quarkus.application.name}).image
quarkus.helm.expressions.0.expression=\
${quarkus.application.name}:{{ .Values.app.version }}

# OpenShift triggers
quarkus.helm.expressions.1.path=\
(kind == DeploymentConfig && metadata.labels.app == ${quarkus.application.name}).spec.triggers.imageChangeParams.from.name
quarkus.helm.expressions.1.expression=\
${quarkus.application.name}:{{ .Values.app.version }}

# K8S Deployment Image & KNative Service Image
quarkus.helm.expressions.2.path=\
(kind == Deployment && metadata.labels.app == ${quarkus.application.name}).spec.template.spec.containers.(name == ${quarkus.application.name}).image
quarkus.helm.expressions.2.expression=\
${quarkus.container-image.registry}/${quarkus.container-image.group}/${quarkus.container-image.name}:{{ .Values.app.version }}

quarkus.helm.expressions.3.path=\
(kind == Service && metadata.labels.app == ${quarkus.application.name}).spec.template.spec.containers.(name == ${quarkus.application.name}).image
quarkus.helm.expressions.3.expression=\
${quarkus.container-image.registry}/${quarkus.container-image.group}/${quarkus.container-image.name}:{{ .Values.app.version }}




Loading