|
| 1 | +{{/* |
| 2 | +Shared pod plumbing for the tool-learning CronJobs. |
| 3 | +
|
| 4 | +Both the policy-computation job (cronjob-tool-learning.yaml) and the export-lake |
| 5 | +producer (cronjob-tool-learning-export.yaml) talk to the same Valkey, S3/MinIO |
| 6 | +lake and TLS material, so the environment and TLS volumes are defined once here |
| 7 | +to keep producer and consumer in sync. Call with the root context, e.g. |
| 8 | + env: |
| 9 | + {{- include "underpass-runtime.toolLearning.env" $ | nindent 16 }} |
| 10 | +*/}} |
| 11 | +{{- define "underpass-runtime.toolLearning.env" -}} |
| 12 | +- name: HOME |
| 13 | + value: /tmp |
| 14 | +- name: LOG_LEVEL |
| 15 | + value: {{ .Values.toolLearning.logLevel | quote }} |
| 16 | +{{- /* S3 / MinIO */}} |
| 17 | +- name: S3_ENDPOINT |
| 18 | + value: {{ .Values.toolLearning.s3.endpoint | quote }} |
| 19 | +- name: S3_REGION |
| 20 | + value: {{ .Values.toolLearning.s3.region | quote }} |
| 21 | +- name: S3_USE_SSL |
| 22 | + value: {{ or .Values.toolLearning.s3.useSSL (default false .Values.s3Tls.enabled) | quote }} |
| 23 | +- name: LAKE_BUCKET |
| 24 | + value: {{ .Values.toolLearning.s3.lakeBucket | quote }} |
| 25 | +- name: AUDIT_BUCKET |
| 26 | + value: {{ .Values.toolLearning.s3.auditBucket | quote }} |
| 27 | +{{- if .Values.toolLearning.s3.existingSecret }} |
| 28 | +- name: S3_ACCESS_KEY |
| 29 | + valueFrom: |
| 30 | + secretKeyRef: |
| 31 | + name: {{ .Values.toolLearning.s3.existingSecret }} |
| 32 | + key: {{ .Values.toolLearning.s3.accessKeyKey }} |
| 33 | +- name: S3_SECRET_KEY |
| 34 | + valueFrom: |
| 35 | + secretKeyRef: |
| 36 | + name: {{ .Values.toolLearning.s3.existingSecret }} |
| 37 | + key: {{ .Values.toolLearning.s3.secretKeyKey }} |
| 38 | +{{- end }} |
| 39 | +{{- /* S3 TLS */}} |
| 40 | +{{- if default false .Values.s3Tls.enabled }} |
| 41 | +{{- if and .Values.s3Tls.existingSecret .Values.s3Tls.keys.ca }} |
| 42 | +- name: S3_CA_PATH |
| 43 | + value: {{ printf "%s/%s" .Values.s3Tls.mountPath .Values.s3Tls.keys.ca | quote }} |
| 44 | +{{- end }} |
| 45 | +{{- if and .Values.s3Tls.keys.cert .Values.s3Tls.keys.key }} |
| 46 | +- name: S3_CERT_PATH |
| 47 | + value: {{ printf "%s/%s" .Values.s3Tls.mountPath .Values.s3Tls.keys.cert | quote }} |
| 48 | +- name: S3_KEY_PATH |
| 49 | + value: {{ printf "%s/%s" .Values.s3Tls.mountPath .Values.s3Tls.keys.key | quote }} |
| 50 | +{{- end }} |
| 51 | +{{- end }} |
| 52 | +{{- /* Valkey */}} |
| 53 | +- name: VALKEY_ADDR |
| 54 | + value: "{{ .Values.toolLearning.valkey.host }}:{{ .Values.toolLearning.valkey.port }}" |
| 55 | +- name: VALKEY_DB |
| 56 | + value: {{ .Values.toolLearning.valkey.db | quote }} |
| 57 | +- name: VALKEY_KEY_PREFIX |
| 58 | + value: {{ .Values.toolLearning.valkey.keyPrefix | quote }} |
| 59 | +- name: VALKEY_TTL |
| 60 | + value: {{ .Values.toolLearning.valkey.ttl | quote }} |
| 61 | +- name: VALKEY_TELEMETRY_PREFIX |
| 62 | + value: {{ .Values.toolLearning.valkey.telemetryPrefix | quote }} |
| 63 | +{{- if .Values.toolLearning.valkey.existingSecret }} |
| 64 | +- name: VALKEY_PASSWORD |
| 65 | + valueFrom: |
| 66 | + secretKeyRef: |
| 67 | + name: {{ .Values.toolLearning.valkey.existingSecret }} |
| 68 | + key: {{ .Values.toolLearning.valkey.passwordKey | default "password" }} |
| 69 | +{{- end }} |
| 70 | +{{- /* NATS */}} |
| 71 | +- name: NATS_URL |
| 72 | + value: {{ .Values.toolLearning.nats.url | quote }} |
| 73 | +{{- /* NATS TLS */}} |
| 74 | +{{- if ne (default "disabled" .Values.natsTls.mode) "disabled" }} |
| 75 | +- name: NATS_TLS_MODE |
| 76 | + value: {{ .Values.natsTls.mode | quote }} |
| 77 | +{{- if and .Values.natsTls.existingSecret .Values.natsTls.keys.ca }} |
| 78 | +- name: NATS_TLS_CA_PATH |
| 79 | + value: {{ printf "%s/%s" .Values.natsTls.mountPath .Values.natsTls.keys.ca | quote }} |
| 80 | +{{- end }} |
| 81 | +{{- if and .Values.natsTls.keys.cert .Values.natsTls.keys.key }} |
| 82 | +- name: NATS_TLS_CERT_PATH |
| 83 | + value: {{ printf "%s/%s" .Values.natsTls.mountPath .Values.natsTls.keys.cert | quote }} |
| 84 | +- name: NATS_TLS_KEY_PATH |
| 85 | + value: {{ printf "%s/%s" .Values.natsTls.mountPath .Values.natsTls.keys.key | quote }} |
| 86 | +{{- end }} |
| 87 | +{{- end }} |
| 88 | +{{- /* Valkey TLS */}} |
| 89 | +{{- if .Values.valkeyTls.enabled }} |
| 90 | +- name: VALKEY_TLS_ENABLED |
| 91 | + value: "true" |
| 92 | +{{- if and .Values.valkeyTls.existingSecret .Values.valkeyTls.keys.ca }} |
| 93 | +- name: VALKEY_TLS_CA_PATH |
| 94 | + value: {{ printf "%s/%s" .Values.valkeyTls.mountPath .Values.valkeyTls.keys.ca | quote }} |
| 95 | +{{- end }} |
| 96 | +{{- if and .Values.valkeyTls.keys.cert .Values.valkeyTls.keys.key }} |
| 97 | +- name: VALKEY_TLS_CERT_PATH |
| 98 | + value: {{ printf "%s/%s" .Values.valkeyTls.mountPath .Values.valkeyTls.keys.cert | quote }} |
| 99 | +- name: VALKEY_TLS_KEY_PATH |
| 100 | + value: {{ printf "%s/%s" .Values.valkeyTls.mountPath .Values.valkeyTls.keys.key | quote }} |
| 101 | +{{- end }} |
| 102 | +{{- end }} |
| 103 | +{{- /* DuckDB/libcurl custom CA + client cert for S3 mTLS */}} |
| 104 | +{{- if and (default false .Values.s3Tls.enabled) .Values.s3Tls.existingSecret .Values.s3Tls.keys.ca }} |
| 105 | +- name: SSL_CERT_FILE |
| 106 | + value: {{ printf "%s/%s" .Values.s3Tls.mountPath .Values.s3Tls.keys.ca | quote }} |
| 107 | +{{- if and .Values.s3Tls.keys.cert .Values.s3Tls.keys.key }} |
| 108 | +- name: CURL_SSLCERT |
| 109 | + value: {{ printf "%s/%s" .Values.s3Tls.mountPath .Values.s3Tls.keys.cert | quote }} |
| 110 | +- name: CURL_SSLKEY |
| 111 | + value: {{ printf "%s/%s" .Values.s3Tls.mountPath .Values.s3Tls.keys.key | quote }} |
| 112 | +{{- end }} |
| 113 | +{{- else if and .Values.valkeyTls.enabled .Values.valkeyTls.existingSecret .Values.valkeyTls.keys.ca }} |
| 114 | +{{- /* Fallback: reuse Valkey CA for DuckDB/libcurl when s3Tls is not configured */}} |
| 115 | +- name: SSL_CERT_FILE |
| 116 | + value: {{ printf "%s/%s" .Values.valkeyTls.mountPath .Values.valkeyTls.keys.ca | quote }} |
| 117 | +{{- end }} |
| 118 | +{{- end -}} |
| 119 | + |
| 120 | +{{- define "underpass-runtime.toolLearning.volumeMounts" -}} |
| 121 | +- name: tmp |
| 122 | + mountPath: /tmp |
| 123 | +{{- if and .Values.valkeyTls.enabled .Values.valkeyTls.existingSecret }} |
| 124 | +- name: valkey-tls |
| 125 | + mountPath: {{ .Values.valkeyTls.mountPath }} |
| 126 | + readOnly: true |
| 127 | +{{- end }} |
| 128 | +{{- if and (ne (default "disabled" .Values.natsTls.mode) "disabled") .Values.natsTls.existingSecret }} |
| 129 | +- name: nats-tls |
| 130 | + mountPath: {{ .Values.natsTls.mountPath }} |
| 131 | + readOnly: true |
| 132 | +{{- end }} |
| 133 | +{{- if and (default false .Values.s3Tls.enabled) .Values.s3Tls.existingSecret }} |
| 134 | +- name: s3-tls |
| 135 | + mountPath: {{ .Values.s3Tls.mountPath }} |
| 136 | + readOnly: true |
| 137 | +{{- end }} |
| 138 | +{{- end -}} |
| 139 | + |
| 140 | +{{- define "underpass-runtime.toolLearning.volumes" -}} |
| 141 | +- name: tmp |
| 142 | + emptyDir: |
| 143 | + sizeLimit: 256Mi |
| 144 | +{{- if and .Values.valkeyTls.enabled .Values.valkeyTls.existingSecret }} |
| 145 | +- name: valkey-tls |
| 146 | + secret: |
| 147 | + secretName: {{ .Values.valkeyTls.existingSecret }} |
| 148 | +{{- end }} |
| 149 | +{{- if and (ne (default "disabled" .Values.natsTls.mode) "disabled") .Values.natsTls.existingSecret }} |
| 150 | +- name: nats-tls |
| 151 | + secret: |
| 152 | + secretName: {{ .Values.natsTls.existingSecret }} |
| 153 | +{{- end }} |
| 154 | +{{- if and (default false .Values.s3Tls.enabled) .Values.s3Tls.existingSecret }} |
| 155 | +- name: s3-tls |
| 156 | + secret: |
| 157 | + secretName: {{ .Values.s3Tls.existingSecret }} |
| 158 | +{{- end }} |
| 159 | +{{- end -}} |
0 commit comments