Can you include a timeout option in a helm test template file?

8/27/2020

I know it's possible to change the timeout option when performing helm test from the command line by using the --timeout flag on the command line.

Is there a way to specify that in the template file instead?

-- JamesG419
kubernetes
kubernetes-helm

1 Answer

10/15/2020

If the tests are specified as Jobs instead of Pods, a deadline can be specified in the JobSpec by setting the activeDeadlineSeconds field.

apiVersion: batch/v1
kind: Job
metadata:
  name: "{{ include "helm-test-timeout.fullname" . }}-test-timeout"
  labels:
{{ include "helm-test-timeout.labels" . | nindent 4 }}
  annotations:
    "helm.sh/hook": test-success
spec:
  activeDeadlineSeconds: 30
  template:
    spec:
      containers:
      # The nginx container will just launch and wait
      # and cause the test to time out
      - name: nginx
        image: nginx
      restartPolicy: Never

However, this deadline cannot be extended with the --timeout flag to helm test.

-- Lauri Koskela
Source: StackOverflow