Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node enables interaction with Kubernetes resources, specifically supporting operations on ReplicaSets among other resource types. The Exec operation allows executing commands inside a container of a Kubernetes pod associated with the specified resource. This is useful for debugging, running scripts, or performing administrative tasks directly within the container environment.

Common scenarios include:

  • Running diagnostic commands inside a pod managed by a ReplicaSet.
  • Executing maintenance scripts without redeploying containers.
  • Quickly inspecting the state or logs of applications running in pods.

For example, you might use this node to execute a shell command inside a pod of a ReplicaSet to check application status or modify runtime configuration temporarily.

Properties

Name Meaning
Image The container image name used when running or restarting pods; relevant for Exec as context.
Namespace The Kubernetes namespace where the ReplicaSet and its pods reside (default: "default").
Resource Name The specific name of the ReplicaSet resource to target for the operation.

Note: For the Exec operation, the node expects a command array (not shown in your provided properties but present in the source) specifying the command to run inside the container.

Output

The output JSON contains the result of the executed command inside the pod's container. Typically, it includes:

  • stdout: The standard output from the executed command.
  • Potentially other execution metadata depending on the underlying client implementation.

No binary data output is indicated for this operation.

Dependencies

  • Requires valid Kubernetes API credentials configured in n8n to authenticate and interact with the cluster.
  • Depends on an internal Kubernetes client utility (K8SClient) to perform API calls and command executions.
  • The node uses the Kubernetes API to locate pods related to the ReplicaSet and execute commands inside them.

Troubleshooting

  • No credentials got returned!
    This error occurs if the node cannot retrieve the required Kubernetes API credentials. Ensure that the credentials are properly set up and linked to the node.

  • Command must be an array!
    The command property must be a JSON array of strings representing the command and its arguments. Providing a string or invalid JSON will cause this error.

  • If the command execution fails silently or returns no output, verify that the targeted pod is running and accessible, and that the command is valid within the container environment.

Links and References

Discussion