Skip to content

Commit

Permalink
feat: Improved Vert.x 4 support + added quickstart
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Mar 4, 2021
1 parent 1aaf217 commit e8d159b
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Usage:
* Fix #545: Replace Boolean.valueOf with Boolean.parseBoolean for string to boolean conversion
* Fix #515: Properties now get resolved in CustomResource fragments
* Fix #586: Apply and Undeploy service use configured namespace
* Fix #584: Improved Vert.x 4 support

### 1.1.1 (2021-02-23)
* Fix #570: Disable namespace creation during k8s:resource with `jkube.namespace` flag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean isApplicable(List<ImageConfiguration> configs) {
@Override
protected List<String> getExtraJavaOptions() {
List<String> opts = super.getExtraJavaOptions();
opts.add("-Dvertx.cacheDirBase=/tmp");
opts.add("-Dvertx.cacheDirBase=/tmp/vertx-cache");

if (! contains("-Dvertx.disableDnsResolver=", opts)) {
opts.add("-Dvertx.disableDnsResolver=true");
Expand Down
46 changes: 46 additions & 0 deletions quickstarts/maven/vertx4/README.md
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
```
125 changes: 125 additions & 0 deletions quickstarts/maven/vertx4/pom.xml
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>
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());
}
});
}
}

0 comments on commit e8d159b

Please sign in to comment.