Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node enables interaction with Kubernetes clusters by performing various operations on Kubernetes resources. Specifically for the Jobs resource and the Exec operation, it allows executing commands inside a running Job's pod container. This is useful for debugging, inspecting runtime state, or triggering specific actions within the Job environment.

Common scenarios include:

  • Running diagnostic commands inside a Job's pod to troubleshoot issues.
  • Executing maintenance or update scripts dynamically without redeploying the Job.
  • Inspecting logs or environment details interactively.

Example: You have a batch processing Job running in Kubernetes and want to execute a shell command inside its pod to check temporary files or process status.

Properties

Name Meaning
Image The container image name related to the Job (used in some operations like run, exec).
Namespace Kubernetes namespace where the Job resource resides; defaults to "default".
Resource Name The specific Job resource name to target for the exec operation.

Note: The Command property (not listed here but present in the source) is required for the exec operation and must be a JSON array representing the command and its arguments to run inside the pod.

Output

The output is a JSON array containing the result of the executed command inside the Job's pod. The structure includes:

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

If the command produces binary data, it would typically be included in the stdout field encoded as a string, but this node primarily returns textual command output.

Dependencies

  • Requires valid Kubernetes API credentials configured in n8n to authenticate and communicate with the cluster.
  • The node depends on an internal Kubernetes client utility (K8SClient) to perform API calls.
  • The user must provide appropriate permissions to execute commands inside pods.

Troubleshooting

  • No credentials got returned!
    This error indicates missing or misconfigured Kubernetes API credentials. Ensure that the API key or token credential is properly set up in n8n.

  • Command must be an array!
    The command input must be a JSON array (e.g., ["ls", "-l"]). Providing a string or other type will cause this error.

  • Pod not found or inaccessible
    If the specified Job's pod does not exist or is not running, the exec operation will fail. Verify the Job name, namespace, and pod status.

  • Permission denied errors
    The Kubernetes service account or API token used may lack exec permissions. Check RBAC settings in your cluster.

Links and References

Discussion