{"id":36525,"date":"2022-06-02T06:58:00","date_gmt":"2022-06-02T06:58:00","guid":{"rendered":"https:\/\/www.techrepublic.com\/?p=3974757"},"modified":"2022-06-02T06:58:00","modified_gmt":"2022-06-02T06:58:00","slug":"how-to-scale-service-deployments-with-portainer","status":"publish","type":"post","link":"https:\/\/cloudnewshub.com\/?p=36525","title":{"rendered":"How to scale service deployments with Portainer"},"content":{"rendered":"<div id>\n<p> 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 a service to all nodes in the Swarm. <\/p>\n<\/div>\n<div id>\n<figure id=\"attachment_3974767\" aria-describedby=\"caption-attachment-3974767\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-article wp-image-3974767\" src=\"http:\/\/cloudnewshub.com\/wp-content\/uploads\/2022\/06\/how-to-scale-service-deployments-with-portainer.jpg\" alt width=\"770\" height=\"489\"><figcaption id=\"caption-attachment-3974767\" class=\"wp-caption-text\">Image: vectorhot\/Adobe Stock<\/figcaption><\/figure>\n<p>One of the many reasons why containers have taken enterprises by storm is their ability to easily scale up and down as needed. This aspect of containers is so crucial that some developers go out of their way to make it such that their deployments can auto-scale to meet demands.<\/p>\n<p>But not every deployment requires that level of flexibility. For those container service deployments that could benefit from manual scaling, there\u2019s always the command line, which isn\u2019t at all challenging (find out how in my piece <a href=\"https:\/\/www.techrepublic.com\/article\/how-to-deploy-service-docker-swarm-cluster\/\" target=\"_blank\" rel=\"nofollow noopener sponsored noreferrer\">How to deploy a service to a Docker Swarm cluster<\/a>).<\/p>\n<p>But for those who prefer a GUI approach to all things containers, there\u2019s my favorite management platform, <a href=\"https:\/\/www.techrepublic.com\/search\/?q=portainer\" target=\"_blank\" rel=\"nofollow noopener sponsored noreferrer\">Portainer<\/a>. Portainer makes it even easier to scale your deployed Docker services up or down, on an as-needed basis. That\u2019s exactly what I want to walk you through here, the scaling (up and down) of your deploy Docker services, by way of Portainer.<\/p>\n<p><strong>SEE: <a href=\"https:\/\/www.techrepublic.com\/resource-library\/whitepapers\/hiring-kit-cloud-engineer\/\" target=\"_blank\" rel=\"nofollow noopener sponsored noreferrer\">Hiring Kit: Cloud Engineer<\/a> (TechRepublic Premium)<\/strong><\/p>\n<h2>What you\u2019ll need<\/h2>\n<p>In order to scale your services in this manner, you\u2019ll need a running instance of Portainer deployed to a Docker Swarm. Let\u2019s outline both the process of deploying both the Swarm and Portainer and then we\u2019ll scale a new service.<\/p>\n<h2>How to deploy Docker Swarm<\/h2>\n<p>I\u2019m going to distill this process down to the essentials. You\u2019ll need at least three machines, and I\u2019ll demonstrate on Ubuntu Server 22.04. On each machine install Docker with:<\/p>\n<p><code>sudo apt-get docker.io -y<\/code><\/p>\n<aside class=\"pinbox right\">\n<h3 class=\"heading\">Must-read developer coverage<\/h3>\n<\/aside>\n<p>Make sure your user has access to the docker group (on each machine) with the command:<\/p>\n<p><code>sudo usermod -aG docker $USER<\/code><\/p>\n<p>Log out and log back in.<\/p>\n<p>On the Docker controller, initialize the Swarm with:<\/p>\n<p><code>docker swarm init --advertise-addr SERVER<\/code><\/p>\n<p>Where <code>SERVER<\/code> is the IP address of the controller.<\/p>\n<p>That will output the command you must run on each of the nodes to connect to the swarm.&nbsp; Just to make sure everything works, and we have a service to work with later, deploy a service with:<\/p>\n<p><code>docker service create -p 8001:80 --name webservice nginx<\/code><\/p>\n<h2>How to deploy Portainer<\/h2>\n<p>We\u2019ll now deploy Portainer. First, create a volume with:<\/p>\n<p><code>docker volume create portainer_data<\/code><\/p>\n<p>You can now deploy Portainer with the command:<\/p>\n<p><code>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 <code>portainer\/portainer-ce<\/code><\/code><\/p>\n<p>After a minute or two, point a web browser to https:\/\/SERVER:9443, where <code>SERVER<\/code> is the IP address of the hosting server. Portainer is now ready to go.<\/p>\n<h2>How to scale a service with Portainer<\/h2>\n<p>Now that we have Docker and Portainer running, it\u2019s time to scale that service to the Swarm. Remember, we only deployed a total of three nodes, so that\u2019s the limit of our scaling.<\/p>\n<p>Within Portainer, click Services in the left sidebar and you should see our test service we created earlier from the command line (<strong>Figure A<\/strong>).<\/p>\n<p><strong>Figure A<\/strong><\/p>\n<figure id=\"attachment_3974758\" aria-describedby=\"caption-attachment-3974758\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-article wp-image-3974758\" src=\"http:\/\/cloudnewshub.com\/wp-content\/uploads\/2022\/06\/how-to-scale-service-deployments-with-portainer-1.jpg\" alt width=\"770\" height=\"164\"><figcaption id=\"caption-attachment-3974758\" class=\"wp-caption-text\">Image: Jack Wallen\/TechRepublic. Our test service (named webservice) is ready to scale.<\/figcaption><\/figure>\n<p>Under the Scheduling Mode column (fourth from the left), you should see a replicated 1\/1 Scale. Between 1\/1 and Scale there are arrows pointing up and down. To scale the service up, click the arrows and then in the resulting field either type <code>3<\/code> or use the up arrow to scale the service to all three nodes (<strong>Figure B<\/strong>).<\/p>\n<p><strong>Figure B<\/strong><\/p>\n<figure id=\"attachment_3974759\" aria-describedby=\"caption-attachment-3974759\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-article wp-image-3974759\" src=\"http:\/\/cloudnewshub.com\/wp-content\/uploads\/2022\/06\/how-to-scale-service-deployments-with-portainer-2.jpg\" alt width=\"770\" height=\"29\"><figcaption id=\"caption-attachment-3974759\" class=\"wp-caption-text\">Image: Jack Wallen\/TechRepublic. Scaling our service to all three nodes of our Docker Swarm<\/figcaption><\/figure>\n<p>The service will take a moment to scale. At first it\u2019ll read 1\/3, but eventually should read 3\/3, which means it has successfully scaled to all three nodes. You might have to refresh the Portainer Services page to see the service has scaled (<strong>Figure C<\/strong>).<\/p>\n<p><strong>Figure C<\/strong><\/p>\n<figure id=\"attachment_3974760\" aria-describedby=\"caption-attachment-3974760\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-article wp-image-3974760\" src=\"http:\/\/cloudnewshub.com\/wp-content\/uploads\/2022\/06\/how-to-scale-service-deployments-with-portainer-3.jpg\" alt width=\"770\" height=\"22\"><figcaption id=\"caption-attachment-3974760\" class=\"wp-caption-text\">Image: Jack Wallen\/TechRepublic. Our service has successfully scaled to all three nodes.<\/figcaption><\/figure>\n<p>And that, my dear friends, is all it takes to scale a service with Portainer. It doesn\u2019t get much easier than that.<\/p>\n<p><em><strong>Subscribe to TechRepublic\u2019s <a href=\"https:\/\/www.youtube.com\/channel\/UCKyMiy1zmJ7aZ8aP6DLZLIA\" target=\"_blank\" rel=\"nofollow noopener sponsored noreferrer\">How To Make Tech Work on YouTube<\/a> for all the latest tech advice for business pros from Jack Wallen.<\/strong><\/em><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 a service to all nodes in the Swarm. Image: vectorhot\/Adobe Stock One of the many reasons why containers have taken enterprises by storm is their ability to easily scale [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":36526,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40,783],"tags":[],"class_list":["post-36525","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud","category-cloudsync"],"_links":{"self":[{"href":"https:\/\/cloudnewshub.com\/index.php?rest_route=\/wp\/v2\/posts\/36525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudnewshub.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudnewshub.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudnewshub.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudnewshub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36525"}],"version-history":[{"count":0,"href":"https:\/\/cloudnewshub.com\/index.php?rest_route=\/wp\/v2\/posts\/36525\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudnewshub.com\/index.php?rest_route=\/wp\/v2\/media\/36526"}],"wp:attachment":[{"href":"https:\/\/cloudnewshub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudnewshub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=36525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudnewshub.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=36525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}