diff --git a/docker/code-server/README.md b/docker/code-server/README.md new file mode 100644 index 00000000..e69de29b diff --git a/docker/code-server.yaml b/docker/code-server/compose.yaml similarity index 87% rename from docker/code-server.yaml rename to docker/code-server/compose.yaml index 3bc998ed..e0597ee3 100644 --- a/docker/code-server.yaml +++ b/docker/code-server/compose.yaml @@ -10,7 +10,7 @@ services: - SUDO_PASSWORD=password #optional - DEFAULT_WORKSPACE=/config/workspace #optional volumes: - - $HOME/.config/vscode/config:/home/coder/config + - /home/sysadm/.config/vscode/config:/home/coder/config - /home/sysadm/monitoring:/config/workspace/monitoring ports: - 8443:8443 diff --git a/docker/monitoring/README.md b/docker/monitoring/README.md new file mode 100644 index 00000000..b7ce54c8 --- /dev/null +++ b/docker/monitoring/README.md @@ -0,0 +1,85 @@ +## Compose sample + +### Prometheus & Grafana + +Project structure: + +``` +. +├── compose.yaml +├── grafana +│ └── grafana-config.yaml +├── prometheus +│ └── prometheus-config.yaml +└── README.md +``` + +[_compose.yaml_](docker-compose.yaml) + +``` +services: + prometheus: + image: prom/prometheus + ... + ports: + - 9090:9090 + grafana: + image: grafana/grafana + ... + ports: + - 3000:3000 +``` + +Copy the `monitoring` directory over to your Docker host with secure copy like so: + +```bash + scp -r home-ops/docker/monitoring sysadm@:/home/sysadm/monitoring +``` + +Then use the directory path on the host to map your config files as example: + +```yaml +volumes: + - /home/sysadm/monitoring/prometheus:/etc/prometheus +``` + +The compose file defines a stack with two services `prometheus` and `grafana`. + +When deploying the stack, docker compose maps port the default ports for each service to the equivalent ports on the host in order to inspect easier the web interface of each service. +Make sure the ports 9090 and 3000 on the host are not already in use. + +## Deploy with docker compose + +``` +$ docker compose up -d +Creating network "prometheus-grafana_default" with the default driver +Creating volume "prometheus-grafana_prom_data" with default driver +... +Creating grafana ... done +Creating prometheus ... done +Attaching to prometheus, grafana + +``` + +## Expected result + +Listing containers must show two containers running and the port mapping as below: + +``` +$ docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +dbdec637814f prom/prometheus "/bin/prometheus --c…" 8 minutes ago Up 8 minutes 0.0.0.0:9090->9090/tcp prometheus +79f667cb7dc2 grafana/grafana "/run.sh" 8 minutes ago Up 8 minutes 0.0.0.0:3000->3000/tcp grafana +``` + +Navigate to `http://localhost:3000` in your web browser and use the login credentials specified in the compose file to access Grafana. It is already configured with prometheus as the default datasource. + +![page](output.jpg) + +Navigate to `http://localhost:9090` in your web browser to access directly the web interface of prometheus. + +Stop and remove the containers. Use `-v` to remove the volumes if looking to erase all data. + +``` +docker compose down -v +``` diff --git a/docker/monitoring.yaml b/docker/monitoring/compose.yaml similarity index 79% rename from docker/monitoring.yaml rename to docker/monitoring/compose.yaml index 15f9309f..88c78f1f 100644 --- a/docker/monitoring.yaml +++ b/docker/monitoring/compose.yaml @@ -6,20 +6,22 @@ services: - "--config.file=/etc/prometheus/prometheus.yaml" ports: - 9090:9090 - restart: unless-stopped + restart: always volumes: - /home/sysadm/monitoring/prometheus:/etc/prometheus - prom_data:/prometheus + grafana: image: grafana/grafana container_name: grafana ports: - 3000:3000 - restart: unless-stopped + restart: always environment: - GF_SECURITY_ADMIN_USER=admin - GF_SECURITY_ADMIN_PASSWORD=grafana volumes: - - ./home/sysadm/monitoring/grafana:/etc/grafana/provisioning/datasources + - /home/sysadm/monitoring/grafana:/etc/grafana/provisioning/datasources + volumes: prom_data: diff --git a/docker/monitoring/grafana/grafana-config.yaml b/docker/monitoring/grafana/grafana-config.yaml new file mode 100644 index 00000000..44999d46 --- /dev/null +++ b/docker/monitoring/grafana/grafana-config.yaml @@ -0,0 +1,9 @@ +apiVersion: 1 + +datasources: + - name: Prometheus + type: prometheus + url: http://prometheus:9090 + isDefault: true + access: proxy + editable: true diff --git a/docker/monitoring/prometheus/prometheus-config.yaml b/docker/monitoring/prometheus/prometheus-config.yaml new file mode 100644 index 00000000..95b281f1 --- /dev/null +++ b/docker/monitoring/prometheus/prometheus-config.yaml @@ -0,0 +1,8 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + - job_name: "prometheus" + static_configs: + - targets: ["localhost:9090", "192.168.7.70:9100"] diff --git a/docker/postgres/README.md b/docker/postgres/README.md new file mode 100644 index 00000000..e69de29b diff --git a/docker/postgres.yaml b/docker/postgres/compose.yaml similarity index 65% rename from docker/postgres.yaml rename to docker/postgres/compose.yaml index bcce9c0e..14bbcb2b 100644 --- a/docker/postgres.yaml +++ b/docker/postgres/compose.yaml @@ -1,3 +1,5 @@ +version: "3.8" + services: postgres: container_name: postgres @@ -27,6 +29,17 @@ services: volumes: - pgadmin_data:/var/lib/pgadmin + postgres-exporter: + container_name: postgres-exporter + image: quay.io/prometheuscommunity/postgres-exporter + environment: + DATA_SOURCE_URI: "postgres://postgres:password@postgres:5432/postgres?sslmode=disable" + DATA_SOURCE_USER: postgres + DATA_SOURCE_PASS: password + depends_on: + - postgres + - pgadmin + volumes: postgres_data: pgadmin_data: diff --git a/docker/redis/README.md b/docker/redis/README.md new file mode 100644 index 00000000..351ae779 --- /dev/null +++ b/docker/redis/README.md @@ -0,0 +1,21 @@ +# Run Redis Stack on Docker + +How to install Redis Stack using Docker + +To get started with Redis Stack using Docker, you first need to select a Docker image: + +- `redis/redis-stack` contains both Redis Stack server and Redis Insight. This container is best for local development because you can use the embedded Redis Insight to visualize your data. + +- `redis/redis-stack-server` provides Redis Stack server only. This container is best for production deployment. + +## Getting started + +**redis/redis-stack** + +To start a Redis Stack container using the redis-stack image, run the following command in your terminal: + +[_compose.yaml_](compose.yaml) + +The docker run command above also exposes Redis Insight on port `8001`. You can use Redis Insight by pointing your browser to `localhost:8001`. + +[https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/docker/](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/docker/) diff --git a/docker/redis/compose.yaml b/docker/redis/compose.yaml new file mode 100644 index 00000000..5f15d5c2 --- /dev/null +++ b/docker/redis/compose.yaml @@ -0,0 +1,15 @@ +version: '3.8' + +services: + redis-stack: + image: redis/redis-stack:latest + container_name: redis-stack + ports: + - '6379:6379' + - '8001:8001' + volumes: + - redis_data:/data + +volumes: + redis_data: + driver: local diff --git a/kubernetes/apps/homepage-dashboard/config-map.yaml b/kubernetes/apps/homepage-dashboard/config-map.yaml index af7e4bea..88efe35c 100644 --- a/kubernetes/apps/homepage-dashboard/config-map.yaml +++ b/kubernetes/apps/homepage-dashboard/config-map.yaml @@ -148,6 +148,12 @@ data: description: PGAdmin for Postgres target: _blank + - Redis: + icon: redis.svg + href: http://192.168.7.70:8001 + description: Open-source monitoring system + target: _blank + - Code Server: icon: code.png href: http://192.168.7.70:8443 @@ -166,6 +172,7 @@ data: description: Open-source monitoring system target: _blank + - Network: - PiHole 1: diff --git a/kubernetes/apps/redis-db/deployment.yaml b/kubernetes/apps/redis-db/deployment.yaml index 8fb48129..49042f4b 100644 --- a/kubernetes/apps/redis-db/deployment.yaml +++ b/kubernetes/apps/redis-db/deployment.yaml @@ -16,9 +16,10 @@ spec: spec: containers: - name: redis - image: redis:latest + image: redis/redis-stack:latest ports: - containerPort: 6379 + - containerPort: 8001 resources: requests: memory: "256Mi"