<p>I'm working on a cluster in which I'm performing a lot scraping on Instagram to find valuable accounts and then message them to ask if they're interested in selling their account. This is what my application consists of:</p>

<ol>
  <li>Finding Instagram accounts by scraping for them with a lot of different accounts</li>
  <li>Refine the accounts retrieved and sort out the bad ones</li>
  <li>Message the chosen accounts</li>
</ol>

<p>In addition to this, I'm thinking of uploading every data of each step to a database (the whole chunk of accounts gathered in step 1, the refined accounts gathered in step 2, and the messaged users from step 3) in separate collections. I'm also thinking of developing a slack bot that handles errors by messaging me a report of the error and eventually so it can message me whenever a user responds.
As you can see, there are a lot of different parts of this application and that is the reason why I figured that using Kubernetes for this would be a good idea.</p>

<p>My initial approach to this was by making every pod in my node a rest API. Then I could send a request to each pod, each time I wanted them to run. But if figured that this would not be an optimal solution and not in any way a Kubernetes-way approach.</p>

kostberg
<p>The only way to achieve it in way you describe it is to communicate with Kubernetes API server from inside of your pod. This requires several thing (adding service account and role binding, using kubernetes client etc) and I would not recommended it as regular application flow (unless you are a devops trying to provide some generic/utility solution).</p>

<p>From another angle - sharing a volumes between pods and jobs should be avoided if possible (it adds complexity and restrictions)</p>

<p>You can dit more on this here - <a href="https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#accessing-the-api-from-within-a-pod" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#accessing-the-api-from-within-a-pod</a> - as a starter.</p>

<p>If I can suggest some solutions:</p>

<ul>
<li><p>you can share S3 volume and have Cronjob scheduled to
run every some time. If cronjob finds data - it process it. Therefore you do 
not need to trigger job from inside a pod.</p></li>
<li><p>Two services, sending data via http (if feasible) - second service don't do 
anything when it is not requested from it.</p></li>
</ul>

<p>If you share your usecase with some details probably better answers could be provided.</p>

<p>Cheers</p>
