npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

docker-hive

v2.3.0

Published

Preconfigured docker swarm. Portainer GUI. Built-in monitoring stack with prometheus and grafana.

Downloads

71

Readme

Docker hive

Docker hive is a cli app on top of docker swarm. It doesn't do much, just sets up your docker swarm easily. The main purpose of docker hive is to install the monitoring stack, recommended for docker swarm infrastructure. Once installed, it will expose all services required for the swarm management like prometheus, grafana, portainer, etc.

The nodejs based cli app is just to make our life easier, installing the full pack and updating it.

This is not a fun project, it's meant for production use.

Features

  • Full monitoring stack.
  • Expose all hive management ports only on over a VPN.
  • Sync iptables rules over the whole swarm without logging in on all nodes (encrypted).
  • Not having to remember lots of commands and settings, everything comes out of the box.

Swarm management and monitoring

  • Also uses dockerd exporter with experimental mode.

Usage

Basically, you install the package on all nodes.

On the master run: hive init

On the workers and secondary managers run: hive join

Run hive iptables to check the iptables rules you need to accept connections to the current node.

Run hive nodes to check if the list of nodes gets regularly updated.

Run hive config to edit the config file with nano. You need to restart the hive stack after that with hive restart.

A service will be installed after you init or join a swarm, it will update the nodes ip list when the master adds or removes a node. This can be connected with an iptables callback that updates your iptables rules.

It's recommended to expose the hive management ports over a VPN

  1. Prepare your openvpn client config for the server without a password.
  2. Then after init/join, add the config to /etc/docker-hive/vpn and run hive restart.
  3. Repeat the steps if you have more than one vpn to expose the ports to.
  • If you don't have a VPN, you can publish the ports with the config or during init. This is NOT secure, so you should manually add iptables rules to allow those ports only for administrators.

It's preferred if you don't publish the ports, but only publish them to the internal network with VPN. No matter if they are published, or not, you can assess the services on these ports:

  • http://SERVER_PUBLIC_OR_VPN_ADDRESS:3000 => Portainer
  • http://SERVER_PUBLIC_OR_VPN_ADDRESS:3001 => Grafana
  • http://SERVER_PUBLIC_OR_VPN_ADDRESS:3002 => Unsee
  • http://SERVER_PUBLIC_OR_VPN_ADDRESS:3003 => Prometheus
  • http://SERVER_PUBLIC_OR_VPN_ADDRESS:3004 => Alertmanager
Usage: hive <cmd> <args ...>

Commands:
  hive init [-h <host>] [-i <interface>]              Create a new docker swarm.
  hive join [-t <type>] [-h <host>] [-i <interface>]  Join a docker swarm, managed by hive.
  hive leave                                          Leave the current swarm.
  hive reset                                          Reset the hive stack volumes.
  hive config                                         Edit the config with nano.
  hive start                                          Start the hive stack.
  hive stop                                           Stop the hive stack.
  hive restart                                        Restart the hive stack.
  hive node-add [ip]                                  Allow node to connect.
  hive node-rm [ip]                                   Remove node from the allowed list.
  hive nodes                                          List the allowed nodes.
  hive serve                                          Serve config to the worker/manager nodes.
  hive sync                                           Sync config with the master node.
  hive iptables [-s <file>]                           Print all iptables accept rules.
  hive install-dependencies                           Install dependencies (Ubuntu/Debian).

Options:
  --version  Show version number  [boolean]
  --help     Show help  [boolean]

Wondering how all this works?

This app is an "automation". It doesn't do magic and the code is not long or hard to read. Check it out.

Install node

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -; sudo apt-get install -y nodejs

Install docker-hive

npm install -g docker-hive
hive --help # If the hive command is busy, use docker-hive

For Ubuntu/Debian distributions:

hive install-dependencies

For other distributions you will need to install:

curl
docker-ce/ee

Known issues

  • You have to have open firewall when setting up workers.

To do

  • Video tutorial
  • Autocomplete commands when double tab is pressed

Links

Inspired by: https://github.com/stefanprodan/swarmprom

Helpful commands

Delete all containers (force!! running or stopped containers)

docker rm -f $(docker ps -qa)

Delete old containers

docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs docker rm

Delete stopped containers

docker rm -v $(docker ps -a -q -f status=exited)

Delete containers after stopping

docker stop $(docker ps -aq) && docker rm -v $(docker ps -aq)

Delete dangling images

docker rmi $(docker images -q -f dangling=true)

Delete all images

docker rmi $(docker images -q)

Delete dangling volumes

docker volume rm $(docker volume ls -q -f dangling=true)

Delete all networks

docker network rm $(docker network ls)