Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node enables interaction with Kubernetes clusters by performing various operations on Kubernetes resources. Specifically, the Get operation retrieves details of a specified resource or a filtered list of resources within a namespace.

Common scenarios where this node is beneficial include:

  • Fetching the current state or configuration of Kubernetes objects such as pods, services, deployments, etc.
  • Monitoring specific resources by retrieving their metadata and status.
  • Filtering resources based on labels or fields to narrow down results for automation workflows.

For example, you can use the Get operation to retrieve information about a particular pod in the "default" namespace or list all deployments that match certain label selectors.

Properties

Name Meaning
Namespace The Kubernetes namespace where the resource resides. Defaults to "default".
Resource Name The name of the specific resource to retrieve. If provided, it overrides the field selector to target this exact resource by name.
Field Selector A Kubernetes field selector string to filter resources based on object fields (e.g., metadata.name=my-pod). See Kubernetes Field Selectors.
Label Selector A Kubernetes label selector string to filter resources based on labels (e.g., app=nginx). See Kubernetes Labels.

Output

The output JSON contains the data returned from the Kubernetes API for the requested resource(s). This typically includes metadata, specifications, and status information of the resource(s) fetched.

  • When a specific resource name is provided, the output corresponds to that single resource's detailed JSON representation.
  • When listing resources with selectors, the output is an array of matching resource objects.
  • No binary data is produced by this operation.

Example output snippet (simplified):

[
  {
    "metadata": {
      "name": "example-pod",
      "namespace": "default",
      "labels": { "app": "my-app" }
    },
    "status": {
      "phase": "Running"
    },
    "spec": {
      ...
    }
  }
]

Dependencies

  • Requires valid Kubernetes API credentials configured in n8n to authenticate and communicate with the cluster.
  • Relies on the internal Kubernetes client utility (K8SClient) to perform API calls.
  • No additional external dependencies beyond Kubernetes API access.

Troubleshooting

  • No credentials got returned!
    This error indicates missing or misconfigured Kubernetes API credentials. Ensure that the node has proper authentication set up with the necessary permissions.

  • Invalid field selector or label selector syntax
    If filtering returns no results or errors, verify that the selectors conform to Kubernetes syntax rules.

  • Resource not found
    Providing a non-existent resource name or incorrect namespace will result in empty or error responses. Double-check resource names and namespaces.

  • Command must be an array!
    Although not relevant for the Get operation, this error appears if the command input is malformed when running pods.

Links and References

Discussion