Compare commits

..

17 Commits

Author SHA1 Message Date
verita84
b2ffc745f9 Update 'README.md' 2022-11-13 22:48:27 +00:00
Your Name
be3a18c485 fix 2022-08-15 23:01:36 -06:00
Your Name
22bb930afb fix 2022-08-15 15:02:22 -06:00
verita84
676a1281f7 Update 'agent/agent.js'
fix
2022-08-15 20:40:14 +00:00
verita84
68d24b87d6 Merge pull request 'fix' (#5) from dev into master
Reviewed-on: https://git.pooper.social/verita84/picluster/pulls/5
2022-08-15 16:22:33 +00:00
Your Name
92df40993a fix 2022-08-15 10:22:06 -06:00
verita84
8bc487b521 Merge pull request 'systemd fix' (#4) from dev into master
Reviewed-on: https://git.pooper.social/verita84/picluster/pulls/4
2022-08-15 16:20:27 +00:00
Your Name
d27c305221 fix 2022-08-15 10:19:52 -06:00
verita84
bcfec7f9c7 Merge pull request 'SystemD Fix' (#3) from dev into master
Reviewed-on: https://git.pooper.social/verita84/picluster/pulls/3
2022-08-15 16:17:56 +00:00
Your Name
c0bf401399 fix 2022-08-15 10:17:24 -06:00
verita84
c94054f61d Merge pull request 'API FIX' (#2) from dev into master
Reviewed-on: https://git.pooper.social/verita84/picluster/pulls/2
2022-08-15 16:17:08 +00:00
Your Name
0e24146511 API FIX 2022-08-15 10:02:32 -06:00
verita84
8407ebe1d9 Merge pull request 'SystemD Support and security updates' (#1) from dev into master
Reviewed-on: https://git.pooper.social/verita84/picluster/pulls/1
2022-08-15 15:52:28 +00:00
Your Name
52c1822a8d Security updates 2022-08-15 09:48:56 -06:00
Your Name
acdb0cd8ad SystemD Support 2022-08-15 09:42:56 -06:00
Your Name
f737084eb7 fix 2022-08-14 23:50:12 -06:00
verita84
0a1472e6e8 Update 'README.md' 2022-07-20 17:37:02 +00:00
13 changed files with 13590 additions and 4718 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

View File

@ -1,13 +1,13 @@
# PiCluster
![Pic](https://git.rage.lol/verita84/picluster/raw/branch/master/images/piclusterLogo.png)
![Pic](https://git.poster.place/verita84/picluster/raw/branch/master/images/piclusterLogo.png)
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. PiCluster will only build and run images from Dockerfile's on the host specified in the config file. This software will work on regular x86 hardware also and is not tied to ARM.
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)
![Pic](https://git.rage.lol/verita84/picluster/raw/branch/master/images/picluster-mainscreen.png)
![Pic](https://git.poster.place/verita84/picluster/raw/branch/master/images/picluster-mainscreen.png)
## Features
@ -63,7 +63,7 @@ git clone -b dev https://git.rage.lol/verita84/picluster.git picluster
```
## Config file reference
[See Wiki](https://git.rage.lol/verita84/picluster/wiki/Config-Reference)
[See Wiki](https://git.poster.place/verita84/picluster/wiki/Config-Reference)
## Try PiCluster in Docker
@ -77,38 +77,38 @@ docker-compose up -d
Finally, in your web browser go to <http://127.0.0.1:3003>
## Installation
[See Wiki](https://git.rage.lol/verita84/picluster/wiki/Installation)
[See Wiki](https://git.poster.place/verita84/picluster/wiki/Installation)
## Container Load Balancer
[See Wiki](https://git.rage.lol/verita84/picluster/wiki/Container-Load-Balancer)
## Upgrading
[See Wiki](https://git.rage.lol/verita84/picluster/wiki/Upgrading)
[See Wiki](https://git.poster.place/verita84/picluster/wiki/Upgrading)
## Functions-as-a-Service (FAAS)
[See Wiki](https://git.rage.lol/verita84/picluster/wiki/Serverless-%28FaaS%29)
[See Wiki](https://git.poster.place/verita84/picluster/wiki/Serverless-%28FaaS%29)
<br>
## Configuring and using the command-line client "pictl"
[See Wiki](https://github.com/picluster/picluster/wiki/Pictl)
[See Wiki](https://git.poster.place/verita84/picluster/picluster/wiki/Pictl)
## SSL/TLS
[See Wiki](https://git.rage.lol/verita84/picluster/wiki/SSL-Configuration)
[See Wiki](https://git.poster.place/verita84/picluster/wiki/SSL-Configuration)
## Using pm2 to init PiCluster on systemd
[See Wiki](https://git.rage.lol/verita84/picluster/wiki/PM2)
[See Wiki](https://git.poster.place/verita84/picluster/wiki/PM2)
## Automatic Container failover to other hosts
[See Wiki](https://git.rage.lol/verita84/picluster/wiki/Automatic-Container-failover-to-other-hosts)
[See Wiki](https://git.poster.place/verita84/picluster/wiki/Automatic-Container-failover-to-other-hosts)
# Authors and Contributions
* Project created by [Verita84](https://rage.lol/verita84).
* Project created by [Verita84](https://git.poster.place/verita84).
* [TokinRing](https://github.com/TokinRing), core developer.

View File

@ -1,8 +1,9 @@
# Version 3.0.11
# Version 3.0.12
## New Features:
* Manage Containers: Has a new option called "Commit Image" that allows you to update a Docker image with the current running image.
* Operations: Has a new option called "Edit Hosts" which will let you modify /etc/hosts on the server and then it will be copied to each node.
* SystemD unit file generation for containers to start on Boot (Podman Only).
## Enhancements:
* Added PiCluster version to /nodes API
@ -12,7 +13,7 @@
* ElasticSearch: Support for SSL/TLS
## Removed or Deprecated:
* None
* Auto-starting of containers at boot has been replaced with SystemD Unit files.
## Bug Fixes:
* Docker Swarm fix for adding nodes to existing cluster

View File

@ -355,6 +355,7 @@ app.post('/run', (req, res) => {
node
};
const check_token = req.body.token;
if (check_token !== token) {
@ -368,16 +369,90 @@ app.post('/run', (req, res) => {
output.output = stderr;
} else {
output.output = stdout;
if (config.autostart_containers) {
if (req.body.command.indexOf('docker container run') > -1) {
systemd(req.body.command);
} else if (req.body.command.indexOf('docker container rm') > -1) {
systemd_remove(req.body.command);
}
}
}
res.json(output);
res.json(output);
}, err => {
if (err) {
console.error('error:', err);
}
// Console.log('output', output);
Console.log('output', output);
});
});
function systemd(data) {
const systemd = ["[Unit]", "Description=Container", "After=podman.service", "[Service]", "Type=oneshot", "RemainAfterExit=yes", "Environment=\"NAME=", "ExecStartPre=/bin/sh -c \"/usr/bin/podman rm -f ${NAME}; exit 0;\"", "ExecStartPre=/bin/sh -c \"/usr/bin/podman build -t ${NAME} " + config.docker + "/${NAME}; exit 0;\"", "podman run", "ExecStart=/bin/sh -c \"systemctl restart firewalld.service; exit 0;\"", "ExecStart=/bin/sh -c \"podman network reload -a; exit 0;\"", "ExecStop=/usr/bin/podman rm -f ${NAME}", "[Install]", "WantedBy=multi-user.target"];
var container_name = data.split(' ');
var name = container_name[container_name.length - 1];
for (const unit_file of systemd) {
if (unit_file.indexOf('Unit') > -1) {
console.log(unit_file);
fs.writeFile('/etc/systemd/system/picluster-' + name + '.service', unit_file + '\n', err => {
if (err) {
console.log(err);
}
});
} else if (unit_file.indexOf('NAME=') > -1) {
let analyze_unit_file = 'Environment=\"NAME=' + name + '"';
fs.appendFile('/etc/systemd/system/picluster-' + name + '.service', analyze_unit_file + '\n', err => {
if (err) {
console.log(err);
}
});
} else if (unit_file.indexOf('podman run') > -1) {
end_line = 'ExecStart=/bin/sh -c \"' + data + ';exit 0;\"';
fs.appendFile('/etc/systemd/system/picluster-' + name + '.service', end_line + '\n', err => {
if (err) {
console.log(err);
}
});
} else {
fs.appendFile('/etc/systemd/system/picluster-' + name + '.service', unit_file + '\n', err => {
if (err) {
console.log(err);
}
});
console.log(unit_file);
}
}
exec('systemctl enable picluster-' + name + '.service', (error, stdout, stderr) => {
if (error) {
console.log(error);
}
if (stdout) {
console.log(stdout);
}
});
}
function systemd_remove(data) {
var container_name = data.split(' ');
var name = container_name[container_name.length - 1];
exec('systemctl disable picluster-' + name + '.service', (error, stdout, stderr) => {
if (error) {
console.log(error);
} else {
console.log('\nRemoving picluster-' + name + '.service');
fs.unlink('/etc/systemd/system/picluster-' + name + '.service', error => {
if (error) {
console.log(error);
}
});
}
});
}
if (config.ssl && config.ssl_cert && config.ssl_key) {
console.log('SSL Agent API enabled');
const ssl_options = {
@ -441,21 +516,6 @@ bootstrapNode();
function additional_services() {
monitoring();
if (config.autostart_containers) {
console.log('Starting all the containers.....');
superagent
.get(`${scheme}${server}:${server_port}/start`)
.query({
token: token,
container: '*'
})
.end((err, res) => {
if (err) {
console.log(error);
}
});
}
if (config.vip_ip && config.vip) {
vip = config.vip_ip;
@ -492,4 +552,4 @@ function additional_services() {
});
});
}
}
}

1188
agent/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"unsafe-perm": true
},
"dependencies": {
"async": "latest",
"async": "^3.2.4",
"body-parser": "latest",
"child-process-promise": "",
"cpu-stats": "latest",

12833
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,7 @@
}
},
"devDependencies": {
"xo": "^0.32.1"
"xo": "^0.51.0"
},
"dependencies": {
"eslint": "^7.24.0",

3059
server/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@ const {
const {
exec
} = require('child_process');
const version = "3.0.11"
const version = "3.0.12"
const bootstrap = {
status: 1

1090
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
"express": "^4.17.1",
"font-logos": "",
"jquery": "^3.6.0",
"jquery.terminal": "^1.23.2",
"jquery.terminal": "^2.34.0",
"line-reader": "^0.4.0",
"moment": "^2.29.1",
"multer": "^1.3.0",

View File

@ -15,9 +15,7 @@ let config = JSON.parse(fs.readFileSync((process.env.PICLUSTER_CONFIG ? process.
process.env.NODE_TLS_REJECT_UNAUTHORIZED = config.ssl_self_signed ? '0' : '1';
const app = express();
app.use(express.urlencoded({
limit: '20mb'
}));
app.use(express.urlencoded({ extended: true }));
app.use(express.json({
limit: '20mb'
}));
@ -1372,4 +1370,4 @@ if (config.ssl && config.ssl_cert && config.ssl_key) {
webconsole.listen(web_port, () => {
console.log('Listening on port %d', web_port);
});
}
}