How to run shell command on node through Kubernetes

7,342 views
Skip to first unread message

dob...@gmail.com

unread,
Jun 7, 2017, 7:16:53 AM6/7/17
to Kubernetes user discussion and Q&A
I am looking for an option to run shell command on node through Kubernetes. Is this supported? Unfortunately, I can't find an example on the Internet, but it's strange since Kubernetes has access and enough permissions to do that.

Why do I need it? My application doesn't have a direct access to nodes in a cluster, it can access only Kubernetes API because of security reasons. The application manages and monitors Nodes and Pods, so there is only one way to execute operations on Pods and Nodes: Kubernetes API.


Many Thanks

Rodrigo Campos

unread,
Jun 7, 2017, 8:27:57 AM6/7/17
to kubernet...@googlegroups.com


On Wednesday, June 7, 2017, <dob...@gmail.com> wrote:
I am looking for an option to run shell command on node through Kubernetes. Is this supported? Unfortunately, I can't find an example on the Internet, but it's strange since Kubernetes has access and enough permissions to do that.

Why do I need it? My application doesn't have a direct access to nodes in a cluster, it can access only Kubernetes API because of security reasons. The application manages and monitors Nodes and Pods, so there is only one way to execute operations on Pods and Nodes: Kubernetes API.

Nodes or pods?

You can execute on pods via kubectl exec.

On nodes, I don't think there is any way. You just a daemonSet with hostpath or host network or something like that.

But you usually don't want to just exec something. You want something self-healing and immutable pods. So, for pods you should consider build and deploy again, and for nodes a daemonSet that constantly run and checks all it needs and acts accordingly.




Thanks,
Rodrigo

Rodrigo Campos

unread,
Jun 7, 2017, 12:19:24 PM6/7/17
to kubernet...@googlegroups.com
Oh, you can use fabric, that supports a bastion host and even use the coreOS
integration. See: https://github.com/coreos/fabric-kubernetes-nodes


But for some things, self-healing might be way better :)
Reply all
Reply to author
Forward
0 new messages