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 services. Specifically, the Scale operation for the Service resource allows users to adjust the number of replicas of a Docker Swarm service. This is useful in scenarios where you want to increase or decrease the number of running instances of a service to handle varying workloads or optimize resource usage.

Practical examples:

  • Automatically scaling up a web service during peak traffic hours.
  • Scaling down background worker services during off-hours to save resources.
  • Adjusting replicas as part of a CI/CD pipeline after deploying a new version.

Properties

Name Meaning
Environment ID The ID of the Portainer environment/endpoint where the Docker Swarm service is managed.
Service ID The unique identifier of the Docker Swarm service to scale.
Replicas The desired number of replicas (instances) for the service.
Version The current version number of the service object, required for update operations.

Output

The node outputs JSON data representing the response from the Portainer API after attempting to scale the service. This typically includes details about the updated service state, such as its configuration and status.

No binary data output is involved in this operation.

Dependencies

  • Requires an active connection to a Portainer instance via its API.
  • Needs an API key credential configured in n8n to authenticate requests.
  • The Portainer environment/endpoint must be accessible and properly configured.

Troubleshooting

  • Common issues:

    • Incorrect Environment ID or Service ID will cause the API call to fail because the target service cannot be found.
    • Providing an outdated Version number may result in a conflict error since Portainer requires the correct version for updates.
    • Insufficient permissions or invalid API key can lead to authentication errors.
  • Error messages and resolutions:

    • 404 Not Found: Verify that the Environment ID and Service ID are correct and that the service exists.
    • 409 Conflict: Update the Version property to match the latest service version before scaling.
    • 401 Unauthorized: Check the API key credential and ensure it has the necessary permissions.
    • 400 Bad Request: Ensure the Replicas value is a valid positive integer.

Links and References

Discussion