PiCluster is a simple way to manage Docker containers on multiple hosts. I created this because I found Docker Swarm not that good and Kubernetes was too difficult to install currently on ARM.
- Run commands in parallel across Nodes
- Heartbeat for services
- Easily build and orchestrate Docker images across nodes
- Command-line interface
- Web interface
- HTTP interface
- Docker
- Node.js
This is the core config file for the web console, agent, and server.
You can run the server and agent on the same node since they are listening on different ports.
{
"token":"1234567890ABCDEFGHJKLMNOP",
"docker":"/root/docker",
"server_port":"3000",
"agent_port": "3001",
"layout": [
{"node":"192.168.0.100", "mysql":"-p 3306:3306 mysql","nginx":"nginx"},
{"node":"192.168.0.102", "openvpn":"-p 1194:1194 openvpn"}],
"hb": [
{"node":"192.168.0.100","mysql":"3306", "nginx": "80"},
{"node":"192.168.0.102","openvpn":"1194"}
],
"web_username": "admin",
"web_password":"admin",
"web_connect":"192.168.0.101",
"web_port":"3003"
}
-
layout - Contains each row contains an IP address of the node to run the container on, the name for the container, and the Docker arguments.
-
heartbeat - lists the node, container name, and the port to monitor. If the port can not be connected to, PiCluster will restart the failed image.
-
token - A string you define a random string that will be used for authentication with the agents.
-
agent_port - Defines the port that the agent will listen on.
-
docker - Defines where your Dockerfile's are. The format for the Docker folder should be like this: dockerfiles/imagename/Dockerfile
-
web_username and web_password - Define's the username and password for the web interface.
-
web_connect - IP address of a node running the server.
-
web_port - Port that the web console listens on.
The following environment variables need to be set:
cd server
npm install
node server.js
The server will send commands to be executed on the agents nodes. The agent should be installed on each host in the cluster.
cd agent
npm install
node agent.js
The web console will send commands to the server.
cd web
npm install
node webconsole.js
Pictl is a bash client to easily control the cluster. It will make all the HTTP requests using curl.
- server - IP address of the server
- port - PORT that the server uses
- token - The token used in the Server and Agent configs.
To get a list of accepted arguments:
pictl
To get a list of all the nodes in PiCluster:
pictl nodes
To build all of the Docker images from your config:
pictl build
To run all of the Docker images from your config:
pictl run
To stop all of the Docker images from your config:
pictl stop
To execute a command on all of the hosts
pictl exec "command"
Display all of the Docker images on each host
pictl images
To view the current log
pictl log
The systemd folder containers the service files and scripts to make PiCluster start at boot time.
For each .service file, change ExecStart and ExecStop to reflect the location of the PiCluster folder.
ExecStart=/bin/bash /root/picluster/systemd/start-agent.sh
ExecStop=/bin/bash /root/picluster/systemd/stop-agent.sh
For each file that begins with "start", modify the following variables for your installation.
export PICLUSTER_AGENT_PATH="/root/picluster/agent"
cp systemd/*.service /lib/systemd/system/
To enable the server service.
systemctl enable picluster-server.service
To enable the agent service.
systemctl enable picluster-agent.service
Reboot