Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node enables interaction with Kubernetes clusters by performing various operations on Kubernetes resources. Specifically, for the Namespaces resource with the List operation, it retrieves a list of namespaces from the cluster, optionally filtered by field selectors or label selectors.

Common scenarios where this node is beneficial include:

  • Automating cluster management tasks such as monitoring or auditing namespaces.
  • Integrating Kubernetes namespace data into workflows for deployment pipelines or reporting.
  • Filtering namespaces based on specific criteria to trigger conditional logic in automation.

For example, you could use this node to list all namespaces labeled with environment=production to perform targeted maintenance or gather metrics only for production workloads.

Properties

Name Meaning
Namespace The Kubernetes namespace context to operate within. For listing namespaces, this typically can be set but often defaults to "default".
Resource Name Specific name of the resource to filter by. When provided, it overrides the field selector to fetch only the resource with this exact name.
Field Selector A Kubernetes field selector string to filter resources by their fields (e.g., metadata.name=my-namespace). See Kubernetes Field Selectors for syntax and usage.
Label Selector A Kubernetes label selector string to filter resources by labels (e.g., environment=production). See Kubernetes Labels for syntax and usage.

Output

The output is a JSON array representing the list of namespaces retrieved from the Kubernetes cluster. Each item corresponds to a namespace object containing its metadata and status as returned by the Kubernetes API.

Example output structure snippet:

[
  {
    "metadata": {
      "name": "default",
      "labels": { ... },
      "annotations": { ... }
    },
    "status": {
      "phase": "Active"
    }
  },
  {
    "metadata": {
      "name": "kube-system",
      ...
    },
    "status": {
      "phase": "Active"
    }
  }
]

No binary data output is produced by this operation.

Dependencies

  • Requires valid Kubernetes API credentials configured in n8n to authenticate and communicate with the Kubernetes cluster.
  • The node depends on an internal Kubernetes client utility to perform API calls.
  • Network access to the Kubernetes API server must be available from the n8n environment.

Troubleshooting

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

  • Command must be an array!
    Although not relevant for the List operation, this error may appear if other operations like Run are used incorrectly. Make sure commands are provided as JSON arrays.

  • Empty or no results returned
    If filtering with fieldSelector or labelSelector yields no namespaces, verify the correctness of the selectors and that matching namespaces exist.

  • Network or permission errors
    Ensure that the Kubernetes API endpoint is reachable and that the credentials have sufficient permissions to list namespaces.

Links and References

Discussion