added helm-chart

This commit is contained in:
2025-05-26 11:06:25 +03:00
parent fcfd43a622
commit 0e8ee098a6
7 changed files with 189 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
---
name: example-app
version: 1.0.0-SNAPSHOT
apiVersion: v2

View File

@@ -0,0 +1,17 @@
# example-app
## Configuration
The following table lists the configurable parameters and their default values.
| Parameter | Description | Default |
| --- | --- | --- |
| `app.image` | The container image to use. | docker.io/root/example-app:1.0.0-SNAPSHOT |
| `app.ports.http` | The http port to use for the probe. | 8080 |
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
```
$ helm install --name chart-name -f values.yaml .
```
> **Tip**: You can use the default [values.yaml](values.yaml)

View File

@@ -0,0 +1,72 @@
# Quarkus Helm Notes
To access the Helm annotations or properties you just need to have the following dependency in your
class path:
<dependency>
<groupId>io.quarkiverse.helm</groupId>
<artifactId>quarkus-helm</artifactId>
<version>{quarkus-helm-version}</version>
</dependency>
Build the project using:
mvn clean package
You can find the generated Helm artifacts under: `target/helm/kubernetes/<chart name>/` that should look like:
- Chart.yaml
- values.yaml
- templates/*.yml the generated resources by Quarkus Helm
**Note**: The `<chart name>` is set from either the property `quarkus.helm.name` or the `@HelmChart` annotation or the Quarkus application.
# Requirements
- Have installed [the Helm command line](https://helm.sh/docs/intro/install/)
- Have connected/logged to a kubernetes cluster
- Configure your Quarkus application to use any of the Quarkus Kubernetes extensions like Quarkus Kubernetes, Quarkus OpenShift or Quarkus Knative.
- Configure your Quarkus application to use any of [the Quarkus Container Image extensions](https://quarkus.io/guides/container-image) - This example uses `container-image-docker`.
# How can it be used?
You can run the following Maven command in order to generate the Helm artifacts and build/push the image into a container registry:
```shell
mvn clean package -Dquarkus.container-image.build=true -Dquarkus.container-image.push=true -Dquarkus.container-image.registry=<your container registry> -Dquarkus.container-image.group=<your container registry namespace>
```
This command will push the image to a container registry and will become available when a pod or container is created.
Finally, let's use Helm to deploy it into the cluster:
```shell
helm install helm-example ./target/helm/kubernetes/<chart name>
```
The above command will deploy a chart using the default values (as defined within the `values.yaml` file). We can override the default values to use your `values.dev.yaml` file by executing the following command:
```shell
helm install helm-example ./target/helm/kubernetes/<chart name> --values ./target/helm/<chart name>/kubernetes/values.dev.yaml
```
How can I update my deployment?
- Via the `upgrade` option of Helm command line:
After making changes to your project and regenerating the Helm resources and the application container image, then you need to upgrade your deployment:
```shell
helm upgrade helm-example ./target/helm/kubernetes/<chart name>
```
- Via the `set` option of Helm command line:
```shell
helm upgrade helm-example ./target/helm/kubernetes/<chart name> --set <app name>.replicas=1
```
How can we delete my deployment?
```shell
helm uninstall helm-example
```

View File

@@ -0,0 +1,43 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
app.quarkus.io/quarkus-version: 3.22.3
app.quarkus.io/build-timestamp: 2025-05-26 - 06:36:42 +0000
labels:
app.kubernetes.io/name: example-app
app.kubernetes.io/version: 1.0.0-SNAPSHOT
app.kubernetes.io/managed-by: quarkus
name: example-app
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: example-app
app.kubernetes.io/version: 1.0.0-SNAPSHOT
template:
metadata:
annotations:
app.quarkus.io/quarkus-version: 3.22.3
app.quarkus.io/build-timestamp: 2025-05-26 - 06:36:42 +0000
labels:
app.kubernetes.io/managed-by: quarkus
app.kubernetes.io/name: example-app
app.kubernetes.io/version: 1.0.0-SNAPSHOT
spec:
imagePullSecrets:
- name: {{ .Values.app.secret }}
containers:
- env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: {{ .Values.app.image }}
imagePullPolicy: Always
name: example-app
ports:
- containerPort: {{ .Values.app.ports.http }}
name: http
protocol: TCP

View File

@@ -0,0 +1,22 @@
---
apiVersion: v1
kind: Service
metadata:
annotations:
app.quarkus.io/quarkus-version: 3.22.3
app.quarkus.io/build-timestamp: 2025-05-26 - 06:36:42 +0000
labels:
app.kubernetes.io/name: example-app
app.kubernetes.io/version: 1.0.0-SNAPSHOT
app.kubernetes.io/managed-by: quarkus
name: example-app
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: {{ .Values.app.ports.http }}
selector:
app.kubernetes.io/name: example-app
app.kubernetes.io/version: 1.0.0-SNAPSHOT
type: ClusterIP

View File

@@ -0,0 +1,25 @@
{
"$schema" : "https://json-schema.org/draft-07/schema#",
"properties" : {
"app" : {
"type" : "object",
"properties" : {
"image" : {
"description" : "The container image to use.",
"type" : "string"
},
"ports" : {
"type" : "object",
"properties" : {
"http" : {
"description" : "The http port to use for the probe.",
"type" : "integer"
}
}
}
}
}
},
"title" : "Values",
"type" : "object"
}

View File

@@ -0,0 +1,6 @@
---
app:
image: docker.io/root/example-app:1.0.0-SNAPSHOT
ports:
http: 8080
secret: nexus-secret