Skip to content

Commit

Permalink
Add Kubernetes README for microprofile-health
Browse files Browse the repository at this point in the history
  • Loading branch information
kabir committed May 23, 2024
1 parent 2852420 commit 122a631
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 20 deletions.
17 changes: 14 additions & 3 deletions microprofile-health/README-source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ include::../shared-doc/attributes.adoc[]
:level: Beginner
:technologies: MicroProfile Health
:management-port-openshift:
:post-helm-install-actions: ../microprofile-health/expose-management-port.adoc
:extra-openshift-testing-actions: ../microprofile-health/expose-management-port.adoc
:extra-openshift-test-arguments: -Dserver.management.host=https://$(oc get route {artifactId}-management --template='{{ .spec.host }}')

// Additional Info for OpenShift
:post-helm-install-actions-openshift: ../microprofile-health/expose-management-port-openshift.adoc
:extra-testing-actions-openshift: {post-helm-install-actions-openshift}
:extra-test-arguments-openshift: -Dserver.management.host=https://$(oc get route {artifactId}-management --template='{{ .spec.host }}')

// Additional Info for Kubernetes
:post-helm-install-actions-kubernetes: ../microprofile-health/expose-management-port-kubernetes.adoc
:extra-testing-actions-kubernetes: {post-helm-install-actions-kubernetes}
:extra-test-arguments-kubernetes: -Dserver.management.host=http://localhost:9990

[abstract]
The `microprofile-health` quickstart demonstrates the use of the MicroProfile Health specification in {productName}.
Expand Down Expand Up @@ -455,6 +462,10 @@ include::../shared-doc/build-and-run-the-quickstart-with-bootable-jar.adoc[level

// 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

Expand Down
5 changes: 5 additions & 0 deletions microprofile-health/expose-management-port-kubernetes.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:expose-mgmt-port-kubernetes: true
include::expose-management-port.adoc[]

//Unset the attribute
:!expose-mgmt-port-kubernetes:
5 changes: 5 additions & 0 deletions microprofile-health/expose-management-port-openshift.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:expose-mgmt-port-openshift: true
include::expose-management-port.adoc[]

// Unset the attribute
:!expose-mgmt-port-openshift:
23 changes: 21 additions & 2 deletions microprofile-health/expose-management-port.adoc
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
ifdef::expose-mgmt-port-openshift[]
:expose-mgmt-port-cli: oc
:expose-mgmt-port-yaml-suffix: openshift
endif::[]
ifdef::expose-mgmt-port-kubernetes[]
:expose-mgmt-port-cli: kubectl
:expose-mgmt-port-yaml-suffix: kubernetes
endif::[]

This quickstart requires the management port (9990) to be exposed for demo purposes and testing. We do this only to demonstrate the concepts and ease the testing.

IMPORTANT: It is **not** recommended to expose the management port in a production environment!

To expose the management porte to manually exposes our service on port 9990 we deploying the following file:
To expose the management port to manually expose our service on port 9990 we deploy the following file:
[source,options="nowrap",subs="+attributes"]
----
oc apply -f charts/management-openshift.yml
{expose-mgmt-port-cli} apply -f charts/management-{expose-mgmt-port-yaml-suffix}.yml
----
Once this is deployed you will be able to access the management port via the created `microprofile-health-management` route.

ifdef::expose-mgmt-port-openshift[]
To get the address of the `microprofile-health-management` route, execute:
[source,options="nowrap",subs="+attributes"]
----
$ oc get route microprofile-health -o jsonpath="{.spec.host}"
----
endif::[]
ifdef::expose-mgmt-port-kubernetes[]
To access the management port from outside the cluster, we need to set up a Kubernetes port forward. This is done with the command:
[source,options="nowrap",subs="+attributes"]
----
{expose-mgmt-port-cli} port-forward service/microprofile-health-management 9990:9990
----
Note that the command to create the port-forward will not return, so it is easiest to run this in a separate terminal.
endif::[]
3 changes: 3 additions & 0 deletions shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ 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:
4 changes: 4 additions & 0 deletions shared-doc/build-and-run-the-quickstart-with-openshift.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
:cloud-platform: OpenShift
:openshift: true
ifndef::helm-app-name[]
:helm-app-name: {artifactId}
endif::helm-app-name[]
Expand All @@ -24,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:
11 changes: 7 additions & 4 deletions shared-doc/helm-deploy-project.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ If you want to see all the configuration elements to customize your deployment y
$ helm show readme {helmChartName}
----

ifndef::kubernetes[]
ifdef::openshift[]
Get the URL of the route to the deployment.

[source,options="nowrap",subs="+attributes"]
Expand All @@ -140,6 +140,9 @@ endif::[]
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[]
10 changes: 5 additions & 5 deletions shared-doc/run-integration-tests-with-kubernetes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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 Kubernetes before you begin.
====

ifdef::extra-kubernetes-testing-actions[]
include::{extra-kubernetes-testing-actions}[leveloffset=+1]
endif::extra-kubernetes-testing-actions[]
ifdef::extra-testing-actions-kubernetes[]
include::{extra-testing-actions-kubernetes}[leveloffset=+1]
endif::extra-testing-actions-kubernetes[]

ifndef::extra-kubernetes-test-arguments[:extra-kubernetes-test-arguments:]
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-openshift-test-arguments}
$ mvn verify -Pintegration-testing -Dserver.host=http://localhost:8080 {extra-test-arguments-kubernetes}
----

12 changes: 6 additions & 6 deletions shared-doc/run-integration-tests-with-openshift.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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[]

Expand Down

0 comments on commit 122a631

Please sign in to comment.