Is there any wayto run bash script from one pod or init container to another pod?

6/11/2020

I have two K8s services A and B running. When service B pods come up, I have to trigger some bash script that executes on service A pods. How we can achieve that ?

Actual case: when service B pods scales, the init container of service B pods will perform some action on service A pods.

-- Rajen Patel
kubernetes

1 Answer

6/23/2020

You can't directly run scripts or other code in other pods. You need to make network calls to cause things to happen. The use case you describe sounds a little unusual, and a better way to do it might be to use the Kubernetes API in service A to watch for B pods, or to query the Service object for B to find out what pods are present when you need to know that.

-- Matt
Source: StackOverflow