-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Improved Vert.x 4 support + added quickstart
Signed-off-by: Marc Nuri <[email protected]>
- Loading branch information
Showing
5 changed files
with
210 additions
and
1 deletion.
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
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
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,46 @@ | ||
# Eclipse JKube Vert.x 4 Web Quickstart | ||
Eclipse Vert.x 4 Web example application declaring a Simple AbstractVerticle. | ||
|
||
### Steps to use | ||
|
||
Make sure that Kubernetes/OpenShift cluster or Minikube/minishift is running. | ||
|
||
#### For OpenShift | ||
```shell | ||
$ minishift start | ||
``` | ||
Below command will create your OpenShift resource descriptors. | ||
```shell | ||
$ mvn -Popenshift clean oc:resource | ||
``` | ||
|
||
Now start S2I build by hitting the build goal. | ||
```shell | ||
|
||
$ mvn -Popenshift package oc:build | ||
``` | ||
|
||
Below command will deploy your application on OpenShift cluster. | ||
```shell | ||
$ mvn -Popenshift oc:apply | ||
``` | ||
|
||
#### For Kubernetes | ||
Start your cluster: | ||
```shell | ||
$ minikube start | ||
``` | ||
Below command will create your Kubernetes resource descriptors. | ||
```shell | ||
$ mvn -Pkubernetes clean k8s:resource | ||
``` | ||
|
||
Now start docker build by hitting the build goal. | ||
```shell | ||
$ mvn -Pkubernetes package k8s:build | ||
``` | ||
|
||
Below command will deploy your application on Kubernetes cluster. | ||
```shell | ||
$ mvn -Pkubernetes k8s:deploy | ||
``` |
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,125 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.eclipse.jkube.quickstarts.maven</groupId> | ||
<artifactId>vertx-4</artifactId> | ||
<version>1.2.0-SNAPSHOT</version> | ||
<name>Eclipse JKube :: Quickstarts :: Maven :: Vertx 4 Web</name> | ||
<packaging>jar</packaging> | ||
|
||
<description> | ||
Eclipse Vert.x 4 example application declaring a Simple AbstractVerticle. | ||
</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version> | ||
<jkube.version>${project.version}</jkube.version> | ||
<vertx.version>4.0.2</vertx.version> | ||
<vertx.health.path>/</vertx.health.path> <!-- Used by JKube to determine the health check probes path --> | ||
<main.verticle>org.eclipse.jkube.quickstarts.maven.MainVerticle</main.verticle> | ||
<launcher.class>io.vertx.core.Launcher</launcher.class> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-stack-depchain</artifactId> | ||
<version>${vertx.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<!-- vertx --> | ||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-dropwizard-metrics</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>${maven-shade-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<transformers> | ||
<transformer | ||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<manifestEntries> | ||
<Main-Class>${launcher.class}</Main-Class> | ||
<Main-Verticle>${main.verticle}</Main-Verticle> | ||
</manifestEntries> | ||
</transformer> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> | ||
</transformers> | ||
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar | ||
</outputFile> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>kubernetes</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.jkube</groupId> | ||
<artifactId>kubernetes-maven-plugin</artifactId> | ||
<version>${jkube.version}</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
<profile> | ||
<id>openshift</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.jkube</groupId> | ||
<artifactId>openshift-maven-plugin</artifactId> | ||
<version>${jkube.version}</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
37 changes: 37 additions & 0 deletions
37
quickstarts/maven/vertx4/src/main/java/org/eclipse/jkube/quickstarts/maven/MainVerticle.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,37 @@ | ||
/** | ||
* 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 org.eclipse.jkube.quickstarts.maven; | ||
|
||
import io.vertx.core.AbstractVerticle; | ||
import io.vertx.core.Promise; | ||
|
||
public class MainVerticle extends AbstractVerticle { | ||
|
||
@Override | ||
public void start(Promise<Void> startPromise) { | ||
vertx.createHttpServer().requestHandler(req -> | ||
req.response() | ||
.putHeader("content-type", "text/plain") | ||
.end("Hello from Vert.x!") | ||
).listen(8080, http -> { | ||
if (http.succeeded()) { | ||
startPromise.complete(); | ||
System.out.println("HTTP server started on port 8080"); | ||
} else { | ||
startPromise.fail(http.cause()); | ||
} | ||
}); | ||
} | ||
} |