<p>Do you think there is a way to create custom health check in kubernetes?</p>
<p>For example, using http get but if the content contains some string, then it's counted as failure.</p>

Sumanto Dinar
<p>You may use <code>exec</code> probe to create whichever logic you want. If your image contains curl, and your applications listens on 8080 port, you may insert something like</p>
<pre class="lang-yaml prettyprint-override"><code>    livenessProbe:
      exec:
        command:
        - bash
        - -c
        - exit &quot;$(curl localhost:8080 | grep -c 'BAD_STRING')&quot;
</code></pre>
<p>grep will return 0 if no &quot;bad&quot; strings are found, thus check will pass. Anything non-zero will result in probe failure.</p>
<p>You can use whichever script you find necessary, maybe you can put a healthcheck script inside your container and call it in exec section.</p>
<p>Relevant doc:</p>
<pre><code>kubectl explain deployment.spec.template.spec.containers.readinessProbe.exec
KIND:     Deployment
VERSION:  apps/v1

RESOURCE: exec &lt;Object&gt;

DESCRIPTION:
     One and only one of the following should be specified. Exec specifies the
     action to take.

     ExecAction describes a &quot;run in container&quot; action.

FIELDS:
   command      &lt;[]string&gt;
     Command is the command line to execute inside the container, the working
     directory for the command is root ('/') in the container's filesystem. The
     command is simply exec'd, it is not run inside a shell, so traditional
     shell instructions ('|', etc) won't work. To use a shell, you need to
     explicitly call out to that shell. Exit status of 0 is treated as
     live/healthy and non-zero is unhealthy.
</code></pre>
