1
0
Fork 0
mirror of https://github.com/ThomasGsp/HyperProxmox.git synced 2025-02-13 03:32:16 +00:00
HyperProxmox/README.md

285 lines
10 KiB
Markdown
Raw Normal View History

2017-11-18 20:15:00 +00:00
# HyperProxmox
2017-10-24 12:42:54 +00:00
* Author : Tlams
* Date : 2017/2018
2018-02-19 12:13:22 +00:00
* Version : Alpha 1.0
2017-10-24 12:42:54 +00:00
* Status: Dev
2018-02-15 11:05:50 +00:00
* Object : Massive LXC CT / KVM deployment and management system for Proxmox clusters.
2018-02-14 12:32:49 +00:00
* Information :
This project is currently in active development.
You shouldn't use in production mode, use at your risks !
2017-10-29 16:59:20 +00:00
2018-02-19 11:47:21 +00:00
## Version informations:
* Provide:
- Basic web interface to list instances, nodes and clusters (with details)
- Basic instance management by the web interface(stop/start/restart...)
- Proxmox data crawler
- API for the system management and data
- Encipher the critical data (cluster access)
* Not provide:
2018-02-19 12:11:38 +00:00
- Advanced security (No API/Web interface authentification - DO NOT EXPOSE API ON "0.0.0.0")
2018-02-19 11:47:21 +00:00
- Instance deployment
- Group & cluster viewing in web interface
- Advanced logs system
- Purge data system
- Lot of others things
2018-02-13 17:57:07 +00:00
## Requirement:
* Proxmox infrastructure (standalone, clusters...)
* Administrative pve user (full access)
* Vztemplate uploaded
2017-10-29 16:59:20 +00:00
2018-02-13 17:57:07 +00:00
* MongoDB server
* Version 3.6
* Standalone or with replicats for hight availability
* Redis server
* Web stack
* Nginx
* PHP7
* php-curl, php-mysql, php7.0-json
* Python softwares
* Version 3.5 min
* python-redis
* pymongo
* web.py
* python-requests
* Crypto
2018-02-21 22:20:00 +00:00
## Installation (Debian type - Full standalone stack)
2018-02-13 17:57:07 +00:00
### Install all packages
``` bash
2018-02-20 00:18:44 +00:00
apt-get install php-fpm php-curl php-json python3-pip python3-redis python3-netaddr mongodb nginx redis-server git
2018-02-13 17:57:07 +00:00
pip3 install pymongo db utils web.py requests
```
### Configurations (bases)
#### NGINX
``` bash
2018-02-14 12:32:49 +00:00
server {
listen *:443 ssl;
server_name youdomain.name;
root /var/www/hyperproxmox;
ssl on;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security "max-age=86400";
location ~ \.php$ {
include snippets/fastcgi-php.conf;
2018-02-15 12:12:58 +00:00
fastcgi_pass unix:/var/run/php-www.sock;
2018-02-14 12:32:49 +00:00
}
}
2018-02-13 17:57:07 +00:00
```
#### PHP
``` bash
2018-02-14 12:32:49 +00:00
[www]
user = www-data
group = www-data
listen = /var/run/php-www.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
pm = dynamic
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_children = 50
pm.max_requests = 200
pm.status_path = /fpm-status
ping.path = /ping
ping.response = pong
request_slowlog_timeout = 0
request_terminate_timeout = 0
catch_workers_output = yes
2018-02-13 17:57:07 +00:00
```
#### Hyperproxmox
``` bash
2018-02-14 12:32:49 +00:00
useradd hyperproxmox
2018-02-20 00:18:44 +00:00
cd /opt/ && git clone https://github.com/ThomasGsp/HyperProxmox.git
2018-02-14 12:32:49 +00:00
# set www dir
mkdir /var/www/hyperproxmox
2018-02-20 00:18:44 +00:00
cp -R /opt/HyperProxmox/code/web/www/* /var/www/hyperproxmox/
2018-02-14 12:32:49 +00:00
chown www-data: -R /var/www/hyperproxmox
# No www-data write (useless)
2018-02-15 12:12:58 +00:00
chmod 550 -R /var/www/hyperproxmox
2018-02-14 12:32:49 +00:00
# Set hyperproxmox
chown hyperproxmox: -R /opt/HyperProxmox
chmod 760 -R /opt/HyperProxmox
# Log dir (you can change it)
mkdir /var/log/hyperproxmox/
2018-02-15 12:12:58 +00:00
chown hyperproxmox: /var/log/hyperproxmox/
2018-02-14 12:32:49 +00:00
2018-02-20 00:18:44 +00:00
#Rm demo keys
rm /opt/HyperProxmox/code/scripts/main/private/keys/Ragnarok.p*
```
2018-02-14 12:32:49 +00:00
```
``` bash
# Configurations
vi /opt/HyperProxmox/code/scripts/main/private/conf/config
< set your values >
2018-02-13 17:57:07 +00:00
```
2017-10-29 16:59:20 +00:00
### Init:
``` bash
2018-02-21 21:30:04 +00:00
# Start & generate your key (root user/sudo)
runuser -l hyperproxmox -c '/usr/bin/python3.5 /opt/HyperProxmox/code/scripts/main/startup.py'
OUTPUT:
######################
No key found, auto-generation started ...
Need a passphrase to start the generation:
This action can take some minutes, please wait.
Your new key has been generate !
- Private Key: private/keys/Ragnarok.pvt.key
- Public Key: private/keys/Ragnarok.pvt.key
Passphrase HASH: 10e06b990d44de0091a2(......)5591c161ecc35944fc69c4433a49d10fc6b04a33611
You MUST save your passphrase hash in a security place !
Start API server...
http://127.0.0.1:8080/
######################
2017-10-29 16:59:20 +00:00
```
2018-02-21 21:30:04 +00:00
The HASH will be ask at each start.
Without it, the privite key can be read and the access cannot be load in the memory.
If you loose it, you must delete the keys, delete the different entries in the collection "clusters_conf" in mongoDB database.
2017-10-29 16:59:20 +00:00
2018-02-20 00:18:44 +00:00
### Insert your first cluster (from host)
2017-10-29 16:59:20 +00:00
``` bash
2018-02-23 14:04:59 +00:00
# Minimum:
curl -H -XPOST -d '{ "name": "Cluster_A",
"url":"proxmox.cluster.net",
"port": "8006",
"user": "user@pve",
"password": "******",
"template": "",
"storage_disk": "",
"exclude_nodes": [""],
"groups" : [""],
"weight": 1
}' localhost:8080/api/v1/administration/cluster/new
# Other example:
curl -H -XPOST -d '{ "name": "Cluster_B",
2017-10-29 16:59:20 +00:00
"url":"proxmox.cluster.net",
"port": "8006",
"user": "user@pve",
"password": "******",
"template": "local:vztmpl/debian-9.0-standard_9.0-2_amd64.tar.gz",
"storage_disk": "disks",
2018-02-23 14:04:59 +00:00
"exclude_nodes": ["node_shit1"],
2018-02-14 12:32:49 +00:00
"groups" : ["group1", "group2..."],
"weight": 1
2018-02-23 14:04:59 +00:00
}' localhost:8080/api/v1/administration/cluster/new
2017-10-29 16:59:20 +00:00
```
2018-02-23 14:04:59 +00:00
* "name": Symbolic cluster name. Should be uniq (string) [VALUE NOT EMPTY REQUIRED]
* "url": Proxmox - Web GUI URL access (string) [VALUE NOT EMPTY REQUIRED]
* "port": Proxmox - Web PORT access (string) [VALUE NOT EMPTY REQUIRED]
* "user": Proxmox - Administrative PVE user (string) [VALUE NOT EMPTY REQUIRED]
* "password": Proxmox - PVE password (string) [VALUE NOT EMPTY REQUIRED]
2018-02-14 12:32:49 +00:00
* "template": Default template for LXC (string)
* "storage_disk": Default shared disk for KVM/LXC (string)
* "exclude_nodes": Do not use this nodes - Not visible (list)
* "groups" : Symbolics groups for this node (list)
2018-02-23 14:04:59 +00:00
* "weight": Weight for the cluster auto-selection (int) [VALUE NOT EMPTY REQUIRED]
2018-02-19 12:11:38 +00:00
![alt text](https://github.com/ThomasGsp/HyperProxmox/blob/master/doc/screenshots/h-nodes.jpg)
![alt text](https://github.com/ThomasGsp/HyperProxmox/blob/master/doc/screenshots/h-vms.jpg)
![alt text](https://github.com/ThomasGsp/HyperProxmox/blob/master/doc/screenshots/h-sto.jpg)
2018-02-21 21:30:04 +00:00
## API Information
### General informations
``` bash
([a-z0-9]+) = MongoID
2018-02-21 21:40:03 +00:00
([0-9]+) = Timestamp/vmid
2018-02-21 21:30:04 +00:00
([0-9a-zA-Z\_\-]+) = Cluster/node name
```
2018-02-21 21:33:03 +00:00
### Instance status management
2018-02-21 21:30:04 +00:00
``` bash
'/api/v1/instance/id/([a-z0-9]+)/status/(start|stop|current|reset|shutdown)' | GET
```
### Cluster management
``` bash
'/api/v1/administration/cluster/(?:[0-9a-zA-Z\_\-]+)' | GET - Return the informations for an specific cluster
2018-02-21 21:40:03 +00:00
| PUT - Update the configurations for an specific cluster
| DELETE - Delete the configuration for an specific cluster
2018-02-21 21:30:04 +00:00
'/api/v1/administration/cluster/' | GET - Return all clusters information
'/api/v1/administration/cluster/new' | POST - Inster a new cluster
```
2018-02-21 21:33:03 +00:00
### Cache Data - MongoDB
2018-02-21 21:40:03 +00:00
This data are manage by the crawler, you can't insert or change data yourself
2018-02-21 21:30:04 +00:00
``` bash
# date/cluster/node/vmid
# Disks mapping
'/api/v1/static/disks/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/([0-9]+)' | GET - Return the informations for an specific disk
'/api/v1/static/disks/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/' | GET - Return all disks used in a node
'/api/v1/static/disks/([0-9]+)/([0-9a-zA-Z\_\-]+)/' | GET - Return all disks used in a cluster
'/api/v1/static/disks/([0-9]+)/' | GET - Return all disks
# Storages mapping
'/api/v1/static/storages/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/' | GET - Return all storage used in a node
'/api/v1/static/storages/([0-9]+)/([0-9a-zA-Z\_\-]+)/' | GET - Return all storages used in a cluster
'/api/v1/static/storages/([0-9]+)/' | GET - Return all storages
# Instances mapping
'/api/v1/static/instances/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/([0-9]+) | GET - Return the informations for an specific instance
'/api/v1/static/instances/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)/ | GET - Return all instances for a node
'/api/v1/static/instances/([0-9]+)/([0-9a-zA-Z\_\-]+)/ | GET - Return all instances for a cluster
'/api/v1/static/instances/([0-9]+) | GET - Return all instances (the dump can be very big, in a large infrastructure)
# Nodes mapping
'/api/v1/static/(nodes)/([0-9]+)/([0-9a-zA-Z\_\-]+)/([0-9a-zA-Z\_\-]+)' | GET - Return the informations for an specific node
'/api/v1/static/(nodes)/([0-9]+)/([0-9a-zA-Z\_\-]+)/' | GET - Return all nodes for a cluster
'/api/v1/static/(nodes)/([0-9]+)/' | GET - Return all nodes
# cluster mapping
'/api/v1/static/(clusters)/([0-9]+)/(?:[0-9a-zA-Z\_\-]+)' | GET - Return the insformations for a specific cluster
'/api/v1/static/(clusters)/([0-9]+)/' | GET - Return all cluster informations
# date
'/api/v1/static/dates/(all|last)' | GET - Return all or the last date available (generated by the crawler)
# mongoid
'/api/v1/static/(instances|nodes|clusters|storages|disks)/id/([a-z0-9]+)' | GET - Return an information by mongoid
```
2018-02-21 22:20:00 +00:00
### Typical use
2018-02-21 21:30:04 +00:00
``` bash
curl http://127.0.0.1:8080/api/v1/static/nodes/1519040226/Cluster_1/sd-817348
2018-02-21 22:20:00 +00:00
```