mirror of https://github.com/grafana/loki
Adding `make debug` support to build debug binaries and debug containers which wrap the binary with delve and allow for remote debugging
parent
42e5bf1af8
commit
916124b9ea
@ -0,0 +1,17 @@ |
||||
FROM alpine:3.9 |
||||
RUN apk add --update --no-cache ca-certificates |
||||
COPY loki-debug /bin/loki-debug |
||||
ADD dlv /usr/bin |
||||
COPY loki-local-config.yaml /etc/loki/local-config.yaml |
||||
EXPOSE 80 |
||||
|
||||
# Expose 40000 for delve |
||||
EXPOSE 40000 |
||||
|
||||
# Allow delve to run on Alpine based containers. |
||||
RUN apk add --no-cache libc6-compat |
||||
|
||||
# Run delve, ending with -- because we pass params via kubernetes, per the docs: |
||||
# Pass flags to the program you are debugging using --, for example:` |
||||
# dlv exec ./hello -- server --config conf/config.toml` |
||||
ENTRYPOINT ["/usr/bin/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "exec", "/bin/loki-debug", "--"] |
||||
@ -0,0 +1,17 @@ |
||||
FROM alpine:3.9 |
||||
RUN apk add --update --no-cache ca-certificates |
||||
ADD promtail-debug /usr/bin |
||||
ADD dlv /usr/bin |
||||
COPY promtail-local-config.yaml /etc/promtail/local-config.yaml |
||||
COPY promtail-docker-config.yaml /etc/promtail/docker-config.yaml |
||||
|
||||
# Expose 40000 for delve |
||||
EXPOSE 40000 |
||||
|
||||
# Allow delve to run on Alpine based containers. |
||||
RUN apk add --no-cache libc6-compat |
||||
|
||||
# Run delve, ending with -- because we pass params via kubernetes, per the docs: |
||||
# Pass flags to the program you are debugging using --, for example:` |
||||
# dlv exec ./hello -- server --config conf/config.toml` |
||||
ENTRYPOINT ["/usr/bin/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "exec", "/usr/bin/promtail-debug", "--"] |
||||
@ -0,0 +1,57 @@ |
||||
## Debug images |
||||
|
||||
To build debug images run |
||||
|
||||
```shell |
||||
make debug |
||||
``` |
||||
|
||||
You can use the `docker-compose.yaml` in this directory to launch the debug versions of the image in docker |
||||
|
||||
|
||||
## Promtail in kubernetes |
||||
|
||||
If you want to debug promtail in kubernetes, I have done so with the ksonnet setup: |
||||
|
||||
```shell |
||||
ks init promtail |
||||
cd promtail |
||||
ks env add promtail |
||||
jb init |
||||
jb install github.com/grafana/loki/production/ksonnet/promtail |
||||
vi environments/promtail/main.jsonnet |
||||
``` |
||||
|
||||
Replace the contents with: |
||||
|
||||
```jsonnet |
||||
local promtail = import 'promtail/promtail.libsonnet'; |
||||
|
||||
|
||||
promtail + { |
||||
_images+:: { |
||||
promtail: 'grafana/promtail-debug:latest', |
||||
}, |
||||
_config+:: { |
||||
namespace: 'default', |
||||
|
||||
promtail_config+: { |
||||
external_labels+: { |
||||
cluster: 'some_cluster_name', |
||||
}, |
||||
scheme: 'https', |
||||
hostname: 'hostname', |
||||
username: 'username', |
||||
password: 'password', |
||||
}, |
||||
}, |
||||
} |
||||
``` |
||||
|
||||
change the `some_cluster_name` to anything meaningful to help find your logs in loki |
||||
|
||||
also update the `hostname`, `username`, and `password` for your loki instance. |
||||
|
||||
## Loki in kubernetes |
||||
|
||||
Haven't tried this yet, it works from docker-compose so it should run in kubernetes just fine also. |
||||
@ -0,0 +1,37 @@ |
||||
version: "3" |
||||
|
||||
networks: |
||||
loki: |
||||
|
||||
services: |
||||
loki: |
||||
# this is required according to https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code#linuxdocker |
||||
security_opt: |
||||
- seccomp:unconfined |
||||
image: grafana/loki-debug:latest |
||||
ports: |
||||
- "40000:40000" |
||||
- "3100:3100" |
||||
command: -config.file=/etc/loki/local-config.yaml |
||||
networks: |
||||
- loki |
||||
|
||||
promtail: |
||||
# this is required according to https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code#linuxdocker |
||||
security_opt: |
||||
- seccomp:unconfined |
||||
image: grafana/promtail-debug:latest |
||||
ports: |
||||
- "40100:40000" |
||||
volumes: |
||||
- /var/log:/var/log |
||||
command: -config.file=/etc/promtail/docker-config.yaml |
||||
networks: |
||||
- loki |
||||
|
||||
grafana: |
||||
image: grafana/grafana:master |
||||
ports: |
||||
- "3000:3000" |
||||
networks: |
||||
- loki |
||||
Loading…
Reference in new issue