VOOZH about

URL: https://www.javacodegeeks.com/2017/11/wildfly-kubernetes-exec-probes.html

⇱ WildFly Kubernetes exec probes - Java Code Geeks


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"

[...]
process-type=Server
product-name=WildFly Full
product-version=11.0.0.Final
[...]
server-state=running
suspend-state=RUNNING
uuid=c52658a9-ca39-4548-9879-162cd6e14d93

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"

hello.war

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:

...
 containers:
 - name: hello-joker
 image: docker.example.com/hello:1
 imagePullPolicy: IfNotPresent
 livenessProbe:
 exec:
 command:
 - /bin/sh
 - -c
 - /opt/jboss/wildfly/bin/jboss-cli.sh --connect --commands=ls | grep 'server-state=running'
 readinessProbe:
 exec:
 command:
 - /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.

Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
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 ....
I agree to the Terms and Privacy Policy

Thank you!

We will contact you soon.

πŸ‘ Photo of Sebastian Daschner
Sebastian Daschner
November 8th, 2017Last Updated: November 8th, 2017
0 195 1 minute read

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.
Subscribe

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

0 Comments
Oldest
Newest Most Voted
Back to top button
Close
wpDiscuz