Does anyone have K8S CronJob that upload data to dgraph?
Below is my basic cronjob.
Thanks
– Run only one instance of the job, never kill a long running
– Wake up every five minutes to check data files to upload in /dgraph/upload/ready
– Schama is present in /dgraph/upload/schama directory
– Remove the data file after successful upload
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: dgraph-live-uploader-job
namespace: dgraph
spec:
schedule: "*/5 * * * *"
concurrencyPolicy: "Forbid"
failedJobsHistoryLimit: 3
successfulJobsHistoryLimit: 10
startingDeadlineSeconds: 10 # 1 min
jobTemplate:
spec:
backoffLimit: 0
template:
spec:
containers:
- name: dgraph-live-uploader
image: dgraph/dgraph:v21.03.1
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- |
#!/usr/bin/env bash
echo Starting Live uploader CronJob
schemaFile="/dgraph/upload/scheme/studient.rdf"
echo Schema file is ${schemaFile}
for file in /dgraph/upload/ready*/*; do
if [ ! -f "$file" ]; then
echo "Not a file: $file"
continue
fi
dgraph live --files ${file} --schema ${schemaFile} --alpha dgraph-dgraph-alpha:9080 --zero dgraph-dgraph-zero:5080 --format=rdf --upsertPredicate "xid" -b 3000
returnCode=$?
echo The dgraph live ReturnCode = "${returnCode}"
if [ ${returnCode} -eq 0 ]; then
echo Removing successfully processed data file ${file}
rm ${file}
fi
done
volumeMounts:
- name: datadir
mountPath: /dgraph
dnsPolicy: ClusterFirst
restartPolicy: Never
nodeSelector:
agentpool: "ingest"
volumes:
- name: datadir
persistentVolumeClaim:
claimName: dgraph-azurefile