Skip to content

Commit

Permalink
chore: add scaledjob triggered by cron (#3478)
Browse files Browse the repository at this point in the history
* chore: add scaledjob triggered by cron

* fix: changed max replicas to two for scaledjob

* fix: changed max memory to 10GB so it can avoid lack of resources with ingesting pipeline
  • Loading branch information
JinIgarashi authored May 13, 2024
1 parent 55a1a1d commit bfa1a83
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions backends/k8s/stac-pipeline/yaml/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
args: ["-m", "undpstac_pipeline.cli", "queue", "--force"]
resources:
limits:
memory: "15G"
memory: "10G"
cpu: "2000m"
envFrom:
- secretRef:
Expand All @@ -39,7 +39,7 @@ spec:
failedJobsHistoryLimit: 0 # Optional. Default: 100. How many failed jobs should be kept.
envSourceContainerName: stac # Optional. Default: .spec.JobTargetRef.template.spec.containers[0]
minReplicaCount: 0 # Optional. Default: 0
maxReplicaCount: 1 # Optional. Default: 100
maxReplicaCount: 2 # Optional. Default: 100
rollout:
strategy: gradual # Optional. Default: default. Which Rollout Strategy KEDA will use.
propagationPolicy: foreground # Optional. Default: background. Kubernetes propagation policy for cleaning up existing jobs during rollout.
Expand All @@ -53,3 +53,48 @@ spec:
messageCount: "1" # default 5, scale/spin a pod for every message
activationMessageCount: "0" # default 0, ensure no pods exist if no messages exist in the queue
connectionFromEnv: AZURE_SERVICE_BUS_CONNECTION_STRING
---
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
name: stac-scaled-cron-job
namespace: stac
spec:
jobTargetRef:
parallelism: 1
completions: 1
activeDeadlineSeconds: 300
backoffLimit: 5
template:
spec:
nodeSelector:
type: "pipeline"
containers:
- name: stac
image: undpgeohub.azurecr.io/undp-data/geo-undpstac-pipeline:v0.0.4
imagePullPolicy: Always
command: ["python3"]
# register a message for yesterday into service bus queue
args:
["-m", "queue_register.cli", "yesterday", "--type", "nighttime"]
resources:
limits:
memory: "1G"
cpu: "100m"
envFrom:
- secretRef:
name: stac-secrets
optional: false
restartPolicy: Never
pollingInterval: 600 # Optional. set 10 min for interval to ensure only a process is created
envSourceContainerName: stac # Optional. Default: .spec.JobTargetRef.template.spec.containers[0]
scalingStrategy:
strategy: default
triggers:
- type: cron
metadata:
# Required
timezone: UTC # The acceptable values would be a value from the IANA Time Zone Database.
start: 30 23 * * * # At 23:30 PM
end: 40 23 * * * # At 23:40 PM
desiredReplicas: "1"

0 comments on commit bfa1a83

Please sign in to comment.