Skip to content

Commit

Permalink
....Docker and configmap changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpbennett committed Jul 12, 2024
1 parent cc4263e commit 5738fc9
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 5 deletions.
Empty file added docker/code-server/README.md
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
85 changes: 85 additions & 0 deletions docker/monitoring/README.md
Original file line number Diff line number Diff line change
@@ -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@<docker-host>:/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
```
8 changes: 5 additions & 3 deletions docker/monitoring.yaml → docker/monitoring/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
9 changes: 9 additions & 0 deletions docker/monitoring/grafana/grafana-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: 1

datasources:
- name: Prometheus
type: prometheus
url: http://prometheus:9090
isDefault: true
access: proxy
editable: true
8 changes: 8 additions & 0 deletions docker/monitoring/prometheus/prometheus-config.yaml
Original file line number Diff line number Diff line change
@@ -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"]
Empty file added docker/postgres/README.md
Empty file.
13 changes: 13 additions & 0 deletions docker/postgres.yaml → docker/postgres/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
version: "3.8"

services:
postgres:
container_name: postgres
Expand Down Expand Up @@ -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:
21 changes: 21 additions & 0 deletions docker/redis/README.md
Original file line number Diff line number Diff line change
@@ -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/)
15 changes: 15 additions & 0 deletions docker/redis/compose.yaml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions kubernetes/apps/homepage-dashboard/config-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -166,6 +172,7 @@ data:
description: Open-source monitoring system
target: _blank
- Network:
- PiHole 1:
Expand Down
3 changes: 2 additions & 1 deletion kubernetes/apps/redis-db/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5738fc9

Please sign in to comment.