<p>I'm using helm charts to deploy several REST services with into k8s with spring boot inside deployed container.</p>
<p>However, to be able to do final stage testing I need to introduce some sort of smart liveness probe - i.e. that the target application is actually running properly inside given container.</p>
<p>This can be easily justified by successful return code of simple <code>curl</code> command, however, here's the trick - command needs to be executed with some delay after particular release deployment to give application time to bootstrap.</p>
<p>Here's what I've figured for a test suite:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: &quot;{{ include &quot;chart.fullname&quot; . }}-test&quot;
  labels:
  {{- include &quot;chart.fullname&quot; . | nindent 4 }}
  annotations:
    &quot;helm.sh/hook&quot;: test-success
spec:
  containers:
    - name: test-curl
      image: curl
      command: ['curl']
      args: [' -X POST -i -H &quot;Accept: application/json&quot; -H &quot;Content-Type:application/json&quot; -d ''{&quot;foo&quot;:[&quot;bar&quot;]}'' {{ include &quot;chart.fullname&quot; . }}:{{ .Values.service.port }}']
  restartPolicy: Never
</code></pre>
<p>The key problem is that this test will be executed when service is not really started yet and thus fail anyway.</p>
<p>Is there some mechanism or workaround to introduce delay of execution for this test?</p>
<p>Setting some sleep step in separate test container comes to mind but i'm not sure if this will work properly for this case</p>

im_infamous
<p>thanks to @Emruz Hossain, I've figured the solution out:</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: &quot;{{ .Release.Name }}-test&quot;
  labels:
    app: {{ .Release.Name }}
    release: {{ .Release.Name }}
  annotations:
    &quot;helm.sh/hook&quot;: test-success
spec:
  ttlSecondsAfterFinished: 0
  template:
    spec:
      containers:
        - name: test-curl
          image: target-image:1.2.3
          imagePullPolicy: &quot;IfNotPresent&quot;
          command:
            - /bin/bash
            - -ec
            - |
              curl --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 5 --retry-max-time 30 --retry-all-errors http://{{ .Release.Name }}:{{ .Values.service.port }}/v1/rest -X POST -H &quot;content-type: application/json&quot; -d &quot;{\&quot;foo\&quot;:[\&quot;bar\&quot;]}&quot;
      restartPolicy: Never
</code></pre>
<p>requires k8s api server 1.20+ (due to <a href="https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/" rel="nofollow noreferrer">this</a>) and curl 7.71+ (due to <a href="https://curl.se/docs/manpage.html#--retry-all-errors" rel="nofollow noreferrer">this</a>)</p>
