项目作者: bcochofel

项目描述 :
Docker Swarm cluster
高级语言:
项目地址: git://github.com/bcochofel/vagrant-docker-swarm-cluster.git
创建时间: 2019-11-16T12:38:45Z
项目社区:https://github.com/bcochofel/vagrant-docker-swarm-cluster

开源协议:MIT License

下载


Provision a Docker Swarm Cluster

Introduction

Provision a Docker Swarm cluster composed of two masters and two workers using Vagrant and Ansible.

Quick Installation

To create all the virtual machines and provision with the default swarm stacks execute:

  1. vagrant plugin install vagrant-hostmanager
  2. vagrant up

On Windows take a look at:

Vagrant hostmanager plugin

If the provision of the swarm stack fails you can execute only the provision part:

  1. vagrant provision

If you want to add more hosts (masters and/or workers) just edit both files:

  • Vagrantfile
  • ansible/inventory

After that just run

  1. vagrant up --provision

After this you can connect to one of the master nodes and check the cluster status

  1. vagrant ssh swarm-master-1
  2. docker node ls

Description

This project has docker-compose files to create swarm stacks. The following stacks are available:

  • Traefik/Consul Stack
  • Web User Interface Stack
  • Automation Stack

Web User Interface Stack

Web User Interface Stack provides the following:

DevOps Tool URL Description
Swarmpit http://swarm-master-1:888 Operate your docker infrastructure like a champ
Portainer http://swarm-master-1:9000 Lightweight Docker Swarm management UI

There are 2 docker-compose files:

  • docker-compose.swarmpit.yml (this is automatically installed)
  • docker-compose.portainer.yml

Installing the stacks with traefik

You can also install all the stack and use traefik.
This stack uses traefik and consul and handles HTTPS certificates automatically (including renewals) with Let’s Encrypt.

To install the traefik stack run the following commands on the swarm manager:

  1. vagrant ssh swarm-master-1
  2. docker stack rm web_ui
  3. docker stack rm automation

Edit the environment variables under ansible/traefik_consul-playbook.yml and execute the playbook

  1. ansible-playbook -i ansible/inventory ansible/deploy-traefik-stack.yml --tags traefik

If you want to use docker-compose outside ansible you need to define some environment variables

  1. vagrant@swarm-master-1:~$ export DOMAIN=intra.local.com
  2. vagrant@swarm-master-1:~$ export USERNAME=admin
  3. vagrant@swarm-master-1:~$ export PASSWORD=admin
  4. vagrant@swarm-master-1:~$ export HASHED_PASSWORD=$(openssl passwd -apr1 $PASSWORD)
  5. vagrant@swarm-master-1:~$ docker stack deploy -c docker-compose.swarmpit.traefik.yml web_ui

Make sure you have the following DNS entries:

DevOps Tool URL
Traefik http://traefik.intra.local.com
Consul http://consul.intra.local.com
Swarmpit http://swarmpit.intra.local.com
Portainer http://portainer.intra.local.com

@TODO