Tech

How to Scale Service Deployment with Portainer


Scaling Docker services is actually very simple with Portainer. Jack Wallen shows you how to quickly deploy both Docker Swarm and Portainer, and then quickly scale the service to all nodes in Swarm.

Image: vectorhot / Adobe Stock

One of the many reasons why containers cause storms for businesses is their ability to easily scale up and down as needed. This aspect of the container is so important that some developers have tried to make it their deployment that can automatically scale to meet demand.

But not every implementation requires that level of flexibility. For those container service implementations that can benefit from manual scaling, there’s always the command line, which shouldn’t be difficult at all (learn how in my article). How to deploy a service to a Docker Swarm . cluster).

But for those who prefer a GUI approach to everything, there is my favorite management platform, Porters. Portainer makes it easy to scale your deployed Docker services up or down, on an as-needed basis. That’s exactly what I wanted to guide you here, scaling (up and down) of your deployed Docker services, through Portainer.

UNDERSTAND: Recruitment Toolkit: Cloud Engineer (TechRepublic Premium)

What you need

To scale your service in this way, you will need a running Portainer instance deployed to Docker Swarm. Let’s outline both Swarm and Portainer deployment and then we’ll scale a new service.

How to Deploy Docker Swarm

I will distill this process down to the essentials. You will need at least three machines and I will cover on Ubuntu Server 22.04. On each machine install Docker with:

sudo apt-get docker.io -y

Make sure your user has access to the docker group (per machine) with the command:

sudo usermod -aG docker $USER

Log out and log back in.

On the Docker controller, initialize Swarm with:

docker swarm init --advertise-addr SERVER

Where SERVER is the IP address of the controller.

That will output the command you have to run on each node to connect to the swarm. Just to make sure everything works and we have a service to work with later, let’s implement one with:

docker service create -p 8001:80 --name webservice nginx

How to deploy Portainer

Now we will deploy Portainer. First, create a volume with:

docker volume create portainer_data

Now you can deploy Portainer with the command:

docker run -d -p 8000:8000 -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

After a minute or two, point your web browser to https://SERVER:9443, here SERVER is the IP address of the host server. Portainer is now ready to go.

How to scale services with Portainer

Now that we have Docker and Portainer running, it’s time to extend that service to Swarm. Remember, we’ve only deployed three nodes in total, so that’s our scaling limit.

In Portainer, click Services in the left sidebar and you’ll see our test service we created earlier from the command line (Picture A).

Picture A

Image: Jack Wallen / TechRepublic. Our test service (named webservice) is ready to scale.

In the Scheduling Mode column (fourth from the left) you will see the scaled 1/1 Scale. Between 1/1 and Scale there are arrows pointing up and down. To expand the service, click the arrow, then in the resulting field type 3 or use the up arrow to extend the service to all three nodes (Figure BUT).

Figure BUT

Image: Jack Wallen / TechRepublic. Extend our service to all three of our Docker Swarm nodes

The service will take some time to scale. At first it will read 1/3, but eventually will read 3/3, which means it has successfully expanded to all three nodes. You may have to refresh the Carrier Services page to see the expanded service (SIZE).

SIZE

Image: Jack Wallen / TechRepublic. Our service has successfully extended to all three nodes.

And that, my dear friends, is all it takes to extend a service with Portainer. It doesn’t get any easier than that.

Subscribe to TechRepublic’s How to make technology work on YouTube for all the latest tech advice for business professionals from Jack Wallen.



Source link

news7g

News7g: Update the world's latest breaking news online of the day, breaking news, politics, society today, international mainstream news .Updated news 24/7: Entertainment, Sports...at the World everyday world. Hot news, images, video clips that are updated quickly and reliably

Related Articles

Back to top button