diff --git a/.github/workflows/scripts/kubernetes/qs-overrides/microprofile-reactive-messaging-kafka/overridable-functions.sh b/.github/workflows/scripts/kubernetes/qs-overrides/microprofile-reactive-messaging-kafka/overridable-functions.sh index ecbd69f92b..2331635dc5 100644 --- a/.github/workflows/scripts/kubernetes/qs-overrides/microprofile-reactive-messaging-kafka/overridable-functions.sh +++ b/.github/workflows/scripts/kubernetes/qs-overrides/microprofile-reactive-messaging-kafka/overridable-functions.sh @@ -42,59 +42,23 @@ function installPrerequisites() application="${1}" echo "Installing Strimzi operator" - kubectl apply -f charts/strimzi-on-kubernetes.yaml + kubectl apply -f charts/strimzi-on-kubernetes.yaml --wait --timeout=10m0s - seconds=120 + seconds=300 now=$(date +%s) end=$(($seconds + $now)) - echo "Looping for 2 minutes until the 'kafka' CRD is available " + echo "Looping for 5 minutes until the 'kafka' CRD is available " while [ $now -lt $end ]; do - # It takes a while for the kafka CRD to be ready sleep 5 - echo "Trying to create my-cluster" - kubectl apply -f - <>>>>>> upstream/main +:helm-install-prerequisites-openshift: ../opentelemetry-tracing/helm-install-prerequisites-openshift.adoc +:helm-install-prerequisites-kubernetes: ../opentelemetry-tracing/helm-install-prerequisites-kubernetes.adoc == What is it? @@ -236,6 +233,10 @@ endif::[] include::../shared-doc/build-and-run-the-quickstart-with-bootable-jar.adoc[leveloffset=+1] // OpenShift include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] +ifndef::ProductRelease,EAPXPRelease[] +//Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +endif::[] == Conclusion diff --git a/opentelemetry-tracing/helm-install-prerequisites-common.adoc b/opentelemetry-tracing/helm-install-prerequisites-common.adoc new file mode 100644 index 0000000000..7219c9125a --- /dev/null +++ b/opentelemetry-tracing/helm-install-prerequisites-common.adoc @@ -0,0 +1,36 @@ +ifdef::prereq-openshift[] +:prereq-cloud-platform: OpenShift +:prereq-cloud-cli: oc +:prereq-suffix: openshift +endif::[] +ifdef::prereq-kubernetes[] +:prereq-cloud-platform: Kubernetes +:prereq-cloud-cli: kubectl +:prereq-suffix: kubernetes +endif::[] + +=== Install OpenTelemetry Collector on {prereq-cloud-platform} + +The functionality of this quickstart depends on a running instance of the https://opentelemetry.io/docs/collector/[OpenTelemetry Collector]. + +To deploy and configure the OpenTelemetry Collector, you will need to apply a set of configurations to your {prereq-cloud-platform} cluster, to configure the OpenTelemetry Collector as well as any external routes needed: + +[source,options="nowrap",subs="+attributes"] +---- +include::charts/opentelemetry-collector-openshift.yaml[] +---- + +To make things simpler, you can find these commands in `charts/opentelemetry-collector-openshift.yaml`, and to apply them run the following command in your terminal: + +[source,options="nowrap",subs="+attributes"] +---- +$ {prereq-cloud-cli} apply -f charts/opentelemetry-collector-{prereq-suffix}.yaml +---- + +[NOTE] +==== +When done with the quickstart, the `{prereq-cloud-cli} delete -f charts/opentelemetry-collector-{prereq-suffix}.yaml` command may be used to revert the applied changes. +==== + + + diff --git a/opentelemetry-tracing/helm-install-prerequisites-kubernetes.adoc b/opentelemetry-tracing/helm-install-prerequisites-kubernetes.adoc new file mode 100644 index 0000000000..1a9075d1f2 --- /dev/null +++ b/opentelemetry-tracing/helm-install-prerequisites-kubernetes.adoc @@ -0,0 +1,2 @@ +:prereq-kubernetes: true +include::./helm-install-prerequisites-common.adoc[] diff --git a/opentelemetry-tracing/helm-install-prerequisites-openshift.adoc b/opentelemetry-tracing/helm-install-prerequisites-openshift.adoc new file mode 100644 index 0000000000..ef988f429c --- /dev/null +++ b/opentelemetry-tracing/helm-install-prerequisites-openshift.adoc @@ -0,0 +1,2 @@ +:prereq-openshift: true +include::./helm-install-prerequisites-common.adoc[] diff --git a/opentelemetry-tracing/helm-install-prerequisites.adoc b/opentelemetry-tracing/helm-install-prerequisites.adoc deleted file mode 100644 index c4d4637dba..0000000000 --- a/opentelemetry-tracing/helm-install-prerequisites.adoc +++ /dev/null @@ -1,25 +0,0 @@ -=== Install OpenTelemetry Collector on OpenShift - -The functionality of this quickstart depends on a running instance of the https://opentelemetry.io/docs/collector/[OpenTelemetry Collector]. - -To deploy and configure the OpenTelemetry Collector, you will need to apply a set of configurations to your OpenShift cluster, to configure the OpenTelemetry Collector as well as any external routes needed: - -[source,options="nowrap",subs="+attributes"] ----- -include::charts/opentelemetry-collector-openshift.yaml[] ----- - -To make things simpler, you can find these commands in `charts/opentelemetry-collector-openshift.yaml`, and to apply them run the following command in your terminal: - -[source] ----- -$ oc apply -f charts/opentelemetry-collector-openshift.yaml ----- - -[NOTE] -==== -When done with the quickstart, the `oc delete -f charts/opentelemetry-collector-openshift.yaml` command may be used to revert the applied changes. -==== - - - diff --git a/remote-helloworld-mdb/README-source.adoc b/remote-helloworld-mdb/README-source.adoc index 419c1f884d..98cdf30393 100644 --- a/remote-helloworld-mdb/README-source.adoc +++ b/remote-helloworld-mdb/README-source.adoc @@ -10,6 +10,8 @@ include::../shared-doc/attributes.adoc[] :standalone-server-type: full :archiveType: war :restoreScriptName: remove-remote-broker.cli +:helm-install-prerequisites-openshift: ../remote-helloworld-mdb/helm-install-prerequisites-openshift.adoc +:helm-install-prerequisites-kubernetes: ../remote-helloworld-mdb/helm-install-prerequisites-kubernetes.adoc ifdef::ProductRelease,EAPXPRelease[] :BrokerImageName: registry.redhat.io/amq7/amq-broker-rhel8:7.10 :BrokerProductName: Red Hat AMQ @@ -153,27 +155,9 @@ include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc endif::[] include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] -=== Deploy a {BrokerProductName} instance on OpenShift -[source,options="nowrap",subs="+attributes"] ----- -$ oc run artemis --env AMQ_USER=admin --env AMQ_PASSWORD=admin --image={BrokerImageName} --port=61616 --expose=true ----- - -This will create a broker instance named `artemis` on OpenShift that can be accessed on the port `61616` on the service `artemis` with the account *admin/admin*. -//Prepare Helm for Quickstart Deployment - -include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] - -==== Clean Up - -The broker instance can be deleted from OpenShift by running the command: - -[source,options="nowrap"] ----- -$ oc delete service artemis -service "artemis" deleted -$ oc delete pod artemis -pod "artemis" deleted ----- +ifndef::ProductRelease,EAPXPRelease[] +//Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +endif::[] diff --git a/remote-helloworld-mdb/helm-install-prerequisites-cloud.adoc b/remote-helloworld-mdb/helm-install-prerequisites-cloud.adoc new file mode 100644 index 0000000000..6fc3bf364f --- /dev/null +++ b/remote-helloworld-mdb/helm-install-prerequisites-cloud.adoc @@ -0,0 +1,32 @@ +ifdef::prereq-openshift[] +:prereq-cloud-platform: OpenShift +:prereq-cloud-cli: oc +endif::[] +ifdef::prereq-kubernetes[] +:prereq-cloud-platform: Kubernetes +:prereq-cloud-cli: kubectl +endif::[] + +=== Deploy a {BrokerProductName} instance on {prereq-cloud-platform} + +[source,options="nowrap",subs="+attributes"] +---- +$ {prereq-cloud-cli} run artemis --env AMQ_USER=admin --env AMQ_PASSWORD=admin --image={BrokerImageName} --port=61616 --expose=true +---- + +This will create a broker instance named `artemis` on {prereq-cloud-platform} that can be accessed on the port `61616` on the service `artemis` with the account *admin/admin*. + +==== Clean Up + +NOTE: This should be done *after* the application on {prereq-cloud-platform} has been stopped. + +The broker instance can be deleted from {prereq-cloud-platform} by running the commands: + +[source,options="nowrap",subs="+attributes"] +---- +$ {prereq-cloud-cli} delete service artemis +service "artemis" deleted +$ {prereq-cloud-cli} delete pod artemis +pod "artemis" deleted +---- + diff --git a/remote-helloworld-mdb/helm-install-prerequisites-kubernetes.adoc b/remote-helloworld-mdb/helm-install-prerequisites-kubernetes.adoc new file mode 100644 index 0000000000..528beccc0d --- /dev/null +++ b/remote-helloworld-mdb/helm-install-prerequisites-kubernetes.adoc @@ -0,0 +1,3 @@ +:prereq-kubernetes: true +include::./helm-install-prerequisites-cloud.adoc[] + diff --git a/remote-helloworld-mdb/helm-install-prerequisites-openshift.adoc b/remote-helloworld-mdb/helm-install-prerequisites-openshift.adoc new file mode 100644 index 0000000000..511e170e03 --- /dev/null +++ b/remote-helloworld-mdb/helm-install-prerequisites-openshift.adoc @@ -0,0 +1,2 @@ +:prereq-openshift: true +include::./helm-install-prerequisites-cloud.adoc[] diff --git a/servlet-async/README-source.adoc b/servlet-async/README-source.adoc index b25d1f48f7..9ffa3e2fb9 100644 --- a/servlet-async/README-source.adoc +++ b/servlet-async/README-source.adoc @@ -49,4 +49,8 @@ include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] ifndef::ProductRelease,EAPXPRelease[] include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] endif::[] -include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] \ No newline at end of file +include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] +ifndef::ProductRelease,EAPXPRelease[] +// Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +endif::[] diff --git a/servlet-filterlistener/README-source.adoc b/servlet-filterlistener/README-source.adoc index 53acc4f786..e80ee1183a 100644 --- a/servlet-filterlistener/README-source.adoc +++ b/servlet-filterlistener/README-source.adoc @@ -96,4 +96,8 @@ include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] ifndef::ProductRelease,EAPXPRelease[] include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] endif::[] -include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] \ No newline at end of file +include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] +ifndef::ProductRelease,EAPXPRelease[] +// Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +endif::[] diff --git a/servlet-security/README-source.adoc b/servlet-security/README-source.adoc index fad6e780c2..cc1929fde9 100644 --- a/servlet-security/README-source.adoc +++ b/servlet-security/README-source.adoc @@ -222,3 +222,7 @@ ifndef::ProductRelease,EAPXPRelease[] include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] endif::[] include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] +ifndef::ProductRelease,EAPXPRelease[] +// Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +endif::[] diff --git a/shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc b/shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc new file mode 100644 index 0000000000..b2a5911db0 --- /dev/null +++ b/shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc @@ -0,0 +1,30 @@ +:cloud-platform: Kubernetes +:kubernetes: true +ifndef::helm-app-name[] +:helm-app-name: {artifactId} +endif::helm-app-name[] + +[[build_and_run_the_quickstart_on_kubernetes]] += Building and running the quickstart application with Kubernetes +// The openshift profile +include::../shared-doc/build-the-quickstart-for-kubernetes.adoc[leveloffset=+1] +// Getting Started with Helm +include::../shared-doc/helm-getting-started-overview-kubernetes.adoc[leveloffset=+1] + +ifdef::helm-install-prerequisites-kubernetes[] +// Additional steps needed before deploying in Helm +[[deploy_helm_prerequisites]] +include::{helm-install-prerequisites-kubernetes}[leveloffset=+1] +endif::helm-install-prerequisites-kubernetes[] + +//Prepare Helm for Quickstart Deployment +include::../shared-doc/helm-deploy-project.adoc[leveloffset=+1] + +// Testing on Openshift +include::../shared-doc/run-integration-tests-with-kubernetes.adoc[leveloffset=+1] + +//Prepare Helm for Quickstart Deployment +include::../shared-doc/helm-undeploy-project.adoc[leveloffset=+1] + +// Unset the attribute +:!kubernetes: diff --git a/shared-doc/build-and-run-the-quickstart-with-openshift.adoc b/shared-doc/build-and-run-the-quickstart-with-openshift.adoc index 76c117ca14..dc838cd60c 100644 --- a/shared-doc/build-and-run-the-quickstart-with-openshift.adoc +++ b/shared-doc/build-and-run-the-quickstart-with-openshift.adoc @@ -1,3 +1,5 @@ +:cloud-platform: OpenShift +:openshift: true ifndef::helm-app-name[] :helm-app-name: {artifactId} endif::helm-app-name[] @@ -7,13 +9,13 @@ endif::helm-app-name[] // The openshift profile include::../shared-doc/build-the-quickstart-for-openshift.adoc[leveloffset=+1] // Getting Started with Helm -include::../shared-doc/helm-getting-started-overview.adoc[leveloffset=+1] +include::../shared-doc/helm-getting-started-overview-openshift.adoc[leveloffset=+1] -ifdef::helm-install-prerequisites[] +ifdef::helm-install-prerequisites-openshift[] // Additional steps needed before deploying in Helm [[deploy_helm_prerequisites]] -include::{helm-install-prerequisites}[leveloffset=+1] -endif::helm-install-prerequisites[] +include::{helm-install-prerequisites-openshift}[leveloffset=+1] +endif::helm-install-prerequisites-openshift[] //Prepare Helm for Quickstart Deployment include::../shared-doc/helm-deploy-project.adoc[leveloffset=+1] @@ -23,3 +25,6 @@ include::../shared-doc/run-integration-tests-with-openshift.adoc[leveloffset=+1] //Prepare Helm for Quickstart Deployment include::../shared-doc/helm-undeploy-project.adoc[leveloffset=+1] + +// Unset the attribute +:!openshift: diff --git a/shared-doc/build-the-quickstart-for-cloud-platform-internal.adoc b/shared-doc/build-the-quickstart-for-cloud-platform-internal.adoc new file mode 100644 index 0000000000..7a469d1d44 --- /dev/null +++ b/shared-doc/build-the-quickstart-for-cloud-platform-internal.adoc @@ -0,0 +1,92 @@ +ifndef::ProductRelease,EAPXPRelease[] +The server provisioning functionality is provided by the WildFly Maven Plugin, and you may find its configuration in the quickstart `pom.xml`: +endif::[] +ifdef::ProductRelease,EAPXPRelease[] +The server provisioning functionality is provided by the EAP Maven Plugin, and you may find its configuration in the quickstart `pom.xml`: +endif::[] + +ifndef::ProductRelease,EAPXPRelease[] + +[source,xml,subs="attributes+"] +---- + + openshift + + + + org.wildfly.plugins + wildfly-maven-plugin + + + ${version.server} + cloud + + + ROOT.war + ... + + + + + package + + + + + ... + + + +---- +You may note that unlike the `provisioned-server` profile it uses the cloud context which enables a configuration tuned for {cloud-platform} environment. + +The plugin uses https://github.com/wildfly/wildfly-glow[WildFly Glow] to discover the feature packs and layers required to run the application, and provisions a server containing those layers. + +If you get an error or the server is missing some functionality which cannot be auto-discovered, you can download the https://github.com/wildfly/wildfly-glow/releases[WildFly Glow CLI] and run the following command to see more information about what add-ons are available: +[source,shell] +---- +wildfly-glow show-add-ons +---- +endif::ProductRelease,EAPXPRelease[] + +ifdef::ProductRelease,EAPXPRelease[] +[source,xml,subs="attributes+"] +---- + + openshift + + + + org.jboss.eap.plugins + eap-maven-plugin + + ... + + + org.jboss.eap:wildfly-ee-galleon-pack + + + org.jboss.eap.cloud:eap-cloud-galleon-pack + + + ... + ROOT.war + + + + + package + + + + + ... + + + +---- +You may note that it uses the cloud feature pack which enables a configuration tuned for the {cloud-platform} environment. +endif::[] diff --git a/shared-doc/build-the-quickstart-for-kubernetes.adoc b/shared-doc/build-the-quickstart-for-kubernetes.adoc new file mode 100644 index 0000000000..b42063315f --- /dev/null +++ b/shared-doc/build-the-quickstart-for-kubernetes.adoc @@ -0,0 +1,6 @@ +[[build-the-quickstart-for-kubernetes]] +== Build the {productName} Quickstart to Kubernetes with Helm Charts + +For Kubernetes, the build with Apache Maven uses an `openshift` Maven profile to provision a {productName} server, suitable for running on Kubernetes. + +include::../shared-doc/build-the-quickstart-for-cloud-platform-internal.adoc[] diff --git a/shared-doc/build-the-quickstart-for-openshift.adoc b/shared-doc/build-the-quickstart-for-openshift.adoc index 50ba1441d6..625e07c315 100644 --- a/shared-doc/build-the-quickstart-for-openshift.adoc +++ b/shared-doc/build-the-quickstart-for-openshift.adoc @@ -1,97 +1,6 @@ [[build-the-quickstart-for-openshift]] -== Build the {productName} Source-to-Image (S2I) Quickstart to OpenShift with Helm Charts +== Build the {productName} Source-to-Image (S2I) Quickstart to {cloud-platform} with Helm Charts On OpenShift, the S2I build with Apache Maven uses an `openshift` Maven profile to provision a {productName} server, deploy and run the quickstart in OpenShift environment. -ifndef::ProductRelease,EAPXPRelease[] -The server provisioning functionality is provided by the WildFly Maven Plugin, and you may find its configuration in the quickstart `pom.xml`: -endif::[] -ifdef::ProductRelease,EAPXPRelease[] -The server provisioning functionality is provided by the EAP Maven Plugin, and you may find its configuration in the quickstart `pom.xml`: -endif::[] - -ifndef::ProductRelease,EAPXPRelease[] - -[source,xml,subs="attributes+"] ----- - - openshift - - - - org.wildfly.plugins - wildfly-maven-plugin - - - ${version.server} - cloud - - - ROOT.war - ... - - - - - package - - - - - ... - - - ----- -You may note that unlike the `provisioned-server` profile it uses the cloud context which enables a configuration tuned for OpenShift environment. - -The plugin uses https://github.com/wildfly/wildfly-glow[WildFly Glow] to discover the feature packs and layers required to run the application, and provisions a server containing those layers. - -If you get an error or the server is missing some functionality which cannot be auto-discovered, you can download the https://github.com/wildfly/wildfly-glow/releases[WildFly Glow CLI] and run the following command to see more information about what add-ons are available: -[source,shell] ----- -wildfly-glow show-add-ons ----- -endif::ProductRelease,EAPXPRelease[] - -ifdef::ProductRelease,EAPXPRelease[] -[source,xml,subs="attributes+"] ----- - - openshift - - - - org.jboss.eap.plugins - eap-maven-plugin - - ... - - - org.jboss.eap:wildfly-ee-galleon-pack - - - org.jboss.eap.cloud:eap-cloud-galleon-pack - - - ... - ROOT.war - - - - - package - - - - - ... - - - ----- -You may note that it uses the cloud feature pack which enables a configuration tuned for OpenShift environment. -endif::[] +include::../shared-doc/build-the-quickstart-for-cloud-platform-internal.adoc[] \ No newline at end of file diff --git a/shared-doc/helm-deploy-project.adoc b/shared-doc/helm-deploy-project.adoc index 37e29351c0..f04d1035ab 100644 --- a/shared-doc/helm-deploy-project.adoc +++ b/shared-doc/helm-deploy-project.adoc @@ -1,20 +1,65 @@ - +ifndef::helmSetWildFlyArgumentPrefix[] +// For use with nested Helm charts +:helmSetWildFlyArgumentPrefix: +endif::[] ifeval::[{useHelmChartDir} == true] :helm_chart_values: charts endif::[] ifndef::useHelmChartDir[] :helm_chart_values: -f charts/helm.yaml {helmChartName} endif::[] +ifdef::kubernetes[] +:helm-set-build-enabled: --set {helmSetWildFlyArgumentPrefix}build.enabled=false +:helm-set-deploy-route-enabled: --set {helmSetWildFlyArgumentPrefix}deploy.route.enabled=false +:helm-set-image-name: --set {helmSetWildFlyArgumentPrefix}image.name="localhost:5000/{artifactId}" +:helm-extra-arguments: {helm-set-build-enabled} {helm-set-deploy-route-enabled} {helm-set-image-name} +:cloud-cli: kubectl +endif::[] +ifndef::kubernetes[] +:helm-extra-arguments: +:cloud-cli: oc +endif::[] [[deploy_helm]] -== Deploy the {ProductShortName} Source-to-Image (S2I) Quickstart to OpenShift with Helm Charts +== Deploy the {ProductShortName} Source-to-Image (S2I) Quickstart to {cloud-platform} with Helm Charts +ifndef::kubernetes[] Log in to your OpenShift instance using the `oc login` command. -The backend will be built and deployed on OpenShift with a Helm Chart for {productName}. +endif::[] +The backend will be built and deployed on {cloud-platform} with a Helm Chart for {productName}. + +ifndef::kubernetes[] Navigate to the root directory of this quickstart and run the following command: +endif::[] +ifdef::kubernetes[] +Navigate to the root directory of this quickstart and run the following commands: + +[source,options="nowrap",subs="+attributes"] +---- +mvn -Popenshift package wildfly:image +---- +This will use the `openshift` Maven profile we saw earlier to build the application, and create a Docker image containing the {productName} server with the application deployed. The name of the image will be `{artifactId}`. + +Next we need to tag the image and make it available to Kubernetes. You can push it to a registry like `quay.io`. In this case we tag as `localhost:5000/{artifactId}:latest` and push it to the internal registry in our Kubernetes instance: + +[source,options="nowrap",subs="+attributes"] +---- +# Tag the image +docker tag {artifactId} localhost:5000/{artifactId}:latest +# Push the image to the registry +docker push localhost:5000/{artifactId}:latest +---- + +In the below call to `helm install` which deploys our application to Kubernetes, we are passing in some extra arguments to tweak the Helm build: + +* `{helm-set-build-enabled}` - This turns off the s2i build for the Helm chart since Kubernetes, unlike OpenShift, does not have s2i. Instead, we are providing the image to use. +* `{helm-set-deploy-route-enabled}` - This disables route creation normally performed by the Helm chart. On Kubernetes we will use port-forwards instead to access our application, since routes are an OpenShift specific concept and thus not available on Kubernetes. +* `{helm-set-image-name}` - This tells the Helm chart to use the image we built, tagged and pushed to Kubernetes' internal registry above. + +endif::[] [source,options="nowrap",subs="+attributes"] ---- -$ helm install {helm-app-name} {helm_chart_values} --wait --timeout=10m0s +$ helm install {helm-app-name} {helm_chart_values} --wait --timeout=10m0s {helm-extra-arguments} NAME: {helm-app-name} ... STATUS: deployed @@ -25,7 +70,7 @@ This command will return once the application has successfully deployed. In case [source,options="nowrap",subs="+attributes"] ---- -oc get deployment {helm-app-name} +{cloud-cli} 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: @@ -61,7 +106,7 @@ deploy: ---- endif::requires-http-route[] -This will create a new deployment on OpenShift and deploy the application. +This will create a new deployment on {cloud-platform} and deploy the application. If you want to see all the configuration elements to customize your deployment you can use the following command: [source,options="nowrap",subs="+attributes"] @@ -69,7 +114,7 @@ If you want to see all the configuration elements to customize your deployment y $ helm show readme {helmChartName} ---- - +ifdef::openshift[] Get the URL of the route to the deployment. [source,options="nowrap",subs="+attributes"] @@ -77,12 +122,27 @@ Get the URL of the route to the deployment. $ oc get route {helm-app-name} -o jsonpath="{.spec.host}" ---- Access the application in your web browser using the displayed URL. +endif::[] +ifdef::kubernetes[] +To be able to connect to our application running in Kubernetes from outside, we need to set up a port-forward to the `{helm-app-name}` service created for us by the Helm chart. + +This service will run on port `8080`, and we set up the port forward to also run on port `8080`: +[source,options="nowrap",subs="+attributes"] +---- +kubectl port-forward service/{helm-app-name} 8080:8080 +---- +The server can now be accessed via `http://localhost:8080` from outside Kubernetes. Note that the command to create the port-forward will not return, so it is easiest to run this in a separate terminal. + +endif::[] [NOTE] ==== The Maven profile named `openshift` is used by the Helm chart to provision the server with the quickstart deployed on the root web context, and thus the application should be accessed with the URL without the `/{artifactId}` path segment after `HOST:PORT`. ==== -ifdef::post-helm-install-actions[] -include::{post-helm-install-actions}[leveloffset=+1] -endif::post-helm-install-actions[] +ifdef::openshift+post-helm-install-actions-openshift[] +include::{post-helm-install-actions-openshift}[leveloffset=+1] +endif::openshift+post-helm-install-actions-openshift[] +ifdef::kubernetes+post-helm-install-actions-kubernetes[] +include::{post-helm-install-actions-kubernetes}[leveloffset=+1] +endif::kubernetes+post-helm-install-actions-kubernetes[] diff --git a/shared-doc/helm-getting-started-overview-kubernetes.adoc b/shared-doc/helm-getting-started-overview-kubernetes.adoc new file mode 100644 index 0000000000..b0aaa18cd4 --- /dev/null +++ b/shared-doc/helm-getting-started-overview-kubernetes.adoc @@ -0,0 +1,37 @@ +[[getting_started_with_helm]] += Getting Started with Kubernetes and Helm Charts + +This section contains the basic instructions to build and deploy this quickstart to Kubernetes using Helm Charts. + +== Install Kubernetes +In this example we are using https://github.com/kubernetes/minikube[Minikube] as our Kubernetes provider. See the https://minikube.sigs.k8s.io/docs/start/[Minikube Getting Started guide] for how to install it. After installing it, we start it with 4GB of memory. + +[source,options="nowrap",subs="+attributes"] +---- +minikube start --memory='4gb' +---- +The above command should work if you have Docker installed on your machine. If, you are using https://podman-desktop.io[Podman] instead of Docker, you will also need to pass in `--driver=podman`, as covered in the https://minikube.sigs.k8s.io/docs/handbook/config/[Minikube documentation]. + +Once Minikube has started, we need to enable its https://minikube.sigs.k8s.io/docs/handbook/registry/[registry] since that is where we will push the image needed to deploy the quickstart, and where we will tell the Helm charts to download it from. + +[source,options="nowrap",subs="+attributes"] +---- +minikube addons enable registry +---- + +In order to be able to push images to the registry we need to make it accessible from outside Kubernetes. How we do this depends on your operating system. All the below examples will expose it at `localhost:5000` + +[source,options="nowrap",subs="+attributes"] +---- +# On Mac: +docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:$(minikube ip):5000" + +# On Linux: +kubectl port-forward --namespace kube-system service/registry 5000:80 & + +# On Windows: +kubectl port-forward --namespace kube-system service/registry 5000:80 +docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000" +---- + +include::../shared-doc/helm-pre-requisites.adoc[] \ No newline at end of file diff --git a/shared-doc/helm-getting-started-overview.adoc b/shared-doc/helm-getting-started-overview-openshift.adoc similarity index 100% rename from shared-doc/helm-getting-started-overview.adoc rename to shared-doc/helm-getting-started-overview-openshift.adoc diff --git a/shared-doc/helm-pre-requisites.adoc b/shared-doc/helm-pre-requisites.adoc index 19d6b9550c..41dae8032e 100644 --- a/shared-doc/helm-pre-requisites.adoc +++ b/shared-doc/helm-pre-requisites.adoc @@ -1,8 +1,10 @@ [[prerequisites_helm_openshift]] == Prerequisites +ifndef::kubernetes[] * 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. +endif::[] +* https://helm.sh[Helm] must be installed to deploy the backend on {cloud-platform}. Once you have installed Helm, you need to add the repository that provides Helm Charts for {productName}. diff --git a/shared-doc/helm-undeploy-project.adoc b/shared-doc/helm-undeploy-project.adoc index ba19b574f1..078d91513e 100644 --- a/shared-doc/helm-undeploy-project.adoc +++ b/shared-doc/helm-undeploy-project.adoc @@ -1,7 +1,14 @@ [[undeploy_helm]] -== Undeploy the {ProductShortName} Source-to-Image (S2I) Quickstart from OpenShift with Helm Charts +== Undeploy the {ProductShortName} Source-to-Image (S2I) Quickstart from {cloud-platform} with Helm Charts [source,options="nowrap",subs="+attributes"] ---- $ helm uninstall {helm-app-name} ---- +ifdef::kubernetes[] +To stop the port forward you created earlier use: +[source,options="nowrap",subs="+attributes"] +---- +$ kubectl port-forward service/{helm-app-name} 8080:8080 +---- +endif::[] \ No newline at end of file diff --git a/shared-doc/run-integration-tests-with-kubernetes.adoc b/shared-doc/run-integration-tests-with-kubernetes.adoc new file mode 100644 index 0000000000..bdafc2ee73 --- /dev/null +++ b/shared-doc/run-integration-tests-with-kubernetes.adoc @@ -0,0 +1,20 @@ +[[run_the_integration_tests_with_kubernetes]] += Run the Integration Tests with Kubernetes +The integration tests included with this quickstart, which verify that the quickstart runs correctly, may also be run with the quickstart running on Kubernetes. +[NOTE] +==== +The integration tests expect a deployed application, so make sure you have deployed the quickstart on Kubernetes before you begin. +==== + +ifdef::extra-testing-actions-kubernetes[] +include::{extra-testing-actions-kubernetes}[leveloffset=+1] +endif::extra-testing-actions-kubernetes[] + +ifndef::extra-test-arguments-kubernetes[:extra-test-arguments-kubernetes:] + +Run the integration tests using the following command to run the `verify` goal with the `integration-testing` profile activated and the proper URL: +[source,options="nowrap",subs="+attributes"] +---- +$ mvn verify -Pintegration-testing -Dserver.host=http://localhost:8080 {extra-test-arguments-kubernetes} +---- + diff --git a/shared-doc/run-integration-tests-with-openshift.adoc b/shared-doc/run-integration-tests-with-openshift.adoc index 5d9a87487b..17e3271622 100644 --- a/shared-doc/run-integration-tests-with-openshift.adoc +++ b/shared-doc/run-integration-tests-with-openshift.adoc @@ -6,23 +6,23 @@ The integration tests included with this quickstart, which verify that the quick The integration tests expect a deployed application, so make sure you have deployed the quickstart on OpenShift before you begin. ==== -ifdef::extra-openshift-testing-actions[] -include::{extra-openshift-testing-actions}[leveloffset=+1] -endif::extra-openshift-testing-actions[] +ifdef::extra-testing-actions-openshift[] +include::{extra-testing-actions-openshift}[leveloffset=+1] +endif::extra-testing-actions-openshift[] -ifndef::extra-openshift-test-arguments[:extra-openshift-test-arguments:] +ifndef::extra-test-arguments-openshift[:extra-test-arguments-openshift:] Run the integration tests using the following command to run the `verify` goal with the `integration-testing` profile activated and the proper URL: ifndef::requires-http-route[] [source,options="nowrap",subs="+attributes"] ---- -$ mvn verify -Pintegration-testing -Dserver.host=https://$(oc get route {helm-app-name} --template='{{ .spec.host }}') {extra-openshift-test-arguments} +$ mvn verify -Pintegration-testing -Dserver.host=https://$(oc get route {helm-app-name} --template='{{ .spec.host }}') {extra-test-arguments-openshift} ---- endif::requires-http-route[] ifdef::requires-http-route[] [source,options="nowrap",subs="+attributes"] ---- -$ mvn verify -Pintegration-testing -Dserver.host=http://$(oc get route {helm-app-name} --template='{{ .spec.host }}') {extra-openshift-test-arguments} +$ mvn verify -Pintegration-testing -Dserver.host=http://$(oc get route {helm-app-name} --template='{{ .spec.host }}') {extra-test-arguments-openshift} ---- endif::requires-http-route[] diff --git a/spring-resteasy/README-source.adoc b/spring-resteasy/README-source.adoc index ce8656365f..1ed180f4f2 100644 --- a/spring-resteasy/README-source.adoc +++ b/spring-resteasy/README-source.adoc @@ -76,3 +76,7 @@ ifndef::ProductRelease,EAPXPRelease[] include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] endif::[] include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] +ifndef::ProductRelease,EAPXPRelease[] +// Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +endif::[] diff --git a/tasks-jsf/README-source.adoc b/tasks-jsf/README-source.adoc index 9eb0c8fd72..979493c391 100644 --- a/tasks-jsf/README-source.adoc +++ b/tasks-jsf/README-source.adoc @@ -69,4 +69,8 @@ include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] ifndef::ProductRelease,EAPXPRelease[] include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] endif::[] -include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] \ No newline at end of file +include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] +ifndef::ProductRelease,EAPXPRelease[] +// Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +endif::[] diff --git a/temperature-converter/README-source.adoc b/temperature-converter/README-source.adoc index 8b9b2d8e4f..058dc16c68 100644 --- a/temperature-converter/README-source.adoc +++ b/temperature-converter/README-source.adoc @@ -59,4 +59,8 @@ include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] ifndef::ProductRelease,EAPXPRelease[] include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] endif::[] -include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] \ No newline at end of file +include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] +ifndef::ProductRelease,EAPXPRelease[] +// Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +endif::[] diff --git a/thread-racing/README-source.adoc b/thread-racing/README-source.adoc index 63c6f5c0e6..6ef7e33e57 100644 --- a/thread-racing/README-source.adoc +++ b/thread-racing/README-source.adoc @@ -72,4 +72,8 @@ include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] ifndef::ProductRelease,EAPXPRelease[] include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] endif::[] -include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] \ No newline at end of file +include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] +ifndef::ProductRelease,EAPXPRelease[] +// Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +endif::[] diff --git a/todo-backend/README-source.adoc b/todo-backend/README-source.adoc index ad5456cb9b..178382c2b7 100644 --- a/todo-backend/README-source.adoc +++ b/todo-backend/README-source.adoc @@ -11,8 +11,10 @@ include::../shared-doc/attributes.adoc[] :openshift: true :archiveType: war :useHelmChartDir: true -:helm-install-prerequisites: ../todo-backend/helm-install-prerequisites.adoc +:helm-install-prerequisites-openshift: ../todo-backend/helm-install-prerequisites.adoc +:helm-install-prerequisites-kubernetes: ../todo-backend/helm-install-prerequisites.adoc :portedToGlow: true +:helmSetWildFlyArgumentPrefix: wildfly. [abstract] The `todo-backend` quickstart demonstrates how to implement a backend that exposes a HTTP API with JAX-RS @@ -209,80 +211,28 @@ $ 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] - +//=========================================================== +// Openshift - START == Run the Backend on OpenShift // OpenShift include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] - -=== Environment variables for PostgreSQL - -The Helm Chart also contains the environment variables required to connect to the PostgreSQL database. - -ifndef::ProductRelease[] -In local deployment the credentials were passed directly as the values of the environment variables. +include::../todo-backend/additional-readme-openshift.adoc[leveloffset=+1] +// OpenShift - END +//=========================================================== + +//=========================================================== +// Kubernetes - START +ifndef::ProductRelease,EAPXPRelease[] +== Run the Backend on Kubernetes + +//Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +include::../todo-backend/additional-readme-kubernetes.adoc[leveloffset=+1] endif::[] +// Kubernetes - END +//=========================================================== -For OpenShift, we rely on secrets so that the credentials are never copied outside OpenShift: - -[source,options="nowrap"] ----- -deploy: - env: - - name: POSTGRESQL_PASSWORD - valueFrom: - secretKeyRef: - key: database-password - name: todo-backend-db ----- - -When the application is deployed, the value for the `POSTGRESQL_PASSWORD` will be taken from the key `database-password` -in the secret `todo-backend-db`. - -// Testing on Openshift -include::../shared-doc/run-integration-tests-with-openshift.adoc[leveloffset=+1] - -=== Use the todobackend Web Frontend - -Once the backend is deployed on OpenShift, it can be accessed from the route `todo-backend`. -Let's find the host that we can use to connect to this backend: - -[source,options="nowrap"] ----- -$ oc get route todo-backend -o jsonpath="{.spec.host}" -todo-backend-jmesnil1-dev.apps.sandbox.x8i5.p1.openshiftapps.com ----- - -This value will be different for every installation of the backend. - -[WARNING] -==== -Make sure to prepend the host with `https://` to be able to connect to the backend from the ToDo Backend Specs or Client. -The host must also be publicly accessible. -==== - -We can verify that this application is properly working as a ToDo Backend by running its https://todobackend.com/specs/index.html[specs] on it. - - -Once all tests passed, we can use the https://todobackend.com/client/index.html[todobackend client] to have a Web application connected to the backend. - -[NOTE] -==== -https://todobackend.com/[todobackend.com] is an external service used to showcase this quickstart. -It might not always be functional but does not impact the availability of this backend. -==== - -=== Clean Up - -==== Remove the Backend - -The backend can be deleted from OpenShift by running the command: - -[source,options="nowrap"] ----- -$ helm uninstall todo-backend -release "todo-backend" uninstalled ----- == Conclusion @@ -291,5 +241,5 @@ of a {productName} Jakarta EE backend on OpenShift to connect to an external dat ifndef::ProductRelease[] The use of a Server Provisioned deployment makes it seamless to move from a local deployment for development to a -deployment on OpenShift. +deployment on cloud platforms such as OpenShift and Kubernetes. endif::[] \ No newline at end of file diff --git a/todo-backend/additional-readme-cloud.adoc b/todo-backend/additional-readme-cloud.adoc new file mode 100644 index 0000000000..86183341b1 --- /dev/null +++ b/todo-backend/additional-readme-cloud.adoc @@ -0,0 +1,74 @@ +ifdef::additional-readme-openshift[] +:additional-readme-cloud-platform: OpenShift +endif::[] +ifdef::additional-readme-kubernetes[] +:additional-readme-cloud-platform: Kubernetes +endif::[] + +=== Environment variables for PostgreSQL + +The Helm Chart also contains the environment variables required to connect to the PostgreSQL database. + +ifndef::ProductRelease[] +In local deployment the credentials were passed directly as the values of the environment variables. +endif::[] + +For {additional-readme-cloud-platform}, we rely on secrets so that the credentials are never copied outside {additional-readme-cloud-platform}: + +[source,options="nowrap"] +---- +deploy: + env: + - name: POSTGRESQL_PASSWORD + valueFrom: + secretKeyRef: + key: database-password + name: todo-backend-db +---- + +When the application is deployed, the value for the `POSTGRESQL_PASSWORD` will be taken from the key `database-password` +in the secret `todo-backend-db`. + +ifdef::additional-readme-openshift[] +== Use the todobackend Web Frontend + +Once the backend is deployed on {additional-readme-cloud-platform}, it can be accessed from the route `todo-backend`. +Let's find the host that we can use to connect to this backend: + +[source,options="nowrap"] +---- +$ oc get route todo-backend -o jsonpath="{.spec.host}" +todo-backend-jmesnil1-dev.apps.sandbox.x8i5.p1.openshiftapps.com +---- + +This value will be different for every installation of the backend. + +[WARNING] +==== +Make sure to prepend the host with `https://` to be able to connect to the backend from the ToDo Backend Specs or Client. +The host must also be publicly accessible. +==== + +We can verify that this application is properly working as a ToDo Backend by running its https://todobackend.com/specs/index.html[specs] on it. + + +Once all tests passed, we can use the https://todobackend.com/client/index.html[todobackend client] to have a Web application connected to the backend. + +[NOTE] +==== +https://todobackend.com/[todobackend.com] is an external service used to showcase this quickstart. +It might not always be functional but does not impact the availability of this backend. +==== +endif::[] + +== Clean Up + +=== Remove the Backend + +The backend can be deleted from {additional-readme-cloud-platform} by running the command: + +[source,options="nowrap"] +---- +$ helm uninstall todo-backend +release "todo-backend" uninstalled +---- \ No newline at end of file diff --git a/todo-backend/additional-readme-kubernetes.adoc b/todo-backend/additional-readme-kubernetes.adoc new file mode 100644 index 0000000000..1894d7279b --- /dev/null +++ b/todo-backend/additional-readme-kubernetes.adoc @@ -0,0 +1,4 @@ +:additional-readme-kubernetes: true +include::../todo-backend/additional-readme-cloud.adoc[] +// Unset the attribute +:!additional-readme-kubernetes: \ No newline at end of file diff --git a/todo-backend/additional-readme-openshift.adoc b/todo-backend/additional-readme-openshift.adoc new file mode 100644 index 0000000000..144ab7f3fc --- /dev/null +++ b/todo-backend/additional-readme-openshift.adoc @@ -0,0 +1,4 @@ +:additional-readme-openshift: true +include::../todo-backend/additional-readme-cloud.adoc[] +// Unset the attribute +:!additional-readme-openshift: \ No newline at end of file diff --git a/websocket-endpoint/README-source.adoc b/websocket-endpoint/README-source.adoc index 1b9622ef1f..298d2dbd50 100644 --- a/websocket-endpoint/README-source.adoc +++ b/websocket-endpoint/README-source.adoc @@ -57,4 +57,8 @@ include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] ifndef::ProductRelease,EAPXPRelease[] include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] endif::[] -include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] \ No newline at end of file +include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] +ifndef::ProductRelease,EAPXPRelease[] +// Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +endif::[] diff --git a/websocket-hello/README-source.adoc b/websocket-hello/README-source.adoc index f64a5ea94c..692e1a4e4e 100644 --- a/websocket-hello/README-source.adoc +++ b/websocket-hello/README-source.adoc @@ -63,4 +63,8 @@ include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] ifndef::ProductRelease,EAPXPRelease[] include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] endif::[] -include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] \ No newline at end of file +include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] +ifndef::ProductRelease,EAPXPRelease[] +// Kubernetes +include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] +endif::[]