-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature 1958: Add Apache Tomee sample project (#1972)
* Initial check in of Tomee example * Various updates related to issue #1958 - add hello world - update pom - add initial readme * Update Readme.MD * Various updates related to issue #1958 - add hello world - update pom - add initial readme Signed-off-by: Bart van Leeuwen <bart@netage.nl> * Add license headers Signed-off-by: Bart van Leeuwen <bart@netage.nl> * Fixup readme, merge conflict remains Signed-off-by: Bart van Leeuwen <bart@netage.nl> * to-squash Signed-off-by: Marc Nuri <marc@marcnuri.com> Signed-off-by: Bart van Leeuwen <bart@netage.nl> Signed-off-by: Marc Nuri <marc@marcnuri.com> Co-authored-by: Marc Nuri <marc@marcnuri.com>
- Loading branch information
1 parent
ea827f2
commit 09b656e
Showing
7 changed files
with
449 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
name: "Maven :: Tomee" | ||
description: | | ||
Example of using [Apache Tomee](https://tomee.apache.com) | ||
--- | ||
# Eclipse JKube Apache Tomee Quickstart | ||
|
||
This example shows how to integrate Eclipse JKube in an Apache Tomee application | ||
|
||
The result is a deployed Tomee microprofile instance which simply presents Hello World on request. | ||
More advanced Tomee configurations can be done inline according to the Tomee Maven plugin, and overrides as shown in the repository | ||
|
||
## Requirements | ||
|
||
- JDK 11 | ||
- Kubernetes Cluster, with LetsEncrypt support | ||
- kubectl logged in to cluster | ||
- Docker repository `$docker.host` | ||
- docker login to repository done on command line. | ||
- DNS entry for your hostname on the Kubernetes Cluster | ||
|
||
## Building and deploying the application | ||
|
||
|
||
```shell script | ||
$ mvn clean package k8s:deploy | ||
``` | ||
|
||
## Expected output | ||
|
||
Once you've deployed the application _(please allow 1 minute for the application to start)_, you should be able to go `https://$proj.hostname` and be greeted with: | ||
|
||
``` | ||
Hello World | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
<!-- | ||
Copyright (c) 2019 Red Hat, Inc. | ||
This program and the accompanying materials are made | ||
available under the terms of the Eclipse Public License 2.0 | ||
which is available at: | ||
https://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
Red Hat, Inc. - initial API and implementation | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.eclipse.jkube.quickstarts.maven</groupId> | ||
<artifactId>tomee</artifactId> | ||
<version>1.10.1</version> | ||
<name>Eclipse JKube :: Quickstarts :: Maven :: Tomee</name> | ||
<packaging>war</packaging> | ||
|
||
<description> | ||
Tomee deployment template for JKube | ||
</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version> | ||
<jkube.version>${project.version}</jkube.version> | ||
<tomee.version>8.0.13</tomee.version> | ||
<tomee.port>8080</tomee.port> | ||
<failOnMissingWebXml>false</failOnMissingWebXml> | ||
<k8sgroupId>com-example-container</k8sgroupId> | ||
<jkube.enricher.jkube-project-label.app>${k8sgroupId}-${project.artifactId}</jkube.enricher.jkube-project-label.app> | ||
<jkube.image.name>${docker.registry}/${project.groupId}.${project.artifactId}:latest</jkube.image.name> | ||
<docker.registry>docker.io</docker.registry> | ||
<proj.hostname>container.example.com</proj.hostname> | ||
<timestamp>${maven.build.timestamp}</timestamp> | ||
<maven.build.timestamp.format>yyyy-MM-dd_HH-mm</maven.build.timestamp.format> | ||
<work.version>${project.version}</work.version> | ||
</properties> | ||
<profiles> | ||
<profile> | ||
<id>develop</id> | ||
<properties> | ||
<work.version>${project.version}-${timestamp}</work.version> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
<build> | ||
<finalName>tomee</finalName> | ||
<plugins> | ||
<plugin> | ||
<version>${maven-compiler-plugin.version}</version> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<configuration> | ||
<failOnMissingWebXml>false</failOnMissingWebXml> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.tomee.maven</groupId> | ||
<artifactId>tomee-maven-plugin</artifactId> | ||
<version>${tomee.version}</version> | ||
<executions> | ||
<execution> | ||
<id>executable-jar</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<context>ROOT</context> | ||
<tomeeClassifier>microprofile</tomeeClassifier> | ||
<tomeeHttpPort>${tomee.port}</tomeeHttpPort> | ||
<simpleLog>true</simpleLog> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eclipse.jkube</groupId> | ||
<artifactId>kubernetes-maven-plugin</artifactId> | ||
<version>${jkube.version}</version> | ||
<executions> | ||
<execution> | ||
<id>k8s-build</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>build</goal> | ||
<goal>resource</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>k8s-install</id> | ||
<phase>install</phase> | ||
<goals> | ||
<goal>push</goal> | ||
<goal>apply</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<resources> | ||
<labels> | ||
<all> | ||
<property> | ||
<name>version</name> | ||
<value>${work.version}</value> | ||
</property> | ||
</all> | ||
</labels> | ||
<annotations> | ||
<ingress> | ||
<property> | ||
<name>ingress.kubernetes.io/rewrite-target</name> | ||
<value>/</value> | ||
</property> | ||
<property> | ||
<name>cert-manager.io/cluster-issuer</name> | ||
<value>letsencrypt-prod</value> | ||
</property> | ||
</ingress> | ||
</annotations> | ||
</resources> | ||
<images> | ||
<image> | ||
<name>${jkube.image.name}</name> | ||
<build> | ||
<from>adoptopenjdk:11-jre-hotspot</from> | ||
<assembly> | ||
<inline> | ||
<files> | ||
<file> | ||
<source>target/${project.artifactId}-exec.jar</source> | ||
<outputDirectory>.</outputDirectory> | ||
</file> | ||
</files> | ||
</inline> | ||
</assembly> | ||
<ports> | ||
<port>${tomee.port}</port> | ||
</ports> | ||
<cmd>java -jar maven/${project.artifactId}-exec.jar</cmd> | ||
</build> | ||
<run> | ||
<ports> | ||
<port>${tomee.port}:${tomee.port}</port> | ||
</ports> | ||
</run> | ||
</image> | ||
</images> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.tomee</groupId> | ||
<artifactId>javaee-api</artifactId> | ||
<version>8.0-6</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
33 changes: 33 additions & 0 deletions
33
quickstarts/maven/tomee/src/main/java/jkube/HelloWorld.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package jkube; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
|
||
@Path("/") | ||
@ApplicationScoped | ||
|
||
public class HelloWorld { | ||
|
||
@GET | ||
@Produces({ "text/html" }) | ||
|
||
public String getHello() { | ||
return "Hello World"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# Copyright (c) 2019 Red Hat, Inc. | ||
# This program and the accompanying materials are made | ||
# available under the terms of the Eclipse Public License 2.0 | ||
# which is available at: | ||
# | ||
# https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
spec: | ||
strategy: | ||
type: Recreate | ||
template: | ||
spec: | ||
containers: | ||
- imagePullPolicy: Always | ||
ports: | ||
- containerPort: ${tomee.port} | ||
name: http | ||
protocol: TCP | ||
imagePullSecrets: | ||
- name: netagehub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# Copyright (c) 2019 Red Hat, Inc. | ||
# This program and the accompanying materials are made | ||
# available under the terms of the Eclipse Public License 2.0 | ||
# which is available at: | ||
# | ||
# https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
apiVersion: networking.k8s.io/v1 | ||
spec: | ||
tls: | ||
- hosts: | ||
- ${proj.hostname} | ||
secretName: letsencrypt-${k8sgroupId}-${project.artifactId} | ||
rules: | ||
- host: ${proj.hostname} | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: ${project.artifactId} | ||
port: | ||
number: ${tomee.port} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# Copyright (c) 2019 Red Hat, Inc. | ||
# This program and the accompanying materials are made | ||
# available under the terms of the Eclipse Public License 2.0 | ||
# which is available at: | ||
# | ||
# https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
spec: | ||
ports: | ||
- port: ${tomee.port} |
Oops, something went wrong.