|
| 1 | +apiVersion: batch/v1 |
| 2 | +kind: Job |
| 3 | +metadata: |
| 4 | + name: {{ name }} |
| 5 | +spec: |
| 6 | + template: |
| 7 | + metadata: |
| 8 | + labels: |
| 9 | + app: {{ name }} |
| 10 | + spec: |
| 11 | + imagePullSecrets: |
| 12 | + - name: {{ image_pull_secret_name }} |
| 13 | + hostname: {{ name }} |
| 14 | + restartPolicy: OnFailure |
| 15 | + containers: |
| 16 | + - image: {{ container_image }}:{{ container_tag }} |
| 17 | + imagePullPolicy: Always |
| 18 | + name: {{ name }} |
| 19 | + resources: |
| 20 | + requests: |
| 21 | + cpu: "250m" |
| 22 | + memory: "500M" |
| 23 | + limits: |
| 24 | + cpu: "1550m" |
| 25 | + memory: {{ memory_hard_limit | default("1500M") }} |
| 26 | +{% if post_start_command is defined %} |
| 27 | + lifecycle: |
| 28 | + postStart: |
| 29 | + exec: |
| 30 | + command: ["/bin/bash", "-c", "{{ post_start_command }}"] |
| 31 | +{% endif %} |
| 32 | +{% if container_run_args != '' %} |
| 33 | + args: |
| 34 | +{% if advance_arg is defined and advance_arg == true %} |
| 35 | + - bash |
| 36 | + - -c |
| 37 | + - "{{ container_run_args }}" |
| 38 | +{% else %} |
| 39 | +{% for arg in container_run_args.split(' ') %} |
| 40 | + - {{ arg }} |
| 41 | +{% endfor %} |
| 42 | +{% endif %} |
| 43 | +{% endif %} |
| 44 | +{% if container_envs is defined %} |
| 45 | + env: |
| 46 | +{% for env in container_envs %} |
| 47 | +{% if (env.value is defined and env.value != 'ansible_undefined') or env.valueFrom is defined %} |
| 48 | + - name: {{ env.name }} |
| 49 | +{% if env.value is defined %} |
| 50 | + value: "{{ env.value }}" |
| 51 | +{% endif %} |
| 52 | +{% if env.valueFrom is defined %} |
| 53 | + valueFrom: |
| 54 | + fieldRef: |
| 55 | + fieldPath: {{ env.valueFrom }} |
| 56 | +{% endif %} |
| 57 | +{% endif %} |
| 58 | +{% endfor %} |
| 59 | +{% endif %} |
| 60 | +{% if add_capabilities is defined %} |
| 61 | + securityContext: |
| 62 | + capabilities: |
| 63 | + add: |
| 64 | +{% for cap in add_capabilities %} |
| 65 | + - {{ cap }} |
| 66 | +{% endfor %} |
| 67 | +{% endif %} |
| 68 | +{% if hosted_ports is defined %} |
| 69 | + ports: |
| 70 | +{% for port in hosted_ports %} |
| 71 | + - containerPort: {{ port }} |
| 72 | +{% endfor %} |
| 73 | +{% endif %} |
| 74 | +{% if volume_mounts is defined %} |
| 75 | + volumeMounts: |
| 76 | +{% for volume in volume_mounts %} |
| 77 | + - name: {{ volume.name }} |
| 78 | + mountPath: {{ volume.path }} |
| 79 | +{% endfor %} |
| 80 | +{% endif %} |
| 81 | +{% if volume_mounts is defined %} |
| 82 | + volumes: |
| 83 | +{% for volume in volume_mounts %} |
| 84 | + - name: {{ volume.name }} |
| 85 | +{% if volume.kind == "configMap" %} |
| 86 | + configMap: |
| 87 | + name: {{ volume.name }} |
| 88 | +{% endif %} |
| 89 | +{% if volume.kind == "persistent" %} |
| 90 | + persistentVolumeClaim: |
| 91 | + claimName: {{ volume.name }} |
| 92 | +{% endif %} |
| 93 | +{% endfor %} |
| 94 | +{% endif %} |
0 commit comments