Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node allows interaction with Kubernetes resources, specifically focusing on the "Services" resource when the "Exec" operation is selected. The "Exec" operation enables executing commands inside a container of a Kubernetes pod and retrieving the output. This is useful for running diagnostic commands, debugging, or performing administrative tasks directly within the container environment.

Practical scenarios include:

  • Running shell commands inside a service's pod to inspect runtime state.
  • Executing scripts or commands to gather logs or metrics without exposing them externally.
  • Automating maintenance tasks by running commands inside containers as part of workflows.

Properties

Name Meaning
Image The container image name used when running or restarting pods or executing commands.
Namespace The Kubernetes namespace where the target service resides. Defaults to "default".
Resource Name The specific name of the Kubernetes service resource to target for the operation.

Note: For the "Exec" operation, the node expects a command (as a JSON array) to be executed inside the container, but this property was not included in your provided list. It is required to specify the command to run.

Output

The node outputs JSON data representing the result of the executed command inside the Kubernetes pod. The output typically includes:

  • stdout: The standard output text returned from the command execution inside the container.

If the node supports binary data output (e.g., logs or files), it would be summarized here, but for the "Exec" operation on Services, the output is textual command output only.

Dependencies

  • Requires valid Kubernetes API credentials configured in n8n to authenticate and interact with the cluster.
  • The node depends on an internal Kubernetes client utility to communicate with the Kubernetes API.
  • The user must have appropriate permissions to execute commands inside pods of the targeted service.

Troubleshooting

  • No credentials got returned!
    This error indicates missing or misconfigured Kubernetes API credentials. Ensure that the node has access to valid credentials with sufficient permissions.

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

  • Resource or Pod not found
    If the specified service or associated pods do not exist in the given namespace, the operation will fail. Verify the resource name and namespace.

  • Permission denied or forbidden errors
    These indicate insufficient RBAC permissions in Kubernetes. Check the user's role bindings and permissions.

Links and References

Discussion