I have a use case that my "./main" binary should run inside the pod and stop after some time (90 seconds) before launching a new pod by the cronJob object.
But I am not confused about how to add both sleep and run my binary in the background together. Please suggest a good approach to this and excuse me for any wrong syntax.
Dockerfile
FROM golang:alpine
WORKDIR /app
COPY main /app
RUN apk update && apk add bash
CMD ["./main &"]
---
cronjob.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: cron
namespace: test-cron
spec:
schedule: "*/2 * * * *"
concurrencyPolicy: Replace
successfulJobsHistoryLimit: 0
failedJobsHistoryLimit: 0
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
volumes:
- name: log
hostPath:
path: /data/log/test-cron/
containers:
- name: test-cron
image: test-kafka-0.5
command: ["sleep", "90"] // By adding this, the sleep command is working but my binary is not running inside my container.