github.com/kubeshop/testkube@v1.17.23/pkg/executor/containerexecutor/templates/job.tmpl (about)

     1  apiVersion: batch/v1
     2  kind: Job
     3  metadata:
     4    name: "{{ .Name }}"
     5    namespace: {{ .Namespace }}
     6  spec:
     7    {{- if gt .ActiveDeadlineSeconds 0 }}
     8    activeDeadlineSeconds: {{ .ActiveDeadlineSeconds }}
     9    {{- end }}
    10    template:
    11      spec:
    12  
    13  	    {{- if ne .InitImage "" }}
    14        initContainers:
    15        - name: {{ .Name }}-init
    16          {{- if .Registry }}
    17          image: {{ .Registry }}/{{ .InitImage }}
    18          {{- else }}
    19          image: {{ .InitImage }}
    20          {{- end }}
    21          imagePullPolicy: IfNotPresent
    22          command:
    23            - "/bin/runner"
    24            - '{{ .Jsn }}'
    25          {{- if .RunnerCustomCASecret }}
    26          env:
    27            - name: SSL_CERT_DIR
    28              value: /etc/testkube/certs
    29          {{- end }}
    30          volumeMounts:
    31          - name: data-volume
    32            mountPath: /data
    33          {{- if .CertificateSecret }}
    34          - name: {{ .CertificateSecret }}
    35            mountPath: /etc/certs
    36          {{- end }}
    37          {{- if .RunnerCustomCASecret }}
    38          - name: {{ .RunnerCustomCASecret }}
    39            mountPath: /etc/testkube/certs/testkube-custom-ca.pem
    40            readOnly: true
    41            subPath: ca.crt
    42          {{- end }}
    43          {{- if .ArtifactRequest }}
    44            {{- if .ArtifactRequest.VolumeMountPath }}
    45          - name: artifact-volume
    46            mountPath: {{ .ArtifactRequest.VolumeMountPath }}
    47            {{- end }}
    48          {{- end }}
    49          {{- range $configmap := .EnvConfigMaps }}
    50          {{- if and $configmap.Mount $configmap.Reference }}
    51          - name: {{ $configmap.Reference.Name }}
    52            mountPath: {{ $configmap.MountPath }}
    53          {{- end }}
    54          {{- end }}
    55          {{- range $secret := .EnvSecrets }}
    56          {{- if and $secret.Mount $secret.Reference }}
    57          - name: {{ $secret.Reference.Name }}
    58            mountPath: {{ $secret.MountPath }}
    59          {{- end }}
    60          {{- end }}
    61        {{- end }}
    62        containers:
    63        {{ if .Features.LogsV2 -}}
    64        - name: "{{ .Name }}-logs"
    65          image: {{ .Registry }}/{{ .LogSidecarImage }}
    66          env:
    67          - name: DEBUG
    68            value: "true"
    69          - name: NAMESPACE
    70            value: {{ .Namespace }}
    71          - name: NATS_URI
    72            value: "{{ .NatsUri }}"
    73          - name: ID
    74            value: "{{ .Name }}"
    75        {{- end }}
    76        - name: "{{ .Name }}"
    77          {{- if .Registry }}
    78          image: {{ .Registry }}/{{ .Image }}
    79          {{- else }}
    80          image: {{ .Image }}
    81          {{- end }}
    82          imagePullPolicy: IfNotPresent
    83  	    	{{- if gt (len .Command) 0 }}
    84          command:
    85          {{- range $cmd := .Command }}
    86          - {{ $cmd -}}
    87  	    	{{- end }}
    88  	    	{{- end -}}
    89  		    {{- if gt (len .Args) 0 }}
    90          args:
    91          {{- range $arg := .Args }}
    92          - {{ $arg -}}
    93  		    {{- end }}
    94  		    {{- end }}
    95          {{- if .WorkingDir }}
    96          workingDir: {{ .WorkingDir }}
    97          {{- end }}
    98          {{- if .RunnerCustomCASecret }}
    99          env:
   100            - name: SSL_CERT_DIR
   101              value: /etc/testkube/certs
   102          {{- end }}
   103          volumeMounts:
   104          - name: data-volume
   105            mountPath: /data
   106          {{- if .CertificateSecret }}
   107          - name: {{ .CertificateSecret }}
   108            mountPath: /etc/certs
   109          {{- end }}
   110          {{- if .RunnerCustomCASecret }}
   111          - name: {{ .RunnerCustomCASecret }}
   112            mountPath: /etc/testkube/certs/testkube-custom-ca.pem
   113            readOnly: true
   114            subPath: ca.crt
   115          {{- end }}
   116          {{- if .ArtifactRequest }}
   117            {{- if .ArtifactRequest.VolumeMountPath }}
   118          - name: artifact-volume
   119            mountPath: {{ .ArtifactRequest.VolumeMountPath }}
   120            {{- end }}
   121          {{- end }}
   122          {{- range $configmap := .EnvConfigMaps }}
   123          {{- if and $configmap.Mount $configmap.Reference }}
   124          - name: {{ $configmap.Reference.Name }}
   125            mountPath: {{ $configmap.MountPath }}
   126          {{- end }}
   127          {{- end }}
   128          {{- range $secret := .EnvSecrets }}
   129          {{- if and $secret.Mount $secret.Reference }}
   130          - name: {{ $secret.Reference.Name }}
   131            mountPath: {{ $secret.MountPath }}
   132          {{- end }}
   133          {{- end }}
   134        volumes:
   135        - name: data-volume
   136          emptyDir: {}
   137        {{- if .CertificateSecret }}
   138        - name: {{ .CertificateSecret }}
   139          secret:
   140            secretName: {{ .CertificateSecret }}
   141        {{- end }}
   142        {{- if .RunnerCustomCASecret }}
   143        - name: {{ .RunnerCustomCASecret }}
   144          secret:
   145            secretName: {{ .RunnerCustomCASecret }}
   146            defaultMode: 420
   147        {{- end }}
   148        {{- if .ArtifactRequest }}
   149          {{- if and .ArtifactRequest.VolumeMountPath (or .ArtifactRequest.StorageClassName .ArtifactRequest.UseDefaultStorageClassName) }}
   150        - name: artifact-volume
   151          persistentVolumeClaim:
   152            claimName: {{ .Name }}-pvc
   153          {{- end }}
   154        {{- end }}
   155        {{- range $configmap := .EnvConfigMaps }}
   156        {{- if and $configmap.Mount $configmap.Reference }}
   157        - name: {{ $configmap.Reference.Name }}
   158          configmap:
   159            name: {{ $configmap.Reference.Name }}
   160        {{- end }}
   161        {{- end }}
   162        {{- range $secret := .EnvSecrets }}
   163        {{- if and $secret.Mount $secret.Reference }}
   164        - name: {{ $secret.Reference.Name }}
   165          secret:
   166            secretName: {{ $secret.Reference.Name }}
   167        {{- end }}
   168        {{- end }}
   169        restartPolicy: Never
   170        {{- if .ServiceAccountName }}
   171        serviceAccountName: {{ .ServiceAccountName }}
   172        {{- end }}
   173        {{- if gt (len .ImagePullSecrets) 0 }}
   174        imagePullSecrets:
   175        {{- range $secret := .ImagePullSecrets }}
   176        - name: {{ $secret -}}
   177        {{- end }}
   178        {{- end }}
   179    backoffLimit: 0
   180    ttlSecondsAfterFinished: {{ .DelaySeconds }}