Actions90
- Jobs Actions
- Namespaces Actions
- Pods Actions
- Services Actions
- Deployments Actions
- ReplicaSets Actions
- StatefulSets Actions
- DaemonSets Actions
- CronJobs Actions
Overview
This node enables interaction with Kubernetes resources, specifically supporting operations on Deployments among other resource types. The Exec operation allows executing commands inside a container of a Kubernetes pod within a specified namespace and deployment context.
Common scenarios where this node is beneficial include:
- Running diagnostic or maintenance commands inside a running container.
- Executing scripts or commands dynamically without needing direct kubectl access.
- Automating operational tasks such as restarting pods or patching deployments.
For example, you could use the Exec operation to run a shell command inside a pod of a Deployment to check logs or modify runtime configuration temporarily.
Properties
| Name | Meaning |
|---|---|
| Image | The container image name used when running or restarting pods or patching resources. |
| Namespace | The Kubernetes namespace where the Deployment resource resides. Defaults to "default". |
| Resource Name | The name of the specific Deployment resource to target for the operation. |
Note: Although the node supports multiple operations and resources, here we focus on the Deployments resource with the Exec operation.
Output
The output is a JSON array containing the results of the executed command inside the targeted pod. The key field in the output JSON is:
stdout: A string representing the standard output from the executed command inside the container.
No binary data output is indicated for this operation.
Example output JSON structure:
[
{
"stdout": "command execution output here"
}
]
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 perform API calls and execute commands inside pods.
- The user must have appropriate permissions in the Kubernetes cluster to exec into pods and access the specified namespace and deployment.
Troubleshooting
Error: No credentials got returned!
This indicates missing or misconfigured Kubernetes API credentials. Ensure that the API authentication token or kubeconfig is correctly set up in n8n credentials.Error: Command must be an array!
Thecommandproperty must be provided as a JSON array (e.g.,["ls", "-l"]). Passing a string or invalid JSON will cause this error.Permission Denied or Forbidden Errors
These occur if the Kubernetes service account or user lacks exec permissions on pods. Verify RBAC settings and ensure the user has exec privileges.Resource Not Found
If the specified Deployment or pod does not exist in the given namespace, the operation will fail. Double-check resource names and namespaces.
Links and References
- Kubernetes Exec API: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#exec-v1-core
- Kubernetes Field Selectors: https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/
- Kubernetes Label Selectors: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
- Kubernetes RBAC Authorization: https://kubernetes.io/docs/reference/access-authn-authz/rbac/