Thank you for reading this post, don't forget to subscribe!
Имеется несколько хостов:
192.168.1.180 swarm_master1_180
192.168.1.181 swarm_master2_181
192.168.1.182 swarm_master3_182
192.168.1.183 swarm_node1_183
192.168.1.184 swarm_node2_184
192.168.1.185 swarm_node3_185
в предыдущей статье:
мы рассмотрели как создать сертификат, и запустить сервис docker-flow-proxy
[codesyntax lang="php" blockstate="collapsed"]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
mkdir -p /certs openssl genrsa -out /certs/test.ru.key 1024 openssl req -new -key /certs/test.ru.key -out /certs/test.ru.csr openssl req -new -key /certs/test.ru.key -out /certs/test.ru.csr здесь указали наш домен Common Name (eg, your name or your server's hostname) []:*.test.ru openssl x509 -req -days 365 -in /certs/test.ru.csr -signkey /certs/test.ru.key -out /certs/test.ru.crt cat /certs/test.ru.crt /certs/test.ru.key | tee /certs/test.ru.pem создали docker secret docker secret create cert-test.ru.pem /certs/test.ru.pem создали сеть: docker network create --driver overlay proxy директорию для хранения файла с нашим сервисом: mkdir docker-flow-proxy [root@swarm_master1_180 ~]# cat docker-flow-proxy/proxy.yml version: "3.7" services: proxy: image: dockerflow/docker-flow-proxy secrets: - cert-test.ru.pem ports: - 80:80 - 443:443 networks: - proxy environment: - LISTENER_ADDRESS=swarm-listener - MODE=swarm deploy: replicas: 3 swarm-listener: image: dockerflow/docker-flow-swarm-listener networks: - proxy volumes: - /var/run/docker.sock:/var/run/docker.sock environment: - DF_NOTIFY_CREATE_SERVICE_URL=http://proxy:8080/v1/docker-flow-proxy/reconfigure - DF_NOTIFY_REMOVE_SERVICE_URL=http://proxy:8080/v1/docker-flow-proxy/remove deploy: placement: constraints: [node.role == manager] networks: proxy: external: true secrets: cert-test.ru.pem: external: true и запустили его: [root@swarm_master1_180 ~]# docker stack deploy -c docker-flow-proxy/proxy.yml proxy |
[/codesyntax]
теперь запустим панель управления swarmpit
создадим директорию:
[root@swarm_master1_180 ~]# mkdir swarmpit-panel
[codesyntax lang="php" blockstate="collapsed"]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
[root@swarm_master1_180 ~]# cat swarmpit-panel/swarmpit.yml 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 networks: - net - proxy deploy: resources: limits: cpus: '0.50' memory: 1024M reservations: cpus: '0.25' memory: 512M placement: constraints: - node.role == manager labels: - com.df.notify=true - com.df.serviceDomain=<strong>swarmpit.test.ru</strong> - com.df.port=8080 - com.df.httpsOnly=true db: image: couchdb:2.3.0 volumes: - db-data:/opt/couchdb/data networks: - net deploy: resources: limits: cpus: '0.30' memory: 256M reservations: cpus: '0.15' memory: 128M influxdb: image: influxdb:1.7 volumes: - influx-data:/var/lib/influxdb networks: - net deploy: resources: limits: cpus: '0.30' memory: 256M reservations: cpus: '0.15' 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: cpus: '0.10' memory: 64M reservations: cpus: '0.05' memory: 32M networks: net: driver: overlay attachable: true <strong>proxy</strong>: external: true volumes: db-data: driver: "<strong>rexray/rbd:latest</strong>" driver_opts: size: 6 influx-data: driver: "<strong>rexray/rbd:latest</strong>" driver_opts: size: 6 |
[/codesyntax]
мы добавили лейбл для того чтобы сервис был доступ по домену swarmpit.test.ru
com.df.serviceDomain=swarmpit.test.ru
и был доступен по https
com.df.httpsOnly=true
также мы указали что volume необходимо создавать по средствам драйвера rexray/rbd:latest в нашем ceph кластере.
запустим сервис:
[root@swarm_master1_180 ~]# docker stack deploy -c swarmpit-panel/swarmpit.yml swarmpit
Creating network swarmpit_net
Creating service swarmpit_agent
Creating service swarmpit_app
Creating service swarmpit_db
Creating service swarmpit_influxdb
проверяем:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
[root@swarm_master1_180 ~]# <strong>docker stack ls</strong> NAME SERVICES ORCHESTRATOR proxy 2 Swarm swarmpit 4 Swarm [root@swarm_master1_180 ~]# <strong>docker service ls</strong> ID NAME MODE REPLICAS IMAGE PORTS 29fl8nvzekwe proxy_proxy replicated 3/3 dockerflow/docker-flow-proxy:latest *:80->80/tcp, *:443->443/tcp oyj07sgnsmbd proxy_swarm-listener replicated 1/1 dockerflow/docker-flow-swarm-listener:latest wep1g9bs5peg swarmpit_agent global 6/6 swarmpit/agent:latest pm1befmu06o3 swarmpit_app replicated 1/1 swarmpit/swarmpit:latest *:888->8080/tcp sbg3nxdcvs2q swarmpit_db replicated 1/1 couchdb:2.3.0 wl5dim50occy swarmpit_influxdb replicated 1/1 influxdb:1.7 [root@swarm_master1_180 ~]# <strong>docker service ps swarmpit_agent</strong> ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS s5kvip2d99ln swarmpit_agent.x9rwrupt72gzu9plo4wqk5cy0 swarmpit/agent:latest swarm_node3_185 Running Running 2 minutes ago lhtofjfg17g0 swarmpit_agent.5ctlcvxjit9iyn7g2vqe1x3ew swarmpit/agent:latest swarm_node2_184 Running Running 2 minutes ago x1j0cj84g0f2 swarmpit_agent.yt6mo8oxq3c95cw8o0fezjerw swarmpit/agent:latest swarm_node1_183 Running Running 2 minutes ago 0ru6gey9asnq swarmpit_agent.ws4gvcxyuvujpxwiyx5k2t7b6 swarmpit/agent:latest swarm_master3_182 Running Running 2 minutes ago 0wyhi7kprukm swarmpit_agent.l6dlgynhjw8b7p30tczz4tysg swarmpit/agent:latest swarm_master1_180 Running Running 2 minutes ago w8c356y3tmhz swarmpit_agent.ejuadkwudusjipvoehn3pma88 swarmpit/agent:latest swarm_master2_181 Running Running 2 minutes ago [root@swarm_master1_180 ~]# <strong>docker service ps swarmpit_app</strong> ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS watzhnwxqxf4 swarmpit_app.1 swarmpit/swarmpit:latest swarm_master2_181 Running Running 3 minutes ago [root@swarm_master1_180 ~]# <strong>docker service ps swarmpit_db</strong> ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS nav6au32s7gk swarmpit_db.1 couchdb:2.3.0 swarm_node1_183 Running Running 2 minutes ago [root@swarm_master1_180 ~]# <strong>docker service ps swarmpit_influxdb</strong> ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ovsy52epr8rf swarmpit_influxdb.1 influxdb:1.7 swarm_node2_184 Running Running about a minute ago [root@swarm_master1_180 ~]# <strong>docker volume ls</strong> DRIVER VOLUME NAME rexray/rbd:latest swarmpit_db-data rexray/rbd:latest swarmpit_influx-data |
переходим по ссылке:
https://swarmpit.test.ru/#/
и видим что панель доступна по https и отображается наш сертификат: