Skip to content

Commit f7c4acf

Browse files
authored
Merge pull request quarkusio#45986 from sheilamjones/QDOCS-1083-native-executables
Docs: Create procedure for Deploying Quarkus applications compiled to native executables based
2 parents e99d4fb + 7041d32 commit f7c4acf

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
////
2+
This guide is maintained in the main Quarkus repository
3+
and pull requests should be submitted there:
4+
https://github.com/quarkusio/quarkus/tree/main/docs/src/main/asciidoc
5+
////
6+
[id="deploying-to-openshift-native-howto"]
7+
= Deploy {project-name} applications compiled to native executables
8+
9+
include::_attributes.adoc[]
10+
:diataxis-type: howto
11+
:categories: cloud, native
12+
:summary: This guide describes how to deploy a Quarkus application to {openshift} compiled to native executables.
13+
:topics: devops,kubernetes,openshift,cloud,deployment
14+
:extensions: io.quarkus:quarkus-openshift
15+
16+
You can deploy your native {project-name} applications to {openshift} compiled to native executables by using the Docker build strategy.
17+
18+
You must create a native executable for your application that targets the Linux AMD64 operating system.
19+
If your host operating system is different from this, create a native Linux executable by using a container runtime, for example, Docker or Podman.
20+
21+
Your Quarkus project includes pregenerated Dockerfiles with instructions.
22+
If you want to use a custom Dockerfile, add the file to the `src/main/docker` directory or any location inside the module.
23+
Additionally, set the path to your Dockerfile by using the `quarkus.openshift.native-dockerfile` property.
24+
25+
== Prerequisites
26+
27+
* You have a Linux AMD64 system or an Open Container Initiative (OCI) compatible container runtime, such as Podman or Docker.
28+
* You have a Quarkus Maven project that includes the `quarkus-openshift` extension.
29+
* You are working in the correct OpenShift project namespace.
30+
31+
== Procedure
32+
33+
. Set the Docker build strategy in your `application.properties` configuration file:
34+
+
35+
[source, properties]
36+
----
37+
quarkus.openshift.build-strategy=docker
38+
----
39+
. Enable container-based native builds:
40+
+
41+
[source,properties]
42+
----
43+
quarkus.native.container-build=true
44+
----
45+
. Optional: Set the following properties in the `application.properties` file based on your environment:
46+
** If you are using an untrusted certificate, enable certificate trust for the `KubernetesClient`:
47+
+
48+
[source,properties]
49+
----
50+
quarkus.kubernetes-client.trust-certs=true
51+
----
52+
** To expose the service and create an {openshift} route, set the following property:
53+
+
54+
[source,properties]
55+
----
56+
quarkus.openshift.route.expose=true
57+
----
58+
** To use a custom Dockerfile instead of the pregenerated Dockerfiles, set the path to your custom Dockerfile:
59+
+
60+
[source,properties,subs="attributes+,+quotes"]
61+
----
62+
quarkus.openshift.native-dockerfile=<path_to_your_dockerfile>
63+
----
64+
For example, to specify a custom Dockerfile named `Dockerfile.custom-native`:
65+
+
66+
[source,properties]
67+
----
68+
quarkus.openshift.native-dockerfile=src/main/docker/Dockerfile.custom-native
69+
----
70+
71+
** Specify the container engine:
72+
*** To build a native executable with Podman:
73+
+
74+
[source,properties]
75+
----
76+
quarkus.native.container-runtime=podman
77+
----
78+
*** To build a native executable with Docker:
79+
+
80+
[source,properties]
81+
----
82+
quarkus.native.container-runtime=docker
83+
----
84+
85+
. Finally, build the native executable, package, and deploy your application to {openshift}:
86+
+
87+
[source,shell,subs="attributes+,+quotes"]
88+
----
89+
./mvnw clean package -Pnative -Dquarkus.openshift.deploy=true
90+
----
91+
92+
== Verification
93+
94+
. Verify that an image stream and a service resource are created, and that the application is deployed.
95+
Use the {openshift} web console or the following {openshift} command-line interface (CLI) commands:
96+
+
97+
[source,shell,subs="attributes+,+quotes"]
98+
----
99+
oc get is <1>
100+
oc get pods <2>
101+
oc get svc <3>
102+
----
103+
<1> List the image streams created.
104+
<2> List the pods associated with your current OpenShift project.
105+
<3> List the Kubernetes services.
106+
107+
[start=2]
108+
. To get the log output for your application's pod, run the following command where `__<pod_name>__` is the name of the latest pod prefixed with the name of your application:
109+
+
110+
[source,shell,subs="attributes+,+quotes"]
111+
----
112+
oc logs -f __<pod_name>__
113+
----
114+
115+
== References
116+
117+
* xref:deploying-to-openshift.adoc[Deploying {project-name} applications to {openshift}]
118+

0 commit comments

Comments
 (0)