Bboysoul's Blog

首页 公告 RSS

使用swarmpit来监控你的swarm集群

October 10, 2020 本文有 569 个字 需要花费 2 分钟阅读

简介

大家都用过portainer吧,但是个人感觉它的界面挺丑,而且容器的监控数据不能长久的保存,今天推荐一款同样是管理swarm集群的软件 swarmpit

官网

https://swarmpit.io/

从官网就可以看出,真的挺好看的一个dashboard,关键是移动端友好,如果你周围没有电脑,那么使用swarmpit你就可以在手机上轻松管理你的swarm集群了

安装

安装方式有很多,你可以使用官网推荐的一键安装方式

docker run -it --rm \
  --name swarmpit-installer \
  --volume /var/run/docker.sock:/var/run/docker.sock \
swarmpit/install:1.9

当然,因为我集群的缘故,所以我是直接修改yaml的

git clone https://github.com/swarmpit/swarmpit -b master

原来的yaml文件

version: '3.3'

services:
  app:
    image: swarmpit/swarmpit:latest
    environment:
      - SWARMPIT_DB=http://db:5984
      - SWARMPIT_INFLUXDB=http://influxdb:8086
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - 888:8080
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080"]
      interval: 60s
      timeout: 10s
      retries: 3
    networks:
      - net
    deploy:
      resources:
        limits:
          memory: 1024M
        reservations:
          memory: 512M
      placement:
        constraints:
          - node.role == manager
  db:
    image: treehouses/couchdb:2.3.0
    volumes:
      - db-data:/opt/couchdb/data
    networks:
      - net
    deploy:
      resources:
        limits:
          memory: 256M
        reservations:
          memory: 128M

  influxdb:
    image: influxdb:1.7
    volumes:
      - influx-data:/var/lib/influxdb
    networks:
      - net
    deploy:
      resources:
        limits:
          memory: 256M
        reservations:
          memory: 128M

  agent:
    image: swarmpit/agent:latest
    environment:
      - DOCKER_API_VERSION=1.35
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - net
    deploy:
      mode: global
      labels:
        swarmpit.agent: 'true'
      resources:
        limits:
          memory: 64M
        reservations:
          memory: 32M

networks:
  net:
    driver: overlay

volumes:
  db-data:
    driver: local
  influx-data:
    driver: local

说一下上面的相关组件

  • app 就是swarmpit
  • agent 和portainer一样,swarmppit在每个节点上都会部署一个agent收集信息
  • db 使用的是CouchDB用来存储应用的数据
  • influxdb 存储的是集群的信息

因为我是使用traefik做网关的,所以添加了traefik相关的label在app组件中

        - traefik.http.routers.swarmpit-swarmpit-http.rule=Host(``)
        - traefik.http.routers.swarmpit-swarmpit-http.entrypoints=web
        - traefik.http.services.swarmpit-swarmpit.loadbalancer.server.port=8080

同时修改了volume和network

networks:
  app-net:
    external: true

volumes:
  db-data:
    driver_opts:
      type: "nfs"
      o: "addr=10.10.100.244,rw"
      device: ":/nas/docker-volume/swarmpit/db-data"

  influx-data:
    driver_opts:
      type: "nfs"
      o: "addr=10.10.100.244,rw"
      device: ":/nas/docker-volume/swarmpit/influx-data"

最后就是直接部署

docker stack deploy -c swarmpit/docker-compose.yml swarmpit

欢迎关注我的博客www.bboy.app

Have Fun


Tags:

本站总访问量 本站总访客数