Skip to content

Commit 751e4d6

Browse files
authored
Simplify port mapping with traefik in ddev 1.22 (#7)
1 parent 0a33a8f commit 751e4d6

7 files changed

+44
-73
lines changed

config.grafana.traces.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

docker-compose.grafana.logs.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ services:
1515
source: ./grafana/loki/loki.yaml
1616
target: /etc/loki/local-config.yaml
1717
- loki-data:/loki
18+
labels:
19+
com.ddev.site-name: ${DDEV_SITENAME}
20+
com.ddev.approot: ${DDEV_APPROOT}
21+
environment:
22+
- VIRTUAL_HOST=$DDEV_HOSTNAME
23+
- HTTP_EXPOSE=3100:3100
24+
- HTTPS_EXPOSE=3100:3100
1825

1926
agent:
2027
container_name: "ddev-${DDEV_SITENAME}-agent"
@@ -33,4 +40,3 @@ volumes:
3340
name: "ddev-${DDEV_SITENAME}_web-logs"
3441
loki-data:
3542
name: "ddev-${DDEV_SITENAME}_loki"
36-

docker-compose.grafana.metrics.yaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@ services:
44
image: prom/prometheus:latest
55
user: "${UID:-}:${GID:-}"
66
command:
7-
- '--config.file=/etc/prometheus/prometheus.yaml'
8-
- '--storage.tsdb.path=/prometheus'
9-
- '--web.console.libraries=/etc/prometheus/console_libraries'
10-
- '--web.console.templates=/etc/prometheus/consoles'
11-
- '--web.enable-lifecycle'
7+
- "--config.file=/etc/prometheus/prometheus.yaml"
8+
- "--storage.tsdb.path=/prometheus"
9+
- "--web.console.libraries=/etc/prometheus/console_libraries"
10+
- "--web.console.templates=/etc/prometheus/consoles"
11+
- "--web.enable-lifecycle"
1212
volumes:
1313
- type: bind
1414
source: ./grafana/prometheus/prometheus.yaml
1515
target: /etc/prometheus/prometheus.yaml
1616
- prometheus-data:/prometheus
17+
labels:
18+
com.ddev.site-name: ${DDEV_SITENAME}
19+
com.ddev.approot: ${DDEV_APPROOT}
20+
environment:
21+
- VIRTUAL_HOST=$DDEV_HOSTNAME
22+
- HTTP_EXPOSE=9090:9090
23+
- HTTPS_EXPOSE=9090:9090
1724
# Scraping metrics for web services can be configured in the file
1825
# grafana/prometheus/prometheus.yaml
1926

docker-compose.grafana.traces.yaml

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,22 @@
11
services:
2-
web:
3-
# Comment this if you don't need to bind trace ports to localhost.
4-
extra_hosts:
5-
- "tempo:127.0.0.1"
6-
72
tempo:
83
container_name: "ddev-${DDEV_SITENAME}-tempo"
94
image: grafana/tempo:latest
10-
# Comment this if you don't need to bind trace ports to localhost.
11-
network_mode: container:ddev-${DDEV_SITENAME}-web
125
user: "${UID:-}:${GID:-}"
6+
command:
7+
- "-config.file=/etc/tempo.yaml"
138
volumes:
149
- type: bind
1510
source: ./grafana/tempo/tempo.yaml
1611
target: /etc/tempo.yaml
1712
- tempo-data:/data
18-
command:
19-
- "-config.file=/etc/tempo.yaml"
20-
depends_on:
21-
- web
22-
# exposed ports is configured in a separate file:
23-
# config.grafana.tracing.yaml
24-
25-
# # Another approach to expose HTTP tracing endpoints to the ddev host.
26-
# # Only HTTP endoinds supported via this approach.
27-
# labels:
28-
# com.ddev.site-name: ${DDEV_SITENAME}
29-
# com.ddev.approot: $DDEV_APPROOT
30-
# environment:
31-
# - VIRTUAL_HOST=$DDEV_HOSTNAME
32-
# # We need also to pass DDEV default ports here via adding the substring:
33-
# # ${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}
34-
# - HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}:8025,4318:4318,9411:9411,14268:14268
35-
36-
grafana:
37-
# Required to connect from Grafana container via named hosts.
38-
# Comment this if you don't need to bind trace ports to localhost.
39-
links:
40-
- "web:tempo"
13+
labels:
14+
com.ddev.site-name: ${DDEV_SITENAME}
15+
com.ddev.approot: ${DDEV_APPROOT}
16+
environment:
17+
- VIRTUAL_HOST=$DDEV_HOSTNAME
18+
- HTTP_EXPOSE=4318:4318,9411:9411,14268:14268
19+
- HTTPS_EXPOSE=4318:4318,9411:9411,14268:14268
4120

4221
volumes:
4322
tempo-data:

docker-compose.grafana.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ services:
2525
target: /var/lib/grafana/dashboards
2626
environment:
2727
- VIRTUAL_HOST=$DDEV_HOSTNAME
28-
- HTTP_EXPOSE=3001:3000 # Grafana web interface via HTTP.
29-
- HTTPS_EXPOSE=3000:3000 # Grafana web interface with HTTPS.
28+
- HTTP_EXPOSE=3000:3000
29+
- HTTPS_EXPOSE=3000:3000

install.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pre_install_actions:
44

55
project_files:
66
- config.grafana.logs.yaml
7-
- config.grafana.traces.yaml
87
- docker-compose.grafana.logs.yaml
98
- docker-compose.grafana.metrics.yaml
109
- docker-compose.grafana.traces.yaml

tests/test.bats

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,48 +21,46 @@ health_checks() {
2121
# To make a test run only on local machines,
2222
# add the `[ -z "$DDEV_CLOUD_ENV" ] && ` prefix to the command.
2323
if [ -n "${GITHUB_ACTIONS:-}" ]; then
24-
DDEV_CLOUD_ENV=1
24+
DDEV_CLOUD_ENV=
2525
else
2626
DDEV_CLOUD_ENV=
2727
fi
2828
# Workaround end.
2929

3030
# Grafana service
3131
ddev exec "curl -s -o /dev/null http://grafana:3000/api/health"
32-
curl -s -o /dev/null http://${PROJNAME}.ddev.site:3001/api/health
32+
curl -s -o /dev/null http://${PROJNAME}.ddev.site:3000/api/health
3333
curl -s -o /dev/null https://${PROJNAME}.ddev.site:3000/api/health
3434

3535
echo "Checking Loki service"
3636
# Loki takes 15+ secs to initialize, so use the http://loki:3100/ready url
3737
# is not a good idea, just checking the services endpoint.
3838
ddev exec "curl -s -o /dev/null http://loki:3100/services"
39+
curl -s -o /dev/null http://${PROJNAME}.ddev.site:3100/
40+
curl -s -o /dev/null https://${PROJNAME}.ddev.site:3100/
3941

4042
echo "Checking Prometeus service"
4143
ddev exec "curl -s -o /dev/null http://prometheus:9090/-/ready"
44+
curl -s -o /dev/null http://${PROJNAME}.ddev.site:9090/
45+
curl -s -o /dev/null https://${PROJNAME}.ddev.site:9090/
4246

4347
echo "Checking Tempo service"
4448
# Tempo takes 15 secs to initialize, so use the http://tempo:3200/ready url
4549
# is not a good idea, just checking the version endpoint.
4650
ddev exec "curl -s -o /dev/null http://tempo:3200/status/version"
4751

4852
echo "Checking Tempo HTTP receivers ports"
49-
echo 4318
5053
ddev exec "curl -s -o /dev/null http://tempo:4318/"
51-
[ -z "$DDEV_CLOUD_ENV" ] && ddev exec "curl -s -o /dev/null http://localhost:4318/"
52-
[ -z "$DDEV_CLOUD_ENV" ] && curl -s -o /dev/null https://${PROJNAME}.ddev.site:4318/
53-
echo 9411
54+
curl -s -o /dev/null http://${PROJNAME}.ddev.site:4318/
55+
curl -s -o /dev/null https://${PROJNAME}.ddev.site:4318/
56+
5457
ddev exec "curl -s -o /dev/null http://tempo:9411/"
55-
[ -z "$DDEV_CLOUD_ENV" ] && ddev exec "curl -s -o /dev/null http://localhost:9411/"
56-
[ -z "$DDEV_CLOUD_ENV" ] && curl -s -o /dev/null https://${PROJNAME}.ddev.site:9411/
57-
echo 14268
58-
echo 1
58+
curl -s -o /dev/null http://${PROJNAME}.ddev.site:9411/
59+
curl -s -o /dev/null https://${PROJNAME}.ddev.site:9411/
60+
5961
ddev exec "curl -s -o /dev/null http://tempo:14268/"
60-
echo 2
61-
ddev exec "curl -I http://tempo:14268/"
62-
echo 3
63-
[ -z "$DDEV_CLOUD_ENV" ] && ddev exec "curl -s -o /dev/null http://localhost:14268/"
64-
[ -z "$DDEV_CLOUD_ENV" ] && curl -s -o /dev/null https://${PROJNAME}.ddev.site:14268/
65-
echo "Fin"
62+
curl -s -o /dev/null http://${PROJNAME}.ddev.site:14268/
63+
curl -s -o /dev/null https://${PROJNAME}.ddev.site:14268/
6664
}
6765

6866
teardown() {

0 commit comments

Comments
 (0)