项目作者: victoraguilarc

项目描述 :
Tools for deploy a cheap Docker Swarm cluster in https://vultr.com servers over CoreOS
高级语言: Python
项目地址: git://github.com/victoraguilarc/suarm.git
创建时间: 2017-07-12T18:47:49Z
项目社区:https://github.com/victoraguilarc/suarm

开源协议:MIT License

下载


suarm

Tools for deploy a cheap Docker Swarm cluster in https://vultr.com servers over CoreOS
With a loadbalancer

Installation

[sudo] pip install git+https://github.com/vicobits/suarm.git

development

  • Install build essential tools with sudo apt install build-essential
  • Prepare environment with make env
  • Configure swarm.json file.
  • Edit files

Usage

Create Cluster

  • Add api-key to swarm.json from value generated in API Section in
    your Vultr account.
  • Generate a ssh-key for your project with the command suarm keys --create.
  • Register your generated ssh-key into swarm.json file with selecting between your registered keys with suarm keys
  • Create a cluster with suarm cluster --create or suarm -f <config_file> cluster --create

Destroy Cluster

  • Destroy cluster with suarm cluster --delete or suarm -f <config_file> cluster --delete

Configuration file

By defaul suarm catch swarm.json file as configuration file in the current location
this file, contains the next values:

  1. {
  2. "api-key": "<MY_VULTR_API_KEY>",
  3. "ssh-key": "<MY_VULTR_GENERATED_SSHKEYID>",
  4. "label": "<NAME_FOR_SWARM>",
  5. "path": "<PATH_FOR_DEPLOYMENTS>",
  6. "domain": "<DOMAIN_FOR_SWARM_MASTER>",
  7. "email": "<YOUR_EMAIL>",
  8. "manager": {
  9. "replicas": 1,
  10. "zone": "NEW_JERSEY",
  11. "plan": 201,
  12. "os": "COREOS",
  13. "nodes": []
  14. },
  15. "worker": {
  16. "replicas": 2,
  17. "zone": "NEW_JERSEY",
  18. "plan": 201,
  19. "os": "COREOS",
  20. "nodes": []
  21. }
  22. }

Where

  • api-key is obtained from the api
  • ssh-key is a SSHKEYID of some your registered ssh keys in the server this is obtained from
  • ssh-key is path string for apps deployed with docker compose.
  • manager is config for manager nodes
  • worker is config for worker nodes
  • label Is a name for cluster e.g. swarm > swarm-manager, swarm-worker00, swarm-worker01, …
  • replicas is the quantity of nodes
  • zone is a availability zone obtained from the api
    supported zones are:
    1. NEW_JERSEY CHICAGO DALLAS SILICON_VALLEY
    2. SEATTLE LOS_ANGELES ATLANTA SYDNEY
    3. AMSTERDAM LONDON FRANKFURT SINGAPORE
    4. PARIS TOKYO MIAMI
  • plan representa resources for server (Mem/CPU/Price), obtained from the api
    List for common plans are:
    ```
    PLAN MEMORY RAM STORAGE BANDWIDTH CPU PRICE

201 1024 MB RAM 25 GB SSD 1.00 TB BW 1CPU 5 USD
202 2048 MB RAM 40 GB SSD 2.00 TB BW 1CPU 10 USD
203 4096 MB RAM 60 GB SSD 3.00 TB BW 2CPUs 20 USD
204 8192 MB RAM 100 GB SSD 4.00 TB BW 4CPUs 40 USD
205 16384 MB RAM 200 GB SSD 5.00 TB BW 6CPUs 80 USD
206 32768 MB RAM 300 GB SSD 6.00 TB BW 8CPUs 160 USD
207 65536 MB RAM 400 GB SSD 10.00 TB BW 16CPUs 320 USD
208 98304 MB RAM 800 GB SSD 15.00 TB BW 24 CPUs 640 USD

  1. * **os** is OS id in Vultr obtained from the [API](https://api.vultr.com/v1/os/list)
  2. List for supported OS are:

CENTOS_6 DEBIAN_7 UBUNTU_14_04 COREOS DEBIAN_8,
UBUNTU_16_04 FEDORA_25 UBUNTU_17_04 DEBIAN_9 FEDORA_26

  1. # Configure cluster
  2. #### Setup swarm
  3. Use the command `suarm cluster --setup` to configure manager and worker nodes.
  4. #### Setup dashboard
  5. Use the command `suarm cluster --setup-dashboard` to install [portainer](https://portainer.io/) and [vizualizer](https://github.com/dockersamples/docker-swarm-visualizer).
  6. #### Setup proxy
  7. Use the command `suarm cluster --setup-proxy` to install proxy flow base on [DockerFlow](http://dockerflow.com).
  8. ## Setup cluster manually
  9. For setup cluster manually check [Manually docs](COMMANDS.md)
  10. ##Execute commands in production
  11. `docker exec -ti [container] python manage.py createsuperuser`
  12. ## Performance improvement
  13. To improve performance between nodes in the cluster there should be in the same private network.
  14. You can configure a private network.
  15. - First enable the private network feature in all nodes
  16. - Create a file `/etc/systemd/network/static.network` with the next configuration:

[Match]
Name=eth1

[Link]
MTUBytes=1450

[Network]
Address=10.99.0.10
Netmask=255.255.0.0
```

  • Restart networking config
    sudo systemctl restart systemd-networkd

TODOS

  • manage domains add domain to the cluster and manage app domains with Cloudflare
  • deploy app app deployment with docker-compose

Extra Config

For proxy config options check dockerflow-proxy
For letsencrypt config options check dockerflow-le

License

This code is licensed under the MIT License_.

.. _MIT License: https://github.com/vicobits/suarm/blob/master/LICENSE