<p>i have a netcore webapi deployed on kubernetes. Every night at midnight i need to call an endpoint to do some operations on every pod, so i have deployed a cronjob that calls the api with curl and the method does the required operations.</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: test-cronjob
spec:
  schedule: &quot;0 0 * * *&quot;
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: test-cronjob
            image: curlimages/curl:7.74.0
            imagePullPolicy: IfNotPresent
            command:
              - &quot;/bin/sh&quot;
              - &quot;-ec&quot;
              - |
                date;
                echo &quot;doingOperation&quot;
                curl POST &quot;serviceName/DailyTask&quot;
          restartPolicy: OnFailurey
</code></pre>
<p>But this only calls one pod, the one assigned by my ingress.
There is a way to call every pod contained in a service?</p>

<p>That is an expected behavior as when we do <code>curl</code> on a Kubernetes <code>Service</code> object, it is expected to pass the requests to only one of the <code>endpoints</code> (IP of the pods). To achieve, what you need, you need to write a custom script that first gets the endpoints associated with the services and then iteratively call curl over them one by one.</p>
<p>Note: The pods IP can be changed due to pod re-creation so you should fetch the <code>endpoints</code> associated with the service in each run of the <code>cronjob</code>.</p>
