Rancher icon

Rancher

Interact with Rancher/Kubernetes API

Overview

The node interacts with the Rancher/Kubernetes API to perform operations on various Kubernetes resources. Specifically, for the Pod resource with the Get Logs operation, it retrieves logs from a specified pod within a Kubernetes cluster. This is useful for monitoring and debugging applications running inside pods by accessing their log output.

Common scenarios include:

  • Fetching recent logs of a pod to diagnose issues.
  • Retrieving previous terminated container logs to understand past failures.
  • Following live log streams for real-time monitoring during deployments or troubleshooting.

Practical example:

  • A user wants to get the last 100 lines of logs from a specific pod's container in a given namespace to check for errors after a deployment.

Properties

Name Meaning
Cluster Name or ID Select the Kubernetes cluster to operate on. Can be chosen from a list or specified via expression.
Project Name or ID (Optional) Select the project within the cluster. Can be chosen from a list or specified via expression.
Namespace Name or ID (Optional) Select the namespace within the project. Can be chosen from a list or specified via expression.
Pod ID The identifier of the pod from which to retrieve logs. Required.
Container (Optional) The name of the container inside the pod. If not specified, the first container is used.
Log Options Collection of options to customize log retrieval:
- Previous Boolean flag to return logs from the previously terminated container.
- Since Seconds Return logs newer than this relative duration (e.g., 5 seconds, 2 minutes).
- Tail Lines Number of lines from the end of the logs to show.
- Follow Boolean flag to follow the log stream continuously (stream logs in real-time).

Output

The node outputs an array of JSON objects where each object contains the logs retrieved from the specified pod. The json field includes the log data as text.

If the "Follow" option is enabled, the node streams the log output continuously until stopped.

No binary data output is indicated for this operation.

Dependencies

  • Requires access to a Rancher or Kubernetes API endpoint.
  • Requires an API authentication token or API key credential configured in n8n to authenticate requests.
  • The node depends on dynamic loading of clusters, projects, and namespaces via internal methods to populate dropdowns.

Troubleshooting

  • Common Issues:

    • Incorrect or missing cluster/project/namespace selection can cause failure to find the pod.
    • Specifying a wrong Pod ID or container name will result in no logs or errors.
    • Network or permission issues with the Kubernetes API may prevent log retrieval.
    • Using the "Follow" option requires stable connectivity; interruptions may stop streaming.
  • Error Messages:

    • Errors indicating "pod not found" usually mean the Pod ID or namespace is incorrect.
    • Authentication errors suggest invalid or missing API credentials.
    • Timeout or connection errors indicate network issues or API server unavailability.
  • Resolutions:

    • Verify all IDs and names are correct and exist in the selected cluster/project/namespace.
    • Ensure the API credentials have sufficient permissions to read pod logs.
    • Check network connectivity to the Kubernetes API endpoint.
    • For streaming logs, ensure the workflow execution environment supports long-running connections.

Links and References

Discussion