I have two tools communicating with each other via stdin and stdout. Now, I have to keep them in separate microservices. How can I run shell command from one microservice to another? The first one needs response of it's command from second microservice.
Asked
Active
Viewed 200 times
1
-
5By "microservice", do you mean "container"? Shell commands don't run from here to there, they just run. My guess is that you want to pipe the output of one command to the input of another command, and both commands run in different Docker containers or Kubernetes pods. Is that correct? If so, containers exist for the purpose to make this impossible. Run the commands in the same container, or use a different inter-process communication method, such as sockets. You could use `netcat` or `socat`, for example. – berndbausch Feb 06 '21 at 06:10
-
Yes, I am aware about reverse shell of netcat. I want to do something similar. I want to run remote shell command – sanketmlad Feb 06 '21 at 15:51
-
So, why don't you just use netcat? – berndbausch Feb 06 '21 at 23:33
-
because it can have security implications – sanketmlad Feb 07 '21 at 01:23
-
Set up an ssh tunnel between the containers to encrypt data while transferring it. – berndbausch Feb 07 '21 at 02:01
1 Answers
1
You can exec from one pod into another pod granted they have the RoleBinding
pods/exec
available in your namespace. I would listen to berndbausch though and re-architecture your solution as this pattern would be strange.
From <source pod>
: kubectl exec -it <destination pod> -- /bin/bash
![](../../users/profiles/616155.webp)
Wintermute
- 11
- 2