Portainer icon

Portainer

Trabalhe com dados da API do Portainer para gerenciar Docker

Overview

This node integrates with the Portainer API to manage Docker Swarm nodes. Specifically, the Update operation for the Node resource allows users to update properties of a Docker Swarm node within a specified environment (endpoint). This is useful for managing node roles, availability, and labels programmatically via n8n workflows.

Typical use cases include:

  • Changing the role of a node (e.g., from worker to manager).
  • Updating node availability status (active, pause, drain).
  • Modifying node metadata labels for orchestration or filtering purposes.

Example: Automatically update node labels based on monitoring data or orchestrate node role changes during maintenance windows.

Properties

Name Meaning
Environment ID The ID of the Portainer environment/endpoint where the Docker Swarm node resides.
Node ID The unique identifier of the Docker Swarm node to be updated.
Version The version number of the node object, required for concurrency control during update.
Role The desired role of the node in the swarm (e.g., manager or worker).
Availability The availability state of the node (e.g., active, pause, drain).
Labels JSON string representing key-value pairs to label the node for identification or filtering.

Note: The last three properties (Role, Availability, Labels) are inferred from the update request body structure in the source code, although not explicitly listed in the provided input properties snippet. They are essential for the update operation.

Output

The node outputs the JSON response returned by the Portainer API after updating the node. This typically includes the updated node details such as its ID, role, availability, labels, and other metadata reflecting the new state.

No binary data output is involved.

Dependencies

  • Requires an API key credential for authenticating with the Portainer API.
  • The base URL of the Portainer instance must be configured in the credentials.
  • The node makes HTTP POST requests to the Portainer API endpoint /endpoints/{environmentId}/docker/nodes/{nodeId}/update with query parameter version and a JSON body containing the update fields.

Troubleshooting

  • Version Mismatch Error: If the version number provided does not match the current node version, the API may reject the update. Ensure you fetch the latest node version before updating.
  • Invalid JSON in Labels: Labels must be valid JSON. Malformed JSON strings will cause errors.
  • Authentication Errors: Verify that the API key credential is correct and has sufficient permissions.
  • Node Not Found: Confirm that the Node ID and Environment ID correspond to existing resources in Portainer.
  • Network Issues: Ensure the Portainer API base URL is reachable from the n8n instance.

Links and References

Discussion