# How to use the exec module to issue kubectl commands to control the cluster

**URL:** <https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189>\
**Category:** General\
**Created:** [2 August 2021 05:32 UTC](https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189 "2021-08-02T05:32:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lei1](https://avatars.discourse-cdn.com/v4/letter/l/8e7dd6/32.png) [@lei1](https://discourse.nodered.org/u/lei1)\
**Post date:** [2 August 2021 05:32 UTC](https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189/1 "2021-08-02T05:32:48Z")

</div>

I want to use the exec module in nodered to call kubectl commands outside the system. I have successfully called external docker commands by creating nodered containers with some docker files mounted to the outside, but calling k8s commands has not been done.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 August 2021 08:19 UTC](https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189/2 "2021-08-02T08:19:41Z")

</div>

Do the commands need `sudo` in order to run?

---

<div class="post-metadata">

**Author:** ![lei1](https://avatars.discourse-cdn.com/v4/letter/l/8e7dd6/32.png) [@lei1](https://discourse.nodered.org/u/lei1)\
**Post date:** [2 August 2021 08:32 UTC](https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189/3 "2021-08-02T08:32:02Z")

</div>

No, I think as long as I can run kubectl to create a pod

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 August 2021 11:04 UTC](https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189/4 "2021-08-02T11:04:24Z")

</div>

What is the command you are trying to run? If you are not already doing so then give the full path to the command.

Add debug nodes to all outputs of the exec node and see what comes out.

---

<div class="post-metadata">

**Author:** ![lei1](https://avatars.discourse-cdn.com/v4/letter/l/8e7dd6/32.png) [@lei1](https://discourse.nodered.org/u/lei1)\
**Post date:** [2 August 2021 11:16 UTC](https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189/5 "2021-08-02T11:16:49Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0d08ea09606bcdccad2acba1ec8d350ab93d5459.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 August 2021 11:19 UTC](https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189/6 "2021-08-02T11:19:22Z")

</div>

It is better to use separate debug nodes and give them names so you can identify them in the output. Also you should have set them to Output complete message. However you can see yourself what the problem is. It appears that you may not have followed my previous advice which was:

> [@Colin](#):
>
> If you are not already doing so then give the full path to the command.

---

<div class="post-metadata">

**Author:** ![lei1](https://avatars.discourse-cdn.com/v4/letter/l/8e7dd6/32.png) [@lei1](https://discourse.nodered.org/u/lei1)\
**Post date:** [2 August 2021 12:22 UTC](https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189/7 "2021-08-02T12:22:27Z")

</div>

I don't quite understand what you mean

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 August 2021 12:54 UTC](https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189/8 "2021-08-02T12:54:06Z")

</div>

If you go to a command line for your server, type in `whereis kubectl`, it will tell you where the file that is run for that command actually resides. You need to use that full path in Node-RED because when you are running commands inside Node-RED, the command environment is completely different to the one you get when using a terminal.

---

<div class="post-metadata">

**Author:** ![lei1](https://avatars.discourse-cdn.com/v4/letter/l/8e7dd6/32.png) [@lei1](https://discourse.nodered.org/u/lei1)\
**Post date:** [3 August 2021 04:06 UTC](https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189/10 "2021-08-03T04:06:37Z")

</div>

thank you so much

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 August 2021 04:06 UTC](https://discourse.nodered.org/t/how-to-use-the-exec-module-to-issue-kubectl-commands-to-control-the-cluster/49189/11 "2021-08-17T04:06:45Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
