Skip to content

Commit

Permalink
Merge pull request #848 from ehsavoie/WFLY-18887
Browse files Browse the repository at this point in the history
[WFLY-18887]: Improving todo-backend documentation
  • Loading branch information
emmartins authored Jan 10, 2024
2 parents e73c60c + d3d04cb commit 60a5949
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 129 deletions.
28 changes: 20 additions & 8 deletions shared-doc/helm-deploy-project.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

ifeval::[{useHelmChartDir} == true]
:helm_chart_values: charts
endif::[]
ifndef::useHelmChartDir[]
:helm_chart_values: -f charts/helm.yaml {helmChartName}
endif::[]
[[deploy_helm]]
== Deploy the {ProductShortName} Source-to-Image (S2I) Quickstart to OpenShift with Helm Charts

Expand All @@ -7,7 +14,7 @@ The backend will be built and deployed on OpenShift with a Helm Chart for {produ
Navigate to the root directory of this quickstart and run the following command:
[source,options="nowrap",subs="+attributes"]
----
$ helm install {helm-app-name} -f charts/helm.yaml {helmChartName} --wait --timeout=10m0s
$ helm install {helm-app-name} {helm_chart_values} --wait --timeout=10m0s
NAME: {helm-app-name}
...
STATUS: deployed
Expand All @@ -23,17 +30,22 @@ oc get deployment {helm-app-name}

The Helm Chart for this quickstart contains all the information to build an image from the source code using S2I on Java 17:


ifndef::requires-http-route[]
[source,options="nowrap",subs="+attributes"]
ifdef::useHelmChartDir[]
[source,yaml]
----
build:
uri: {githubRepoCodeUrl}
ref: {WildFlyQuickStartRepoTag}
contextDir: {artifactId}
deploy:
replicas: 1
include::{docdir}/charts/Chart.yaml[]
----
endif::useHelmChartDir[]
ifndef::useHelmChartDir[]
[source,yaml]
----
include::{docdir}/charts/helm.yaml[]
----
endif::useHelmChartDir[]
endif::requires-http-route[]

ifdef::requires-http-route[]
[source,options="nowrap",subs="+attributes"]
----
Expand Down
105 changes: 5 additions & 100 deletions todo-backend/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ include::../shared-doc/attributes.adoc[]
:technologies: JPA, JAX-RS, OpenShift, Galleon
:openshift: true
:archiveType: war
:useHelmChartDir: true
:helm-install-prerequisites: ../todo-backend/helm-install-prerequisites.adoc

[abstract]
The `todo-backend` quickstart demonstrates how to implement a backend that exposes a HTTP API with JAX-RS
Expand Down Expand Up @@ -206,108 +208,11 @@ $ curl http://localhost:8080
:extraStartParams: -DPOSTGRESQL_DATABASE=todos -DPOSTGRESQL_SERVICE_HOST=localhost -DPOSTGRESQL_SERVICE_PORT=5432 -DPOSTGRESQL_USER=todos -DPOSTGRESQL_PASSWORD=mysecretpassword -DPOSTGRESQL_DATASOURCE=ToDos
include::../shared-doc/run-integration-tests-with-provisioned-server.adoc[leveloffset=+1]

== Run the Backend on OpenShift

include::../shared-doc/build-the-quickstart-for-openshift.adoc[leveloffset=+1]

=== Prerequisites

* You must be logged in OpenShift and have an `oc` client to connect to OpenShift
* https://helm.sh[Helm] must be installed to deploy the backend on OpenShift.

Once you have installed Helm, you need to add the repository that provides Helm Charts for {productName}:

ifndef::ProductRelease[]
[source,options="nowrap"]
----
$ helm repo add wildfly https://docs.wildfly.org/wildfly-charts/
"wildfly" has been added to your repositories
$ helm search repo wildfly
NAME CHART VERSION APP VERSION DESCRIPTION
wildfly/wildfly ... ... Build and Deploy WildFly applications on OpenShift
wildfly/wildfly-common ... ... A library chart for WildFly-based applications
----
endif::[]
ifdef::ProductRelease[]
[source,options="nowrap",subs="+attributes"]]
----
$ helm repo add jboss-eap https://jbossas.github.io/eap-charts/
"jboss-eap" has been added to your repositories
$ helm search repo jboss-eap
NAME CHART VERSION APP VERSION DESCRIPTION
{helmChartName} ... ... A Helm chart to build and deploy {productVersion} applications
----
endif::[]

ifndef::ProductRelease[]
=== Build and Deploy the Backend on OpenShift with {productName} S2I
endif::[]

The backend will be built and deployed on OpenShift with a Helm Chart for {productName}.

ifndef::ProductRelease[]
Add the bitnami repository which provides an helm chart for PostgreSQL:
[source,options="nowrap"]
----
$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
----

Install the full application (database + backend).

[source,options="nowrap",subs="+attributes"]
----
$ helm dependency update charts/
$ helm install todo-backend charts/
NAME: todo-backend
...
STATUS: deployed
REVISION: 1
----

The Helm Chart for this quickstart contains all the information to build an image from the source code using S2I and install it with the database:

[source,options="nowrap"]
----
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: ...
- name: wildfly
repository: http://docs.wildfly.org/wildfly-charts/
version: ...
----

endif::[]

ifndef::ProductRelease[]
Any configuration specified by this chart is described in its README that is displayed in OpenShift Dev console
or using the command:

[source,options="nowrap",subs="+attributes"]
----
$ helm show readme {helmChartName}
----

Let's wait for the application to be built and deployed:

[source,options="nowrap",subs="+attributes"]
----
$ oc get deployment todo-backend -w
NAME READY UP-TO-DATE AVAILABLE AGE
{artifactId} 0/1 1 0 31s
...
{artifactId} 1/1 1 1 4m31s
----

endif::[]

ifdef::ProductRelease[]

//Prepare Helm for Quickstart Deployment
include::../shared-doc/helm-deploy-project.adoc[leveloffset=+1]
== Run the Backend on OpenShift

endif::[]
// OpenShift
include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1]

=== Environment variables for PostgreSQL

Expand Down
23 changes: 2 additions & 21 deletions todo-backend/charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
apiVersion: v2
name: todo-backend-chart
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
description: A Helm chart to deploy a WildFly todo-backend application and its Postgresql database
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.0.3"
appVersion: 31.0.0.Final
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 13.1.5
#version: 12.9.0
- name: wildfly
repository: http://docs.wildfly.org/wildfly-charts/
version: 2.3.2
28 changes: 28 additions & 0 deletions todo-backend/helm-install-prerequisites.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ifndef::ProductRelease[]
Add the bitnami repository which provides an helm chart for PostgreSQL:
[source,options="nowrap"]
----
$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
----

The Helm Chart for this quickstart contains all the information to build an image from the source code using S2I and install it with the database:

[source,options="nowrap"]
----
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: ...
- name: wildfly
repository: http://docs.wildfly.org/wildfly-charts/
version: ...
----

So we need to update the dependecies of our Helm Chart.

[source,options="nowrap",subs="+attributes"]
----
$ helm dependency update charts/
----
endif::[]

0 comments on commit 60a5949

Please sign in to comment.