Developer

How to manage a Docker Swarm with Portainer

Jack Wallen reveals you ways simple it’s to manage a Docker Swarm deployment with the Portainer web-based GUI.

Programmer smiling at desk.
Image: SteadinessFormCreative/Adobe Stock

I’ve mentioned this many occasions earlier than, and I’ll say it many occasions sooner or later: Portainer is my go-to container administration platform. With Portainer, I can do any activity required to manage and monitor container deployments. I can use Portainer on an remoted docker improvement machine or a multi-node Swarm Cluster.

Wait. Did I simply say multi-node Swarm Cluster? I did.

If your Docker deployments are of a large-scale nature, chances are high fairly good you’re dealing with a Docker Swarm. For those that don’t know, Swarm mode is constructed into the Docker Engine and permits you to manage a cluster of Docker nodes for extra scalability, decentralized deployments, desired state reconciliations, multi-host networking, load balancing and rolling updates.

In different phrases, in case your container deployments want to meet increased calls for, you’re in all probability utilizing Docker Swarm. And the excellent news is you’ll be able to manage your Swarm proper from Portainer.

SEE: Hiring equipment: Back-end Developer (TechRepublic Premium)

Now, if you happen to haven’t already deployed Portainer, be certain to take a look at How to deploy the Portainer container administration device with persistent storage earlier than persevering with on. You’ll need to be certain to deploy Portainer in your controlling node and ensure to use the Agent possibility when creating a new Docker Environment (Figure A).

Figure A

Creating a new Swarm Environment in Portainer.

Once you’ve created your new Environment, it ought to present up in your Environments itemizing (Figure B).

Figure B

My Docker Swarm Environment is present in Portainer.

How to manage your Docker Swarm from Portainer

With your Docker Swarm Environment up and operating, choose it and it is best to see the Swarm entry within the left sidebar (Figure C).

Figure C

The Swarm entry in Portainer’s left navigation.

Click that entry and also you’ll see two sections: Cluster Status and Nodes (Figure D).

Figure D

My Swarm Cluster overview as seen in Portainer.

Let’s take a have a look at our dockercontroller node. Click that entry to reveal the small print (Figure E).

Figure E

The particulars for my Docker Swarm controller node.

As you’ll be able to see, there isn’t a nice deal of things you’ll be able to management. What you are able to do is ready the supply of the node (from Active, Pause, Drain) and add labels, that are metadata that describes the node.

As to the supply, listed here are the descriptions:

  • Active: A node is energetic and is offered for the scheduler to assign duties.
  • Pause: A node is up however the scheduler can’t assign new duties to this node though current duties will stay operating.
  • Drain: A node is up however the scheduler can’t assign new duties and can shut down all current duties, assigning them to different nodes.

The Availability possibility is a very helpful approach to manage particular person nodes. You would possibly want to substitute a node. Instead of simply stopping it, it is best to drain it so all duties are reassigned. You can then deploy the brand new node and set it as energetic.

Use labels as a helpful technique of organizing your swarm. For instance, say node 1 is a Ubuntu server, and node 2 is an AlmaLinux server. Head over to the primary node (which, for our instance, is hosted on Ubuntu Server) and click on + Label. In the ensuing window, kind os for title and Ubuntu Server for worth (Figure F).

Figure F

Adding our first label to a Swarm node in Portainer.

You can add as many labels as you want.

Resolving a complicated error

When I first began working with Docker Swarm and Portainer, I found a complicated error that took me a while to resolve. When I’d try to make any change to a Swarm Node, I’d obtain the error:

rpc error: code = Unknown desc

Even after restarting each node within the Swarm, I wound up with the identical error. On a whim, I checked the time on every server, solely to uncover that node1 and node2 have been configured for various time zones. Because of that, the Swarm nodes had hassle speaking with each other. To repair that downside, I logged into the nodes and ran the command:

sudo timedatectl set-timezone ZONE

Where ZONE is the right timezone for my space which could be discovered with the command:

cat /and so on/timezone

Once you’ve made positive the time zones are right for every node, that error ought to go away and you’ll label your nodes as wanted and set their Availability.

Of course, you may also scale your deployments inside your Swarm with Portainer. To learn how that is executed, take a look at my tutorial How to scale service deployments with Portainer.

And that’s all there may be to managing your Docker Swarm with Portainer. This platform is a exceptional resolution for anybody trying to make managing Docker container deployments a a lot simpler and extra environment friendly course of.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the newest tech recommendation for enterprise execs from Jack Wallen.

admin

Leave a Reply

Your email address will not be published.Required fields are marked *

*