Skip to content

Instantly share code, notes, and snippets.

@mrhalix
Created February 14, 2023 09:39
Show Gist options
  • Save mrhalix/f520f4153dfdc01c97dcc1da49dbc25a to your computer and use it in GitHub Desktop.
Save mrhalix/f520f4153dfdc01c97dcc1da49dbc25a to your computer and use it in GitHub Desktop.
A kubernetes cronjob which concurrently runs two commands when it starts, jobs: docker daemon + python script which uses docker pull,tag,push
apiVersion: batch/v1
kind: CronJob
metadata:
name: JOBNAME
namespace: NAMESPACE
spec:
schedule: "0 3 */10 * *"
jobTemplate:
spec:
template:
spec:
volumes:
- name: kubeconfig
secret:
secretName: kube-configs
containers:
- name: CONTAINERNAME
image: IMAGE
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
command:
- sh
- -c
- |
/usr/local/bin/dockerd-entrypoint.sh &
python3 XXX.py &
wait
# make docker and python code run concurently
volumeMounts:
- name: kubeconfig
readOnly: true
mountPath: "/root/kubeconfig"
resources:
limits:
cpu: 500m
memory: 1G
requests:
cpu: 500m
memory: 1G
restartPolicy: OnFailure
imagePullSecrets:
- name: REGISTRYSECRET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment