Coder Social home page Coder Social logo

swarm-cluster's Introduction

Swarm Cluster

A set of docker compose files describing how the server applications should run. Clone this project to one of the master node of the cluster and configure according to this documentation.

Create docker swarm

Follow the steps described here: https://docs.docker.com/engine/swarm/swarm-tutorial/create-swarm/

Project structure

The structure is divided into different categories. These are described in the following paragraphs. Each category should contain a README.md-file describing the stacks within the category.

System

This contains system relevant services.

Apps

These are private or publicly obtained apps that add to the value of the cluster.

Mustache

A tentative at making the stack files more dynamic by trying to create the stack file from a mustache template. This also allows to create multiple stacks from the same template.

Jobs

Tasks or jobs can be stored here.

Deploy a stack

There are a few general steps necessary to deploy a stack. In some cases further perquisites are described in the README.md-file of the stack directory.

The following paragraphs describe the general steps to take when starting a stack.

1. Environment files

Folders may contain an example.env file that requires some attention before a stack can be deployed. If such a file is present in the folder, run the following command first:

$ cd folder-of-interest/
$ cp example.env .env

Now the newly created file needs to be edited and configured according to the cluster.

2. Configured HOST paths

The .env-file may contain paths that need to be created before the execution of the stack. These are variables that start with HOST_. To create these folders, run the following commands:

$ cd folder-of-interest/
$ cat .env | grep "^HOST_[A-Z]" | cut -d'=' -f2 | xargs sudo mkdir -p
$ cat .env | grep "^HOST_[A-Z]" | cut -d'=' -f2 | xargs sudo chown -R :docker 

Use the sudo command (after the last pipe) for directories that do not reside in your home directory. Omit sudo otherwise. For NFS configuration: Use nobody:nogroup as owner for the created directories with the chown command.

3. Copy data folder

For a service to run properly, it might be necessary to copy or create a pre-configured data folder to the host path location defined in the .env-file. Find the instructions for this step in the README.md file of the stack.

4. Create docker secrets

In terms of Docker Swarm services, a secret is a blob of data, such as a password, SSH private key, SSL certificate, or another piece of data that should not be transmitted over a network or stored unencrypted in a Dockerfile or in your application’s source code. You can use Docker secrets to centrally manage this data and securely transmit it to only those containers that need access to it.

To create a docker secret simply use the following command.

printf "someSecret" | docker secret create <name_of_secret> -

5. Create networks

It may be necessary to create one or more docker networks to run a stack. If this is the case, you'll find the instruction in the README.md of the stack folder.

6. Finally deploy the stack

Having done all the previous steps correctly, you can now deploy a stack by simply running the following command, if an .env-file is associated with the stack :

$ cd folder-of-interest/
$ env -i $(cat .env | grep "^[A-Z]" | xargs) docker stack deploy -c stack-file.yml stack-name

or omit the env part of the command, if there is no .env-file associated with the stack:

$ cd folder-of-interest/
$ docker stack deploy -c stack-file.yml stack-name

swarm-cluster's People

Contributors

tony-defa avatar

Stargazers

Armen avatar

Watchers

 avatar

Forkers

davidsche

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.