Skip to main content

Docker swarm

Docker

Fuente: https://docs.docker.com/engine/install/ubuntu/

Quitamos dependencias antiguas

 for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done

Actualizamos repositorios

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Instalamos docker

 sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Usuario sin sudo

sudo vi /etc/group
docker:x:989:soffid02
sudo systemctl restart docker

sudo usermod -aG docker soffid02

 

Docker compose

Documentación: https://bookstack.soffid.com/books/installation/page/installing-soffid

sudo vi docker-compose.yaml

mariadb

version: "3.8"
services:
  mariadb:
    image: mariadb:11.1.2
    environment:
      MYSQL_ROOT_PASSWORD: dkF45.r4f
      MYSQL_DATABASE: soffid
      MYSQL_USER: soffid
      MYSQL_PASSWORD: 98nds.D3
    healthcheck:
      test: "/usr/bin/mariadb --user=root --password=dkF45.r4f --execute \"SHOW DATABASES;\""
      interval: 2s
      timeout: 20s
      retries: 10
    command:
      - --max_allowed_packet=128M
      - --innodb_log_file_size=256M
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_general_ci
    networks:
      - cluster
    volumes:
      - mariadb_data:/var/lib/mysql

networks:
  network:
    name: cluster
    driver: bridge

volumes:
  mariadb_data:
    name: compose_mariadbdata
  console_trust:
    name: compose_console_trustedcerts
  console_conf:
    name: compose_console_conf
  console_logs:
    name: compose_console_logs
  console_index:
    name: compose_console_index
  sync_conf:
    name: compose_sync_conf

Ahora necesitamos continuar con docker

Docker swarm

Documentación original: https://bookstack.soffid.com/books/emasa/page/docker-swarm

Ejemplos: https://bookstack.soffid.com/books/postbank/page/configuration-swarm https://bookstack.soffid.com/books/diba/page/diagrama

1. sudo vi /etc/rc.local

#!/bin/bash
ethtool -K ens3 tx-checksum-ip-generic off
exit

2. sudo chmod +x /etc/rc.local

3. sudo reboot

4. Crear el swarm

docker swarm init

En el principal ejectuar: docker swarm join-token manager

En los secundarios, ejectuar el comando ofrecido

5. Reiniciar todos los nodos

6. Crear la red interna: 

docker network create  --driver overlay --attachable cluster

Configuración del servidor NFS:

1. Crear el archivo /etc/exports de la maquina storepam y reiniciar:

/repo1 192.168.6.205(rw,sync,no_subtree_check)
/repo1 192.168.6.206(rw,sync,no_subtree_check)


Configuración del swarm:

Se configura en sispam01. Se encuentra en el archivo /opt/soffid/swarm.yaml y el directorio /opt/soffid/traefik

Tras cambiar la configuración, deben ejecutar /opt/soffid/update-swarm.sh