No Success Using vertx-config-kubernetes-configmap

287 views
Skip to first unread message

deven.p...@redhat.com

unread,
Jul 23, 2017, 8:47:21 AM7/23/17
to vert.x
I'm trying to use the configmap capabilities of the Vert.x Config module without much success:

ConfigStoreOptions kubeConfig = new ConfigStoreOptions()
.setType(CONFIGMAP)
.setFormat(HOCON)
.setConfig(new JsonObject()
.put(OPTIONAL, true)
.put("name", "application.properties"));

ConfigRetrieverOptions configRetrieverOptions = new ConfigRetrieverOptions()
.addStore(kubeConfig); // Values here will override identical keys from above

ConfigRetriever retriever = ConfigRetriever.create(vertx, configRetrieverOptions);
retriever.getConfig(res -> {
if (res.succeeded()) {
LOG.log(WARNING, res.result().encodePrettily());
// Do Other Stuff
startFuture.complete();
} else {
LOG.log(SEVERE, "Error loading config");
startFuture.fail(res.cause());
}
});


When I try to deploy this in Kubernetes/OpenShift, I get the following error:

SEVERE: Error loading config
java
.lang.NoClassDefFoundError: Could not initialize class io.fabric8.kubernetes.client.Config
 at io
.fabric8.kubernetes.client.ConfigBuilder.<init>(ConfigBuilder.java:16)
 at io
.fabric8.kubernetes.client.ConfigBuilder.<init>(ConfigBuilder.java:13)
 at io
.vertx.config.kubernetes.ConfigMapStore.lambda$getClient$0(ConfigMapStore.java:80)
 at io
.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:271)
 at io
.vertx.core.impl.TaskQueue.lambda$new$0(TaskQueue.java:60)
 at java
.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java
.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java
.lang.Thread.run(Thread.java:748)
Jul 23, 2017 12:40:11 PM io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer
SEVERE
: Failed in deploying verticle
java
.lang.NoClassDefFoundError: Could not initialize class io.fabric8.kubernetes.client.Config
 at io
.fabric8.kubernetes.client.ConfigBuilder.<init>(ConfigBuilder.java:16)
 at io
.fabric8.kubernetes.client.ConfigBuilder.<init>(ConfigBuilder.java:13)
 at io
.vertx.config.kubernetes.ConfigMapStore.lambda$getClient$0(ConfigMapStore.java:80)
 at io
.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:271)
 at io
.vertx.core.impl.TaskQueue.lambda$new$0(TaskQueue.java:60)
 at java
.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java
.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java
.lang.Thread.run(Thread.java:748)
java
.lang.NoClassDefFoundError: Could not initialize class io.fabric8.kubernetes.client.Config
 at io
.fabric8.kubernetes.client.ConfigBuilder.<init>(ConfigBuilder.java:16)
 at io
.fabric8.kubernetes.client.ConfigBuilder.<init>(ConfigBuilder.java:13)
 at io
.vertx.config.kubernetes.ConfigMapStore.lambda$getClient$0(ConfigMapStore.java:80)
 at io
.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:271)
 at io
.vertx.core.impl.TaskQueue.lambda$new$0(TaskQueue.java:60)
 at java
.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java
.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java
.lang.Thread.run(Thread.java:748)

Any suggestions would be greatly appreciated!!

Thanks,

Deven



Clement Escoffier

unread,
Jul 23, 2017, 9:42:47 AM7/23/17
to ve...@googlegroups.com
Hi Deven,

Which version of Kubernetes-client are you using. Also note that the Kubernetes client requires SLF4J - be sure to have it in your fat jar.
Here is an example of application using a config map: https://github.com/openshiftio-vertx-boosters/vertx-configmap-booster

About the two mentioned issues, I plan to remove the need on the kubernetes client to rely only on the Kubernetes REST API. 

Clement

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/815b5f77-00e5-4b3c-88b1-0408334053a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

deven.p...@redhat.com

unread,
Jul 23, 2017, 9:49:52 AM7/23/17
to vert.x
Ahhh!!! Missing the slf4j dependency could definitely cause that error... I will add it and give it a shot.

Deven

deven.p...@redhat.com

unread,
Jul 23, 2017, 10:21:04 AM7/23/17
to vert.x
Clement,

    Thanks, that got me further... Now I have an OpenShift permissions issue which I need to resolve which is telling me that my app's service account doesn't have access to the configmap... One thing I did want to bring up though is that I am seeing the event loop get blocked when trying to retrieve the configmap:

WARNING: Thread Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 10290 ms, time limit is 2000
io
.vertx.core.VertxException: Thread blocked
 at io
.vertx.core.impl.BlockedThreadChecker.registerThread(BlockedThreadChecker.java:67)
 at io
.vertx.core.impl.VertxThreadFactory.newThread(VertxThreadFactory.java:64)
 at java
.util.concurrent.ThreadPoolExecutor$Worker.<init>(ThreadPoolExecutor.java:612)
 at java
.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:925)
 at java
.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1357)
 at io
.vertx.core.impl.TaskQueue.execute(TaskQueue.java:78)
 at io
.vertx.core.impl.ContextImpl.executeBlocking(ContextImpl.java:291)
 at io
.vertx.core.impl.ContextImpl.executeBlocking(ContextImpl.java:240)
 at io
.vertx.core.impl.VertxImpl.executeBlocking(VertxImpl.java:650)
 at io
.vertx.core.impl.VertxImpl.executeBlocking(VertxImpl.java:656)
 at io
.vertx.config.kubernetes.ConfigMapStore.getClient(ConfigMapStore.java:74)
 at io
.vertx.config.kubernetes.ConfigMapStore.get(ConfigMapStore.java:105)
 at io
.vertx.config.impl.ConfigurationProvider.get(ConfigurationProvider.java:35)
 at io
.vertx.config.impl.ConfigRetrieverImpl.lambda$compute$8(ConfigRetrieverImpl.java:167)
 at io
.vertx.config.impl.ConfigRetrieverImpl$$Lambda$32/648252746.apply(Unknown Source)
 at java
.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
 at java
.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
 at java
.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
 at java
.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
 at java
.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
 at java
.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
 at java
.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
 at io
.vertx.config.impl.ConfigRetrieverImpl.compute(ConfigRetrieverImpl.java:176)
 at io
.vertx.config.impl.ConfigRetrieverImpl.getConfig(ConfigRetrieverImpl.java:98)
 at io
.vertx.config.impl.ConfigRetrieverImpl.<init>(ConfigRetrieverImpl.java:82)
 at io
.vertx.config.ConfigRetriever.create(ConfigRetriever.java:32)
 at com
.redhat.labs.ocp.MainVerticle.start(MainVerticle.java:45)
 at io
.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:434)
 at io
.vertx.core.impl.DeploymentManager$$Lambda$26/1932831450.handle(Unknown Source)
 at io
.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:337)
 at io
.vertx.core.impl.ContextImpl$$Lambda$27/440737101.run(Unknown Source)
 at io
.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
 at io
.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403)
 at io
.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:445)
 at io
.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
 at java
.lang.Thread.run(Thread.java:748)


Seems like that shouldn't be possible as calling retriever.getConfig() takes a callback lambda and should push the whole thing off of the event loop, right?

Let me know if I am perhaps missing something... Also, I pushed my example project up to GitHub for future reference: https://github.com/InfoSec812/vertx-configmap-example

Thanks!!

Deven

Clement Escoffier

unread,
Jul 23, 2017, 10:48:04 AM7/23/17
to ve...@googlegroups.com
Uh… that’s a bug. Can you open a ticket on vert.x config ? 

About the permission, you need:
$ oc policy add-role-to-user view -n $(oc project -q) -z default

Clement

deven.p...@redhat.com

unread,
Jul 23, 2017, 11:24:55 AM7/23/17
to vert.x
Clement,

    Issue opened: https://github.com/vert-x3/vertx-config/issues/18 . For now, as a workaround, we will just mount the configmap as a properties file in the pod.

Thanks,

Deven

Clement Escoffier

unread,
Jul 23, 2017, 12:26:42 PM7/23/17
to ve...@googlegroups.com
Did you try the example I posted before ? 
Accessing config maps using volumes or env variables do not catch updates.

Clement

Deven Phillips

unread,
Jul 23, 2017, 3:30:38 PM7/23/17
to ve...@googlegroups.com
Updates are not a concern because we would be deploying a new image in that case.

Thanks,

Deven

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/LZi9JjgCStc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Deven Phillips

Senior Consulting ENgineer, RED HAT OPEN INNOVATION LABS

Red Hat 

deven.p...@redhat.com


Deven Phillips

unread,
Jul 24, 2017, 1:08:34 PM7/24/17
to ve...@googlegroups.com
Clement,

    I got the configmap working for a JSON literal, but I am getting a Forbidden error for a set of secrets for our PostgreSQL DB... Is there something special we need to do there to make that work?

Thanks in advance!

Deven

Clement Escoffier

unread,
Jul 26, 2017, 4:27:03 AM7/26/17
to ve...@googlegroups.com
Hi,

Generally you can’t read secrets without very specific permissions (I need to re-discover them and document them). So, to read secrets I still recommend using ENV Var. Here is an example:

In fact in the case of secrets the need to hot reload is less prominent I would say. Because they require coordination between the client and the system being protected.

Clement

-- 
DEVEN PHILLIPS

SENIOR CONSULTING ENGINEER, RED HAT OPEN INNOVATION LABS

deven.p...@redhat.com





-- 
DEVEN PHILLIPS

SENIOR CONSULTING ENGINEER, RED HAT OPEN INNOVATION LABS

deven.p...@redhat.com



-- 

You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.

Deven Phillips

unread,
Jul 26, 2017, 8:24:27 AM7/26/17
to ve...@googlegroups.com
Clement,

    I've resolved this issue already by setting the "edit" permission for user "default" in the OpenShift project. Additionally, it is considered a VERY bad practice to put credentials into environment variables as it is relatively easy to capture those values. Anyhow, I also wired up the fabric8-maven-plugin and set it up to be able to deploy to either a local MiniShift/CDK installation or a remote OpenShift Container Platform cluster. Works great!

Deven

On Wed, Jul 26, 2017 at 4:26 AM, Clement Escoffier <clement....@gmail.com> wrote:
Hi,

Generally you can’t read secrets without very specific permissions (I need to re-discover them and document them). So, to read secrets I still recommend using ENV Var. Here is an example:

In fact in the case of secrets the need to hot reload is less prominent I would say. Because they require coordination between the client and the system being protected.

Clement
On 24 Jul 2017, at 19:08, Deven Phillips <deven.p...@redhat.com> wrote:

Clement,

    I got the configmap working for a JSON literal, but I am getting a Forbidden error for a set of secrets for our PostgreSQL DB... Is there something special we need to do there to make that work?

Thanks in advance!

Deven
On Sun, Jul 23, 2017 at 3:30 PM, Deven Phillips <deven.phillips@redhat.com> wrote:
Updates are not a concern because we would be deploying a new image in that case.

Thanks,

Deven

--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/LZi9JjgCStc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.

For more options, visit https://groups.google.com/d/optout.



--

Deven Phillips

Senior Consulting ENgineer, RED HAT OPEN INNOVATION LABS

Red Hat 

deven.p...@redhat.com


Reply all
Reply to author
Forward
0 new messages