<p>I have a program which I have set up several jobs inside it. According to the figure, these jobs are executed every day at a certain time and, for example, send an SMS to a group of numbers.
When I deploy this to Kubernetes, multiple copies are created.
I want to know, do all these original and replica versions do this and send SMS? If it is true that one SMS should be sent to one number, not that several SMS messages should be sent to the same number.
My question is, how does Kubernetes deal with these programs and how should we deploy them correctly?
<a href="https://i.stack.imgur.com/nlLGN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nlLGN.png" alt="enter image description here" /></a></p>
<p>I have read various articles but I don't know which is the right way.</p>

<p>You can use <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer">CronJob</a> for that.</p>
<p>Since you have a single application with all cronjob code. You can modify the c# application to use an environment variable to decide the job type. This way you can create <code>CronJob</code> resource for each job you want.</p>
<h3>Notification Job</h3>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: batch/v1
kind: CronJob
metadata:
  name: notification-job
spec:
  schedule: &quot;* * * * *&quot;
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: notification-job
            image: org/my-csharp-cron-app:latest
            imagePullPolicy: IfNotPresent
          env:
          - name: JOB_TYPE
            value: &quot;NotificationJob&quot;
          restartPolicy: OnFailure
</code></pre>
<h3>Logger Job</h3>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: batch/v1
kind: CronJob
metadata:
  name: logger-job
spec:
  schedule: &quot;* * * * *&quot;
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: logger-job
            image: org/my-csharp-cron-app:latest
            imagePullPolicy: IfNotPresent
          env:
          - name: JOB_TYPE
            value: &quot;LoggerJob&quot;
          restartPolicy: OnFailure
</code></pre>
