diff --git a/example-app-helm-chart/example-app/Chart.yaml b/example-app-helm-chart/example-app/Chart.yaml new file mode 100644 index 0000000..249ffbe --- /dev/null +++ b/example-app-helm-chart/example-app/Chart.yaml @@ -0,0 +1,4 @@ +--- +name: example-app +version: 1.0.0-SNAPSHOT +apiVersion: v2 diff --git a/example-app-helm-chart/example-app/README.md b/example-app-helm-chart/example-app/README.md new file mode 100644 index 0000000..c61fc60 --- /dev/null +++ b/example-app-helm-chart/example-app/README.md @@ -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) diff --git a/example-app-helm-chart/example-app/templates/NOTES.txt b/example-app-helm-chart/example-app/templates/NOTES.txt new file mode 100644 index 0000000..6eb7772 --- /dev/null +++ b/example-app-helm-chart/example-app/templates/NOTES.txt @@ -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: + + + io.quarkiverse.helm + quarkus-helm + {quarkus-helm-version} + + +Build the project using: + + mvn clean package + +You can find the generated Helm artifacts under: `target/helm/kubernetes//` that should look like: +- Chart.yaml +- values.yaml +- templates/*.yml the generated resources by Quarkus Helm + +**Note**: The `` 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= -Dquarkus.container-image.group= +``` + +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/ +``` + +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/ --values ./target/helm//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/ +``` + +- Via the `set` option of Helm command line: + +```shell +helm upgrade helm-example ./target/helm/kubernetes/ --set .replicas=1 +``` + +How can we delete my deployment? + +```shell +helm uninstall helm-example +``` diff --git a/example-app-helm-chart/example-app/templates/deployment.yaml b/example-app-helm-chart/example-app/templates/deployment.yaml new file mode 100644 index 0000000..fd075a6 --- /dev/null +++ b/example-app-helm-chart/example-app/templates/deployment.yaml @@ -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 diff --git a/example-app-helm-chart/example-app/templates/service.yaml b/example-app-helm-chart/example-app/templates/service.yaml new file mode 100644 index 0000000..8147444 --- /dev/null +++ b/example-app-helm-chart/example-app/templates/service.yaml @@ -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 diff --git a/example-app-helm-chart/example-app/values.schema.json b/example-app-helm-chart/example-app/values.schema.json new file mode 100644 index 0000000..6e78477 --- /dev/null +++ b/example-app-helm-chart/example-app/values.schema.json @@ -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" +} \ No newline at end of file diff --git a/example-app-helm-chart/example-app/values.yaml b/example-app-helm-chart/example-app/values.yaml new file mode 100644 index 0000000..a0bdb24 --- /dev/null +++ b/example-app-helm-chart/example-app/values.yaml @@ -0,0 +1,6 @@ +--- +app: + image: docker.io/root/example-app:1.0.0-SNAPSHOT + ports: + http: 8080 + secret: nexus-secret