Enterprise Java

WildFly Kubernetes exec probes

Liveness and readiness probes tell Kubernetes whether a pod is running and ready to do some work. An enterprise application can probe the status of an application via HTTP. If no HTTP endpoint is exposed Kubernetes can also probe by executing commands.

WildFly ships with the useful jboss-cli.sh. This CLI retrieves information about the server and deployment states as follows:

$> ./jboss-cli.sh --connect --commands="ls"

product-name=WildFly Full

We can combine a shell command to check for running servers:
./jboss-cli.sh --connect --commands=ls | grep "server-state=running"

A similar commands gives us the deployed applications:

$> ./jboss-cli.sh --connect --commands="ls deployment"


We compose a shell command again to check whether our applications has been deployed successfully:
./jboss-cli.sh --connect --commands="ls deployment" | grep "hello.war"

Now let’s insert these commands into the YAML descriptor:

  - name: hello-joker
    image: docker.example.com/hello:1
    imagePullPolicy: IfNotPresent
          - /bin/sh
          - -c
          - /opt/jboss/wildfly/bin/jboss-cli.sh --connect --commands=ls | grep 'server-state=running'
          - /bin/sh
          - -c
          - /opt/jboss/wildfly/bin/jboss-cli.sh --connect --commands='ls deployment' | grep 'hello.war'

If your application emits status or “ping” resources, the easier way is to probe the pod via HTTP as shown in this post.

Happy application probing!

Found the post useful? Subscribe to my newsletter for more free content, tips and tricks on IT & Java:

Success! Now check your email to confirm your subscription.

Published on Java Code Geeks with permission by Sebastian Daschner, partner at our JCG program. See the original article here: WildFly Kubernetes exec probes

Opinions expressed by Java Code Geeks contributors are their own.

Want to know how to develop your skillset to become a Java Rockstar?

Join our newsletter to start rocking!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions


Sebastian Daschner

Sebastian Daschner is a self-employed Java consultant and trainer. He is the author of the book 'Architecting Modern Java EE Applications'. Sebastian is a Java Champion, Oracle Developer Champion and JavaOne Rockstar.
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Back to top button