diff --git a/Docker-Swarm/portainer-agent-stack.yml b/Docker-Swarm/portainer-agent-stack.yml new file mode 100644 index 0000000..140e76a --- /dev/null +++ b/Docker-Swarm/portainer-agent-stack.yml @@ -0,0 +1,36 @@ +version: '3.2' + +services: + agent: + image: portainer/agent:2.19.4 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /var/lib/docker/volumes:/var/lib/docker/volumes + networks: + - agent_network + deploy: + mode: global + placement: + constraints: [node.platform.os == linux] + + portainer: + image: portainer/portainer-ce:2.19.4 + command: -H tcp://tasks.agent:9001 --tlsskipverify + ports: + - "9443:9443" + - "9000:9000" + - "8000:8000" + volumes: + - /mnt/Portainer:/data + networks: + - agent_network + deploy: + mode: replicated + replicas: 1 + placement: + constraints: [node.role == manager] + +networks: + agent_network: + driver: overlay + attachable: true \ No newline at end of file diff --git a/Docker-Swarm/swarm-3-nodes.sh b/Docker-Swarm/swarm-3-nodes.sh index 9935dd1..68c0dad 100644 --- a/Docker-Swarm/swarm-3-nodes.sh +++ b/Docker-Swarm/swarm-3-nodes.sh @@ -38,9 +38,6 @@ user=ubuntu # Interface used on remotes interface=eth0 -# Set the virtual IP address (VIP) -vip=192.168.3.50 - # Array of all manager nodes allmanagers=($manager1 $manager2 $manager3) @@ -53,12 +50,6 @@ workers=($worker1 $worker2) # Array of all all=($manager1 $worker1 $worker2) -# Array of all minus manager1 -allnomanager1=($manager2 $manager3 $worker1 $worker2) - -#Loadbalancer IP range -lbrange=192.168.3.60-192.168.3.80 - #ssh certificate name variable certName=id_rsa @@ -132,9 +123,7 @@ echo -e " \033[32;5mManager1 Completed\033[0m" managerToken=`cat manager` workerToken=`cat worker` - - -# Step 4: Connect additional worker +# Step 3: Connect additional worker for newnode in "${workers[@]}"; do ssh -tt $user@$newnode -i ~/.ssh/$certName sudo su <> /etc/fstab @@ -169,7 +158,7 @@ EOF done # OPTIONAL # -# Step 7: Add Portainer +# Step 6: Add Portainer ssh -tt $user@$manager1 -i ~/.ssh/$certName sudo su <