d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
98 lines
4.0 KiB
YAML
98 lines
4.0 KiB
YAML
{{- if .Values.cronjobs.enabled }}
|
|
{{- range $jobKey, $jobConfig := .Values.cronjobs.jobs }}
|
|
{{- if $jobConfig.enabled }}
|
|
---
|
|
apiVersion: batch/v1
|
|
kind: CronJob
|
|
metadata:
|
|
name: {{ include "sim.fullname" $ }}-{{ $jobConfig.name }}
|
|
namespace: {{ $.Release.Namespace }}
|
|
labels:
|
|
{{- include "sim.labels" $ | nindent 4 }}
|
|
app.kubernetes.io/component: cronjob-{{ $jobConfig.name }}
|
|
spec:
|
|
schedule: {{ $jobConfig.schedule | quote }}
|
|
concurrencyPolicy: {{ $jobConfig.concurrencyPolicy | default "Forbid" }}
|
|
successfulJobsHistoryLimit: {{ $jobConfig.successfulJobsHistoryLimit | default 3 }}
|
|
failedJobsHistoryLimit: {{ $jobConfig.failedJobsHistoryLimit | default 1 }}
|
|
{{- with $.Values.cronjobs.startingDeadlineSeconds }}
|
|
startingDeadlineSeconds: {{ . }}
|
|
{{- end }}
|
|
jobTemplate:
|
|
spec:
|
|
ttlSecondsAfterFinished: {{ $.Values.cronjobs.ttlSecondsAfterFinished | default 600 }}
|
|
{{- with $.Values.cronjobs.activeDeadlineSeconds }}
|
|
activeDeadlineSeconds: {{ . }}
|
|
{{- end }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
{{- include "sim.selectorLabels" $ | nindent 12 }}
|
|
app.kubernetes.io/component: cronjob-{{ $jobConfig.name }}
|
|
# Stable group label so NetworkPolicy can allow all cron pods → app
|
|
# without enumerating each job's component value.
|
|
simstudio.ai/component-group: cronjob
|
|
spec:
|
|
serviceAccountName: {{ include "sim.serviceAccountName" $ }}
|
|
automountServiceAccountToken: false
|
|
restartPolicy: {{ $.Values.cronjobs.restartPolicy | default "OnFailure" }}
|
|
{{- include "sim.podSecurityContext" $.Values.cronjobs | nindent 10 }}
|
|
containers:
|
|
- name: {{ $jobConfig.name }}
|
|
image: {{ include "sim.image" (dict "imageRoot" $.Values.cronjobs.image "global" $.Values.global "chartAppVersion" $.Chart.AppVersion) }}
|
|
imagePullPolicy: {{ $.Values.cronjobs.image.pullPolicy }}
|
|
{{- include "sim.containerSecurityContext" $.Values.cronjobs | nindent 12 }}
|
|
env:
|
|
- name: CRON_SECRET
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ include "sim.appSecretName" $ }}
|
|
key: CRON_SECRET
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
args:
|
|
- |
|
|
echo "Starting cron job: {{ $jobConfig.name }}"
|
|
echo "Making HTTP request to {{ $jobConfig.path }}"
|
|
|
|
# Determine the service URL (use internal service regardless of ingress)
|
|
SERVICE_URL="http://{{ include "sim.fullname" $ }}-app:{{ $.Values.app.service.port }}"
|
|
|
|
# Make the HTTP request with timeout and retry logic
|
|
for i in $(seq 1 3); do
|
|
echo "Attempt $i/3"
|
|
if curl -f -s -S --max-time 60 --retry 2 --retry-delay 5 \
|
|
-H "Content-Type: application/json" \
|
|
-H "User-Agent: Kubernetes-CronJob/{{ $jobConfig.name }}" \
|
|
-H "Authorization: Bearer ${CRON_SECRET}" \
|
|
"$SERVICE_URL{{ $jobConfig.path }}"; then
|
|
echo "Success: HTTP request completed"
|
|
exit 0
|
|
fi
|
|
echo "Attempt $i failed, retrying..."
|
|
sleep 10
|
|
done
|
|
echo "Error: All attempts failed"
|
|
exit 1
|
|
resources:
|
|
{{- toYaml $.Values.cronjobs.resources | nindent 14 }}
|
|
{{- with $.Values.global.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
{{- with $.Values.app.nodeSelector }}
|
|
nodeSelector:
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
{{- with $.Values.affinity }}
|
|
affinity:
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
{{- with $.Values.tolerations }}
|
|
tolerations:
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }} |