Python
{{- with .Values.config.service }}{{- if .legacy_compatibility }}{{ fail "managed service chart requires approved releases; legacy compatibility is not supported" }}{{- end }}{{- end }}
{{- if not (regexMatch "@sha256:[a-f0-9]{64}$" .Values.image) -}}{{ fail "image must use a digest" }}{{- end -}}
{{- if not (has .Values.worker.ownership (list "manual" "gitops" "autoscaled")) -}}{{ fail "invalid replica ownership" }}{{- end -}}
{{- if lt (int .Values.terminationGracePeriodSeconds) (int (add .Values.worker.drainSeconds 60)) -}}{{ fail "termination grace must cover drain + 45s cleanup + 15s margin" }}{{- end -}}
{{- if not .Values.config.service -}}{{ fail "config.service is required" }}{{- end -}}
{{- $_ := set .Values.config.service "legacy_compatibility" false -}}
{{- if and .Values.config.artifacts (eq .Values.config.artifacts.kind "azure") -}}
{{- $a := .Values.config.artifacts -}}
{{- range $key := keys $a -}}{{- if not (has $key (list "kind" "deployment" "account" "container" "tenant_id" "client_id" "federated_token_file")) -}}{{ fail "unsupported Azure artifact configuration field" }}{{- end -}}{{- end -}}
{{- if not (regexMatch "^[A-Za-z0-9_-]{1,64}$" (default "" $a.deployment)) -}}{{ fail "Azure artifact deployment scope is invalid" }}{{- end -}}
{{- if not (regexMatch "^[a-z0-9]{3,24}$" (default "" $a.account)) -}}{{ fail "Azure artifact account is invalid" }}{{- end -}}
{{- if or (not (regexMatch "^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$" (default "" $a.container))) (contains "--" $a.container) -}}{{ fail "Azure artifact container is invalid" }}{{- end -}}
{{- range $id := list $a.tenant_id $a.client_id -}}
{{- if or (not (regexMatch "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" (default "" $id))) (eq $id "00000000-0000-0000-0000-000000000000") -}}{{ fail "Azure workload tenant/client ID must be a nonzero UUID" }}{{- end -}}
{{- end -}}
{{- if ne $a.federated_token_file "/var/run/secrets/azure/tokens/azure-identity-token" -}}{{ fail "Azure artifact token file must match the chart-owned projection" }}{{- end -}}
{{- end -}}
{{- if hasKey .Values.config "observability" -}}
{{- $obs := .Values.config.observability -}}
{{- if not (kindIs "map" $obs) -}}{{ fail "config.observability must be an object" }}{{- end -}}
{{- if not (hasKey $obs "schema") -}}{{- $_ := set $obs "schema" "ow_observability" -}}{{- end -}}
{{- if eq $obs.schema .Values.config.schema -}}{{ fail "recording schema must differ from execution schema" }}{{- end -}}
{{- if .Values.secrets.observability -}}
{{- $db := default (dict) $obs.database -}}
{{- if $db.database_loopback_plaintext -}}{{ fail "managed recording database requires verified TLS" }}{{- end -}}
{{- $_ := set $db "database_env" "OW_OBSERVABILITY_URL" -}}
{{- $_ := set $db "database_ca" "/run/observability/ca.crt" -}}
{{- $_ := set $obs "database" $db -}}
{{- else if hasKey $obs "database" -}}{{ fail "secrets.observability is required for a recording database override" }}{{- end -}}
{{- else if .Values.secrets.observability -}}{{ fail "enable config.observability before providing its database secret" }}{{- end -}}
{{- $platform := dict "endpoint" "https://kubernetes.default.svc" "caFile" "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" "tokenFile" "/var/run/secrets/kubernetes.io/serviceaccount/token" "pools" (list (dict "id" "default" "namespace" .Release.Namespace "deployment" (printf "%s-worker" .Release.Name) "ownership" .Values.worker.ownership "maxReplicas" .Values.worker.maxReplicas)) -}}
apiVersion: v1
kind: ConfigMap
metadata: {name: {{ .Release.Name }}-config}
data:
config.json: |
{{- mergeOverwrite (deepCopy .Values.config) (dict "kubernetes" $platform) | toPrettyJson | nindent 4 }}
nginx.conf: |
pid /tmp/nginx.pid;
error_log /dev/stderr warn;
events { worker_connections 256; }
http {
access_log off;
client_body_temp_path /tmp/body; proxy_temp_path /tmp/proxy;
fastcgi_temp_path /tmp/fastcgi; uwsgi_temp_path /tmp/uwsgi; scgi_temp_path /tmp/scgi;
server {
listen 8443 ssl;
ssl_certificate /tls/tls.crt; ssl_certificate_key /tls/tls.key;
ssl_protocols TLSv1.2 TLSv1.3; client_max_body_size 160k;
# Only artifact bytes get the 64 MiB transfer bound. Metadata and agent
# commands retain the smaller JSON limit; never spool artifact bodies.
location ~ ^/(v1/)?sessions/[A-Za-z0-9_-]+/artifacts/[A-Za-z0-9_-]+/content$ {
client_max_body_size 64m; client_body_timeout 120s;
proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1;
proxy_set_header Connection ""; proxy_request_buffering off;
proxy_buffering off; proxy_read_timeout 120s; proxy_send_timeout 120s; }
location / { proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1;
proxy_set_header Connection ""; proxy_buffering off; proxy_read_timeout 3600s; }
}
}
---
apiVersion: v1
kind: Service
metadata: {name: {{ .Release.Name }}-api}
spec:
selector: {app: {{ .Release.Name }}-api}
ports: [{name: https, port: 443, targetPort: 8443}]