Skip to main content

How to Create Docker Swarm with Multipass & Virtualbox

On this tutorial, we're gonna creating a docker swarm with tool called 'multipass'. You can install this tool (either in Mac or Linux) easly with brew install multipass. Another software required is Virtualbox.
To install multipass in macOS, you can follow my tutorial here:
for this little experiment, you will create a minimal setup of Docker Swarm, as per my understanding one manager and two worker nodes will be sufficient along with one server for NFS shared storage.
$ multipass launch -n manager 
$ multipass launch -n worker1 
$ multipass launch -n worker2 
$ multipass launch -n nfsserver
running above commands with defaults, created required VMs for this POC.
$ multipass list 
Name                    State             IPv4             Image manager                 Running      Ubuntu 20.04 LTS 
nfsserver               Running      Ubuntu 20.04 LTS 
worker1                 Running      Ubuntu 20.04 LTS 
worker2                 Running      Ubuntu 20.04 LTS  
Install Docker CE in manager and worker nodes is pretty straight forward, run below scripts as root user
$ apt-get update && apt-get upgrade -y 
$ apt-get remove docker docker-engine -y 
$ apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common python-setuptools -y 
$ curl -fsSL | sudo apt-key add - 
$ add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable" $ apt-get update 
$ apt-get install docker-ce -y 
$ systemctl enable docker 
$ systemctl restart docker 
$ apt install python3-pip -y 
$ pip install docker-compose 
$ usermod -aG docker ubuntu
Login to manager, worker1 and worker2 shell and verify if docker is properly installed, by executing below command from each VM.
docker --version Docker version 20.10.8, build 3967b7d

Initialize docker manager instance
$ docker swarm init --advertise-addr
run join command from each worker VM
$ docker swarm join --token
check if the setup is working as expected
$ docker node ls 
jklhgjfturtaiuskghmv *   manager    Ready     Active         Leader           20.10.8 
jkhgutyikjhgmnjghmvn     worker1    Ready     Active                          20.10.8 
cfgrtdyfhgvncfghggvh     worker2    Ready     Active                          20.10.8
try installing an nginx web server in this cluster and verify if container deployment is working as expected
$ docker service create --name my-web --publish 8080:80 --replicas 2 nginx 
$ docker service ls ID             NAME      MODE         REPLICAS   IMAGE          PORTS s9eabxqjgu98   my-web    replicated   2/2        nginx:latest   *:8080->80/tcp
above command deploys nginx webserver with 2 replicas, check where these 2 containers are deployed to
ubuntu@manager:~$ docker service ps my-web ID             NAME       IMAGE          NODE      DESIRED STATE   CURRENT STATE            ERROR     PORTS 
jghasgghjda   my-web.1   nginx:latest   worker2   Running         Running 48 seconds ago 
fdreytfghca   my-web.2   nginx:latest   manager   Running         Running 56 seconds ago
enjoy it!


Popular posts from this blog

Cara Disable Antimalware Service Executable di Windows 10

Disadari atau tidak, Windows 10 (dan juga windows-windows lainnya) hadir dengan banyak sekali aplikasi bloatware (aplikasi yang tidak perlu-perlu amat dimiliki oleh end user). Contohnya, adalah aplikasi yang seharusnya sudah tergantikan fungsinya oleh antivirus, seperti Antimalware Service Executable . Aplikasi ini dicurigai membuat Windows 10 mengalami inefisiensi memori/RAM, memakan resource yang tinggi, dengan Load yang tinggi (tanpa limit terkadang). Nah, berikut adalah cara men-disable nya: Tekan tombol Windows + I untuk membuka apliaksi Windows Setting. Pilih icon menu Update and Security Pilih lagi menu disamping kiri Windows Security Pada jendela baru yang muncul, ada pilihan Virus & Threat protection Klik ini Lalu matikan proses Real-time protection tersebut. Dengan Regedit. Buka dialog regedit, Windows + R dan ketik ‘regedit’ Cari Folder regedit ini HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender Buat sebuah DWORD baru dengan klik kanan

Setup Debian 11 Official Repository In sources.list (/etc/apt/sources.list)

When you install Debian 11 using a DVD, the OS installer sets the DVD as the source for getting packages for your system if you didn't choose to scan for network mirrors. Due to this reason, the system would ask you to insert a DVD if the disc is not present in the DVD drive when you try to install any software.  Also, the packages on DVD may not be the latest release.  So, we need to get the packages from the Internet. Media change: please insert the disc labeled 'Debian GNU/Linux 11.0.0 _Bullseye_ - Official amd64 DVD Binary-1 20210814-10:04' in the drive '/media/cdrom/' and press [Enter] The /etc/apt/sources.list file with DVD as a source would look something like below. # deb cdrom:[Debian GNU/Linux 11.0.0 _Bullseye_ - Official amd64 DVD Binary-1 20210814-10:04]/ bullseye contrib main deb cdrom:[Debian GNU/Linux 11.0.0 _Bullseye_ - Official amd64 DVD Binary-1 20210814-10:04]/ bullseye contrib main deb bullseye-security

Cara Membuat Live USB VMWare ESXi 6.7 di Linux (Debian/CentOS)

VMWare ESXi 6.7 menyediakan satu installer dalam format CDROM ISO. Dalam tutorial kali ini kita akan membuat sebuah live USB dengan menggunakan sistem Linux, misalnya Debian dan CentOS. Untuk keperluan tutorial kali ini silakan pastikan sudah ada download installer ISO ESXi 6.7 dari Siapkan satu USB Flashdisk dengan kapasitas lebih dari 1GB. Format dalam satu partisi dengan tool yang biasa dipakai dalam format partisi FAT32. Misal dengan FDISK: [sourcecode] fdisk /dev/sdX [/sourcecode] format ke FAT32: [sourcecode]mkfs.fvat -F 32 -n USB /dev/sdX1[/sourcecode] selanjutnya, kita buat USB tersebut bootable dengan syslinux. Bagi linuxnya belum ada syslinux, silakan install dulu (apt-get install syslinux atau yum install syslinux).