Skip to content

Commit

Permalink
Simplify port mapping with traefik in ddev 1.22 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
MurzNN authored Aug 3, 2023
1 parent 0a33a8f commit 751e4d6
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 73 deletions.
18 changes: 0 additions & 18 deletions config.grafana.traces.yaml

This file was deleted.

8 changes: 7 additions & 1 deletion docker-compose.grafana.logs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ services:
source: ./grafana/loki/loki.yaml
target: /etc/loki/local-config.yaml
- loki-data:/loki
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: ${DDEV_APPROOT}
environment:
- VIRTUAL_HOST=$DDEV_HOSTNAME
- HTTP_EXPOSE=3100:3100
- HTTPS_EXPOSE=3100:3100

agent:
container_name: "ddev-${DDEV_SITENAME}-agent"
Expand All @@ -33,4 +40,3 @@ volumes:
name: "ddev-${DDEV_SITENAME}_web-logs"
loki-data:
name: "ddev-${DDEV_SITENAME}_loki"

17 changes: 12 additions & 5 deletions docker-compose.grafana.metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@ services:
image: prom/prometheus:latest
user: "${UID:-}:${GID:-}"
command:
- '--config.file=/etc/prometheus/prometheus.yaml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
- "--config.file=/etc/prometheus/prometheus.yaml"
- "--storage.tsdb.path=/prometheus"
- "--web.console.libraries=/etc/prometheus/console_libraries"
- "--web.console.templates=/etc/prometheus/consoles"
- "--web.enable-lifecycle"
volumes:
- type: bind
source: ./grafana/prometheus/prometheus.yaml
target: /etc/prometheus/prometheus.yaml
- prometheus-data:/prometheus
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: ${DDEV_APPROOT}
environment:
- VIRTUAL_HOST=$DDEV_HOSTNAME
- HTTP_EXPOSE=9090:9090
- HTTPS_EXPOSE=9090:9090
# Scraping metrics for web services can be configured in the file
# grafana/prometheus/prometheus.yaml

Expand Down
39 changes: 9 additions & 30 deletions docker-compose.grafana.traces.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,22 @@
services:
web:
# Comment this if you don't need to bind trace ports to localhost.
extra_hosts:
- "tempo:127.0.0.1"

tempo:
container_name: "ddev-${DDEV_SITENAME}-tempo"
image: grafana/tempo:latest
# Comment this if you don't need to bind trace ports to localhost.
network_mode: container:ddev-${DDEV_SITENAME}-web
user: "${UID:-}:${GID:-}"
command:
- "-config.file=/etc/tempo.yaml"
volumes:
- type: bind
source: ./grafana/tempo/tempo.yaml
target: /etc/tempo.yaml
- tempo-data:/data
command:
- "-config.file=/etc/tempo.yaml"
depends_on:
- web
# exposed ports is configured in a separate file:
# config.grafana.tracing.yaml

# # Another approach to expose HTTP tracing endpoints to the ddev host.
# # Only HTTP endoinds supported via this approach.
# labels:
# com.ddev.site-name: ${DDEV_SITENAME}
# com.ddev.approot: $DDEV_APPROOT
# environment:
# - VIRTUAL_HOST=$DDEV_HOSTNAME
# # We need also to pass DDEV default ports here via adding the substring:
# # ${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}
# - HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}:8025,4318:4318,9411:9411,14268:14268

grafana:
# Required to connect from Grafana container via named hosts.
# Comment this if you don't need to bind trace ports to localhost.
links:
- "web:tempo"
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: ${DDEV_APPROOT}
environment:
- VIRTUAL_HOST=$DDEV_HOSTNAME
- HTTP_EXPOSE=4318:4318,9411:9411,14268:14268
- HTTPS_EXPOSE=4318:4318,9411:9411,14268:14268

volumes:
tempo-data:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ services:
target: /var/lib/grafana/dashboards
environment:
- VIRTUAL_HOST=$DDEV_HOSTNAME
- HTTP_EXPOSE=3001:3000 # Grafana web interface via HTTP.
- HTTPS_EXPOSE=3000:3000 # Grafana web interface with HTTPS.
- HTTP_EXPOSE=3000:3000
- HTTPS_EXPOSE=3000:3000
1 change: 0 additions & 1 deletion install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pre_install_actions:

project_files:
- config.grafana.logs.yaml
- config.grafana.traces.yaml
- docker-compose.grafana.logs.yaml
- docker-compose.grafana.metrics.yaml
- docker-compose.grafana.traces.yaml
Expand Down
30 changes: 14 additions & 16 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,46 @@ health_checks() {
# To make a test run only on local machines,
# add the `[ -z "$DDEV_CLOUD_ENV" ] && ` prefix to the command.
if [ -n "${GITHUB_ACTIONS:-}" ]; then
DDEV_CLOUD_ENV=1
DDEV_CLOUD_ENV=
else
DDEV_CLOUD_ENV=
fi
# Workaround end.

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

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

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

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

echo "Checking Tempo HTTP receivers ports"
echo 4318
ddev exec "curl -s -o /dev/null http://tempo:4318/"
[ -z "$DDEV_CLOUD_ENV" ] && ddev exec "curl -s -o /dev/null http://localhost:4318/"
[ -z "$DDEV_CLOUD_ENV" ] && curl -s -o /dev/null https://${PROJNAME}.ddev.site:4318/
echo 9411
curl -s -o /dev/null http://${PROJNAME}.ddev.site:4318/
curl -s -o /dev/null https://${PROJNAME}.ddev.site:4318/

ddev exec "curl -s -o /dev/null http://tempo:9411/"
[ -z "$DDEV_CLOUD_ENV" ] && ddev exec "curl -s -o /dev/null http://localhost:9411/"
[ -z "$DDEV_CLOUD_ENV" ] && curl -s -o /dev/null https://${PROJNAME}.ddev.site:9411/
echo 14268
echo 1
curl -s -o /dev/null http://${PROJNAME}.ddev.site:9411/
curl -s -o /dev/null https://${PROJNAME}.ddev.site:9411/

ddev exec "curl -s -o /dev/null http://tempo:14268/"
echo 2
ddev exec "curl -I http://tempo:14268/"
echo 3
[ -z "$DDEV_CLOUD_ENV" ] && ddev exec "curl -s -o /dev/null http://localhost:14268/"
[ -z "$DDEV_CLOUD_ENV" ] && curl -s -o /dev/null https://${PROJNAME}.ddev.site:14268/
echo "Fin"
curl -s -o /dev/null http://${PROJNAME}.ddev.site:14268/
curl -s -o /dev/null https://${PROJNAME}.ddev.site:14268/
}

teardown() {
Expand Down

0 comments on commit 751e4d6

Please sign in to comment.