initial commi
This commit is contained in:
commit
6ee69c6bd9
5
.env
Normal file
5
.env
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
POSTGRES_PASSWORD=openpgpwd
|
||||||
|
POSTGRES_USER=openpg
|
||||||
|
POSTGRES_DB=pulumi
|
||||||
|
ODOO_PASSWORD=admin
|
||||||
|
GRAFANA_PASSWORD=grafana_pwd
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*.pyc
|
||||||
|
venv/
|
11
Pulumi.yaml
Normal file
11
Pulumi.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
name: dev
|
||||||
|
description: A minimal OpenStack Python Pulumi program
|
||||||
|
runtime:
|
||||||
|
name: python
|
||||||
|
options:
|
||||||
|
toolchain: pip
|
||||||
|
virtualenv: venv
|
||||||
|
config:
|
||||||
|
pulumi:tags:
|
||||||
|
value:
|
||||||
|
pulumi:template: openstack-python
|
49
__main__.py
Normal file
49
__main__.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import pulumi
|
||||||
|
import pulumi_docker as docker
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Charger le fichier JSON
|
||||||
|
with open("config.json", "r") as f:
|
||||||
|
containers_data = json.load(f)
|
||||||
|
|
||||||
|
# Créer le réseau
|
||||||
|
network = docker.Network("testNetwork")
|
||||||
|
|
||||||
|
# Créer les volumes
|
||||||
|
volumes = {}
|
||||||
|
for container in containers_data["containers"]:
|
||||||
|
for volume in container.get("volumes", []):
|
||||||
|
if "volume_name" in volume and volume["volume_name"] not in volumes:
|
||||||
|
volumes[volume["volume_name"]] = docker.Volume(volume["volume_name"])
|
||||||
|
|
||||||
|
# Créer les conteneurs
|
||||||
|
for container in containers_data["containers"]:
|
||||||
|
instances = container.get("instances", 1)
|
||||||
|
for i in range(instances):
|
||||||
|
container_name = f"{container['name']}-{i}" if instances > 1 else container["name"]
|
||||||
|
# Configurer les volumes
|
||||||
|
volumes_config = [
|
||||||
|
docker.ContainerVolumeArgs(
|
||||||
|
container_path=volume["container_path"],
|
||||||
|
volume_name=volumes[volume["volume_name"]].name
|
||||||
|
) if "volume_name" in volume else
|
||||||
|
docker.ContainerVolumeArgs(
|
||||||
|
container_path=volume["container_path"],
|
||||||
|
host_path=os.path.abspath(volume["host_path"])
|
||||||
|
)
|
||||||
|
for volume in container.get("volumes", [])
|
||||||
|
]
|
||||||
|
# Créer le conteneur
|
||||||
|
docker.Container(container_name,
|
||||||
|
image=container["image"],
|
||||||
|
envs=[f"{key}={value}" for key, value in container.get("envs", {}).items()],
|
||||||
|
ports=[
|
||||||
|
docker.ContainerPortArgs(
|
||||||
|
internal=port["internal"],
|
||||||
|
external=port["external"] + i
|
||||||
|
) for port in container.get("ports", [])
|
||||||
|
],
|
||||||
|
volumes=volumes_config,
|
||||||
|
network_mode=network.name,
|
||||||
|
command=container.get("command", []))
|
91
config.json
Normal file
91
config.json
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
{
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"name": "db",
|
||||||
|
"image": "postgres:latest",
|
||||||
|
"envs": {
|
||||||
|
"POSTGRES_DB": "admin",
|
||||||
|
"POSTGRES_USER": "admin",
|
||||||
|
"POSTGRES_PASSWORD": "admin"
|
||||||
|
},
|
||||||
|
"ports": [{"internal": 5432, "external": 5432}],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"container_path": "/var/lib/postgresql/data",
|
||||||
|
"volume_name": "postgres-data"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "odoo",
|
||||||
|
"image": "odoo:latest",
|
||||||
|
"envs": {
|
||||||
|
"HOST": "db",
|
||||||
|
"USER": "admin",
|
||||||
|
"PASSWORD": "admin",
|
||||||
|
"DATABASE": "admin",
|
||||||
|
"ODOO_PASSWORD": "admin"
|
||||||
|
},
|
||||||
|
"ports": [{"internal": 8069, "external": 8069}],
|
||||||
|
"instances": 3,
|
||||||
|
"command": ["/bin/bash", "-c", "sleep 10 && odoo -i base"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "grafana",
|
||||||
|
"image": "grafana/grafana:latest",
|
||||||
|
"envs": {
|
||||||
|
"GF_SECURITY_ADMIN_PASSWORD": "grafana_pwd",
|
||||||
|
"GF_DATASOURCES_PROMETHEUS_URL": "http://prometheus:9090"
|
||||||
|
},
|
||||||
|
"ports": [{"internal": 3000, "external": 3000}],
|
||||||
|
"instances": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prometheus",
|
||||||
|
"image": "prom/prometheus:latest",
|
||||||
|
"ports": [{"internal": 9090, "external": 9090}],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"container_path": "/prometheus",
|
||||||
|
"volume_name": "prometheus-data"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"container_path": "/etc/prometheus/prometheus.yml",
|
||||||
|
"host_path": "./prometheus.yml"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fluentd",
|
||||||
|
"image": "fluent/fluentd:v1.13-1",
|
||||||
|
"ports": [{"internal": 24224, "external": 24224}],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"container_path": "/fluentd/etc/fluent.conf",
|
||||||
|
"host_path": "./fluent.conf"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "backup",
|
||||||
|
"image": "alpine:latest",
|
||||||
|
"envs": {
|
||||||
|
"POSTGRES_HOST": "db",
|
||||||
|
"POSTGRES_DB": "admin",
|
||||||
|
"POSTGRES_USER": "admin",
|
||||||
|
"POSTGRES_PASSWORD": "admin"
|
||||||
|
},
|
||||||
|
"command": [
|
||||||
|
"/bin/sh", "-c",
|
||||||
|
"apk add --no-cache postgresql-client && sleep 10"
|
||||||
|
],
|
||||||
|
"volumes": [
|
||||||
|
{
|
||||||
|
"container_path": "/backup",
|
||||||
|
"volume_name": "backup-data"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
10
entrypoint.sh
Normal file
10
entrypoint.sh
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
odoo -i base
|
||||||
|
|
||||||
|
|
||||||
|
exec "$@"
|
13
fluent.conf
Normal file
13
fluent.conf
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<source>
|
||||||
|
@type forward
|
||||||
|
port 8069 # Odoo logs
|
||||||
|
</source>
|
||||||
|
|
||||||
|
<source>
|
||||||
|
@type forward
|
||||||
|
port 3000 # Grafana logs
|
||||||
|
</source>
|
||||||
|
|
||||||
|
<match **>
|
||||||
|
@type stdout
|
||||||
|
</match>
|
15
prometheus.yml
Normal file
15
prometheus.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
global:
|
||||||
|
scrape_interval: 15s # How often to scrape metrics (every 15 seconds)
|
||||||
|
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: 'postgres' # For scraping PostgreSQL
|
||||||
|
static_configs:
|
||||||
|
- targets: ['postgres:5432']
|
||||||
|
|
||||||
|
- job_name: 'odoo' # For scraping Odoo
|
||||||
|
static_configs:
|
||||||
|
- targets: ['odoo:8069']
|
||||||
|
|
||||||
|
- job_name: 'grafana' # For scraping Grafana
|
||||||
|
static_configs:
|
||||||
|
- targets: ['grafana:3000']
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
pulumi>=3.0.0,<4.0.0
|
||||||
|
pulumi-openstack>=3.0.0,<4.0.0
|
Loading…
Reference in New Issue
Block a user