Over a million developers have joined DZone.

WildFly Kubernetes Exec Probes [Snippets]

DZone's Guide to

WildFly Kubernetes Exec Probes [Snippets]

Want to run liveness and readiness probes for Kubernetes but don't have an HTTP endpoint? Here's how to run your checks with commands via WildFly.

· Cloud Zone ·
Free Resource

See why enterprise app developers love Cloud Foundry. Download the 2018 User Survey for a snapshot of Cloud Foundry users’ deployments and productivity.

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 command gives us the deployed applications:

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


We compose a shell command again to check whether our application 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!

Cloud Foundry saves app developers $100K and 10 weeks on average per development cycle. Download the 2018 User Survey for a snapshot of Cloud Foundry users’ deployments and productivity. Find out what people love about the industry standard cloud application platform.

wildfly ,kubernetes ,java ,java ee ,probe ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}