Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW FEATURE] Docker swarm support #53

Open
AtomBaf opened this issue Nov 5, 2024 · 6 comments
Open

[NEW FEATURE] Docker swarm support #53

AtomBaf opened this issue Nov 5, 2024 · 6 comments

Comments

@AtomBaf
Copy link

AtomBaf commented Nov 5, 2024

Describe the solution you'd like
Docker swarm support to monitor services and manage them like a container.

Describe alternatives you've considered
As an alternative I'm currently using web-based tools like like swarmpit or portainer.

@mrjackwills
Copy link
Owner

I've not setup/used a Docker Swarm before, would you be able to provide a simple example configuration?

@eliseucbrito
Copy link

Here as a sample configuration.

version: "3.3"

services:
  database_service:
    image: mysql:5.7
    volumes:
      - db_data_volume:/var/lib/mysql
    networks:
      internal_network:
        aliases:
          - database_alias
    ports:
      - "3308:3306"
    deploy:
      placement:
        constraints:
          - node.labels.database == true
      replicas: 1
      restart_policy:
        condition: any
    environment:
      MYSQL_DATABASE: app_database_name
      MYSQL_USER: app_db_user
      MYSQL_PASSWORD_FILE: /run/secrets/db_password_secret
      MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password_secret
    command:
      [
        --character-set-server=utf8,
        --collation-server=utf8_general_ci,
        --sql-mode=STRICT_TRANS_TABLES,
      ]
    secrets:
      - db_password_secret
      - db_root_password_secret

  app_service:
    image: app_image:latest
    volumes:
      - app_documents_volume:/documents
    networks:
      internal_network:
        aliases:
          - app_service_alias
      external_network:
        aliases:
          - app_external_alias
    deploy:
      placement:
        constraints:
          - node.labels.application == true
      replicas: 1
      restart_policy:
        condition: any
    configs:
     - source: app_config_file
       target: /path/to/config.properties
     - source: app_persistence_file
       target: /path/to/persistence.properties

networks:
  internal_network:
  external_network:
    external: true

secrets:
  db_password_secret:
    external: true
  db_root_password_secret:
    external: true

configs:
   app_config_file:
     file: ../config.properties
   app_persistence_file:
     file: ../persistence.properties

volumes:
  db_data_volume:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: /path/to/db_data_directory
  app_documents_volume:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: /path/to/documents_directory

its similiar to compose, but have some features to be used in production.

Here is a script to setup a project locally:

#!/bin/sh

IP_ADDRESS=$(ip -4 addr show scope global | grep inet | awk '{print $2}' | cut -d/ -f1 | head -n 1)

if [ -z "$IP_ADDRESS" ]; then
    echo "Error: Was not possible to obtain the IP address."
    exit 1
fi

echo "Initializing Docker Swarm with IP: $IP_ADDRESS..."
docker swarm init --advertise-addr "$IP_ADDRESS" || echo "Swarm already initialized."


echo "Creating networks..."
docker network create -d overlay database || echo "Network 'database' already exists"
docker network create -d overlay my-network || echo "Network 'my-network' already exists"

echo "Creating secrets..."
echo "passwork" | docker secret create db_password_secret -
echo "rootpass" | docker secret create db_root_password_secret -

echo "Deploying stack..."
docker stack deploy -c compose-dev.yml my-stack

echo "Process completed!"

waiting for this feature!

@mrjackwills
Copy link
Owner

waiting for this feature!

Don't hold your breathe, but I'll have a look into it

@mrjackwills
Copy link
Owner

mrjackwills commented Dec 4, 2024

Docker swarm support to monitor services and manage them like a container.

I have a basic service set up, I've not used Docker swarm before, what features do you think would be essential to implement into oxker in order to manage the swarm? Secondly, what information about the swarm (or each replica?) would be essential to display?

@AtomBaf
Copy link
Author

AtomBaf commented Dec 4, 2024

Taking swarmpit as en example, I would like to see all services, and zooming into one of them would allow me to see its parameters, replicas, status....

@eliseucbrito
Copy link

what features do you think would be essential to implement into oxker in order to manage the swarm

  1. show all stacks running
  2. can enter on a stack and see what services is running
  3. can enter on a service and show logs
  4. same features for containers (start, stop, restart, delete)

It would also be cool to see other docker things like:

  • volumes
  • configs (config files)
  • networks
  • secrets (the names)
  • nodes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants