<p>I'm using janusgraph docker image - <a href="https://hub.docker.com/r/janusgraph/janusgraph" rel="nofollow noreferrer">https://hub.docker.com/r/janusgraph/janusgraph</a>
In my kubernetes deployment to initialise the remote graph using groovy script mounted to <code>docker-entrypoint-initdb.d</code></p>
<p>This works as expected but in case if the remote host is not ready the janusgraph container throws exception and is still in the running mode.</p>
<p>Because of this kubernetes will not attempt to restart the container again. Is there any way so that I can configure this janusgraph container to terminate in case of any exception</p>

Vivek
<p>As @Gavin has mentioned you can use probes to check if containers are working. <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">Liveness Probes</a> is used   to know when containers are failed. If a container is unresponsive - it can restart the container.</p>
<p>Readiness probes inform when the container is available for accepting traffic. The readiness probe is used to control which pods are used as the backends for a service. A pod is considered ready when all of its containers are ready. If a pod is not ready, it is removed from service Endpoints.</p>
<p>Kubernetes supports three mechanisms for implementing liveness and readiness probes:</p>
<p><strong>1)</strong> making an HTTP request against a container
This probes  have additional fields that can be set on  <code>httpGet</code>:</p>
<blockquote>
<ul>
<li><code>host</code>: Host name to connect to, defaults to the pod IP. You probably want to set &quot;Host&quot; in httpHeaders instead.</li>
<li><code>scheme</code>: Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP.</li>
<li><code>path</code>: Path to access on the HTTP server. Defaults to /.</li>
<li><code>httpHeaders</code>: Custom headers to set in the request. HTTP allows repeated headers.</li>
<li><code>port</code>: Name or number of the port to access on the container. Number must be in the range 1 to 65535.</li>
</ul>
</blockquote>
<p>Read more: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#http-probes" rel="nofollow noreferrer">http-probes</a>.</p>
<pre class="lang-yaml prettyprint-override"><code>livenessProbe:
  httpGet:
    path: /healthz
    port: liveness-port
</code></pre>
<p><strong>2)</strong> opening a TCP socket against a container</p>
<pre><code>initialDelaySeconds: 15  
livenessProbe: ~  
periodSeconds: 20  
port: 8080  
tcpSocket: ~
</code></pre>
<p><strong>3)</strong> running a command inside a container</p>
<pre><code>livenessProbe:  
  exec:  
    command:  
    - sh  
    - /tmp/status_check.sh  
  initialDelaySeconds: 10  
</code></pre>
<p>If you will get status code different than 0 this will mean that probe failed.
You can also add to probes additional params such as <code>initialDelaySeconds</code>: indicate number of seconds after the container has started before liveness or readiness probes are initiated. See: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes" rel="nofollow noreferrer">configuring-probes</a>.</p>
<p>In every case add also   <code>restartPolicy: Never</code>
to your pods definition. By default is always.</p>
