<commit_before>////
This guide is maintained in the main Quarkus repository
and pull requests should be submitted there:
https://github.com/quarkusio/quarkus/tree/master/docs/src/main/asciidoc
////

include::./attributes.adoc[]
= {project-name} - Deploying on Kubernetes and OpenShift

This guide covers:

* The deployment of the application to Kubernetes
* The deployment of the application to OpenShift

This guide takes as input the application developed in the link:building-native-image-guide.html[native application guide].
So, you should have been able to package your application as a binary executable, copied it in a Docker image and run this image.

Depending on whether you are a _bare_ Kubernetes user or an OpenShift user, pick the section you need.
The OpenShift section leverages OpenShift _builds_ and _routes_ features which are not available in _bare_ Kubernetes.

== Prerequisites

For this guide you need:

* roughly 10 minutes (20 minutes if you want to deploy the application on both platforms)
* having access to a Kubernetes and/or OpenShift cluster. Minikube and Minishift are valid options.
* being able to package the docker image from the link:building-native-image-guide.html[native application guide]

== Solution

We recommend to follow the instructions in the next sections and build the application step by step.
However, you can go right to the completed example.

Clone the Git repository: `git clone {quickstarts-clone-url}`, or download an {quickstarts-archive-url}[archive].

The solution is located in the `getting-started` directory.

== Deploying the application in Kubernetes

First, you need to _push_ the Docker image (created in the previous guide) to the image registry of your Kubernetes cluster.
Depending on your cluster, there are several ways.
For `minikube`, execute:

[source,shell]
----
# For minishift use "eval $(minishift docker-env)" instead
eval $(minikube docker-env)

docker build -f src/main/docker/Dockerfile -t quarkus-quickstart/quickstart .
----

Once the image has been pushed to the Kubernetes image registry, instantiate the application as follows:

[source,shell]
----
kubectl run quarkus-quickstart --image=quarkus-quickstart/quickstart:latest --port=8080 --image-pull-policy=IfNotPresent
kubectl expose deployment quarkus-quickstart --type=NodePort
----

The application is now exposed as an internal service. If you are using `minikube`, you can access it using:

[source,shell]
----
curl $(minikube service quarkus-quickstart --url)/hello/quarkus
----

== Deploying the application in OpenShift

In this section, we are going to leverage the build mechanism of OpenShift. Run:

[source,shell]
----
# To build the image on OpenShift
oc new-build --binary --name=quarkus-quickstart -l app=quarkus-quickstart
oc patch bc/quarkus-quickstart -p '{"spec":{"strategy":{"dockerStrategy":{"dockerfilePath":"src/main/docker/Dockerfile"}}}}'
oc start-build quarkus-quickstart --from-dir=. --follow

# To instantiate the image
oc new-app --image-stream=quarkus-quickstart:latest

# To create the route
oc expose service quarkus-quickstart

# Get the route URL
export URL="http://$(oc get route | grep quarkus-quickstart | awk '{print $2}')"
curl $URL/hello/greeting/quarkus
----

Your application is accessible at the printed URL.

== Going further

This guide covered the deployment of a Quarkus application on Kubernetes and OpenShift.
However, there is much more, and the integration with these environments has been tailored to make Quarkus applications execution very smooth.
For instance, the health extension can be used for health check; the configuration support allows mounting the application configuration using config map, the metric extension produces data _scrappable_ by Prometheus and so on.
<commit_msg>Printing app URL to make it visible to user<commit_after>////
This guide is maintained in the main Quarkus repository
and pull requests should be submitted there:
https://github.com/quarkusio/quarkus/tree/master/docs/src/main/asciidoc
////

include::./attributes.adoc[]
= {project-name} - Deploying on Kubernetes and OpenShift

This guide covers:

* The deployment of the application to Kubernetes
* The deployment of the application to OpenShift

This guide takes as input the application developed in the link:building-native-image-guide.html[native application guide].
So, you should have been able to package your application as a binary executable, copied it in a Docker image and run this image.

Depending on whether you are a _bare_ Kubernetes user or an OpenShift user, pick the section you need.
The OpenShift section leverages OpenShift _builds_ and _routes_ features which are not available in _bare_ Kubernetes.

== Prerequisites

For this guide you need:

* roughly 10 minutes (20 minutes if you want to deploy the application on both platforms)
* having access to a Kubernetes and/or OpenShift cluster. Minikube and Minishift are valid options.
* being able to package the docker image from the link:building-native-image-guide.html[native application guide]

== Solution

We recommend to follow the instructions in the next sections and build the application step by step.
However, you can go right to the completed example.

Clone the Git repository: `git clone {quickstarts-clone-url}`, or download an {quickstarts-archive-url}[archive].

The solution is located in the `getting-started` directory.

== Deploying the application in Kubernetes

First, you need to _push_ the Docker image (created in the previous guide) to the image registry of your Kubernetes cluster.
Depending on your cluster, there are several ways.
For `minikube`, execute:

[source,shell]
----
# For minishift use "eval $(minishift docker-env)" instead
eval $(minikube docker-env)

docker build -f src/main/docker/Dockerfile -t quarkus-quickstart/quickstart .
----

Once the image has been pushed to the Kubernetes image registry, instantiate the application as follows:

[source,shell]
----
kubectl run quarkus-quickstart --image=quarkus-quickstart/quickstart:latest --port=8080 --image-pull-policy=IfNotPresent
kubectl expose deployment quarkus-quickstart --type=NodePort
----

The application is now exposed as an internal service. If you are using `minikube`, you can access it using:

[source,shell]
----
curl $(minikube service quarkus-quickstart --url)/hello/quarkus
----

== Deploying the application in OpenShift

In this section, we are going to leverage the build mechanism of OpenShift. Run:

[source,shell]
----
# To build the image on OpenShift
oc new-build --binary --name=quarkus-quickstart -l app=quarkus-quickstart
oc patch bc/quarkus-quickstart -p '{"spec":{"strategy":{"dockerStrategy":{"dockerfilePath":"src/main/docker/Dockerfile"}}}}'
oc start-build quarkus-quickstart --from-dir=. --follow

# To instantiate the image
oc new-app --image-stream=quarkus-quickstart:latest

# To create the route
oc expose service quarkus-quickstart

# Get the route URL
export URL="http://$(oc get route | grep quarkus-quickstart | awk '{print $2}')"
echo "Application URL: $URL"
curl $URL/hello/greeting/quarkus
----

Your application is accessible at the printed URL.

== Going further

This guide covered the deployment of a Quarkus application on Kubernetes and OpenShift.
However, there is much more, and the integration with these environments has been tailored to make Quarkus applications execution very smooth.
For instance, the health extension can be used for health check; the configuration support allows mounting the application configuration using config map, the metric extension produces data _scrappable_ by Prometheus and so on.

{'fraction_non_alphanumeric': 0.07971679559459814, 'fraction_numerical': 0.0023600367116821818, 'mean_word_length': 4.629520295202952, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3215706', 'n_tokens_mistral': 2109, 'n_tokens_neox': 1992, 'n_words': 936}