-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4757 from jsternberg/hack-otelcol
hack: configure the otel-collector for hack/compose
- Loading branch information
Showing
8 changed files
with
132 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Use to set up a dev environment for buildkit. | ||
# Not meant for production deployments. | ||
# Use the same way you would use docker compose. | ||
# | ||
# $ hack/compose up -d --build | ||
# | ||
# Can be extended for local development by adding | ||
# a compose.override.yaml file to the same directory. | ||
# | ||
# Additional config files for extra services can | ||
# also be placed in the same folder and they will | ||
# be automatically ignored by git. | ||
# | ||
# To access the newly created development buildkit, | ||
# use either: | ||
# | ||
# $ buildctl --addr tcp://127.0.0.1:1234 ... | ||
# | ||
# or alternatively configure a new builder with buildx. | ||
# | ||
# $ docker buildx create \ | ||
# --bootstrap \ | ||
# --name dev \ | ||
# --driver remote \ | ||
# tcp://127.0.0.1:1234 | ||
# $ docker buildx --builder dev ... | ||
# Use to set up a dev environment for buildkit using docker compose. | ||
# See composefiles/README.md for more details. | ||
|
||
. $(dirname $0)/util | ||
set -eu -o pipefail | ||
|
||
filesDir=$(dirname $0)/composefiles | ||
|
||
args=(compose '-f' "$filesDir/compose.yaml") | ||
if [ -f "$filesDir/compose.override.yaml" ]; then | ||
args+=('-f' "$filesDir/compose.override.yaml") | ||
fi | ||
|
||
dockerCmd "${args[@]}" "$@" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Buildkit Docker Compose | ||
|
||
The `hack/compose` script provides a convenient development environment for building and testing buildkit with some | ||
useful supporting services and configuration using docker compose to assemble the environment. | ||
This configuration is not meant for production deployments. | ||
|
||
## Usage | ||
|
||
The primary way to use the script is as a substitute to `docker compose`. | ||
|
||
```bash | ||
$ hack/compose up -d | ||
``` | ||
|
||
All arguments to this script will be forwarded to `docker compose`. | ||
This will use the `moby/buildkit:local` image to create a buildkit container. | ||
The image can be either built with `make images` or the `--build` flag can be used. | ||
|
||
```bash | ||
$ hack/compose up -d --build | ||
``` | ||
|
||
To access the newly created development buildkit, use either: | ||
|
||
```bash | ||
$ buildctl --addr docker-container://buildkit-dev ... | ||
``` | ||
|
||
or alternatively configure a new builder with buildx. | ||
|
||
```bash | ||
$ docker buildx create \ | ||
--bootstrap \ | ||
--name dev \ | ||
--driver remote \ | ||
docker-container://buildkit-dev | ||
``` | ||
|
||
## Extending Configuration | ||
|
||
The compose definition can be extended by using `-f $COMPOSE_FILE` to extend the configuration. | ||
These files are in the `extensions` folder. | ||
|
||
As an example, an extension can be used for aiding with buildx metrics development: | ||
|
||
```bash | ||
$ hack/compose -f hack/composefiles/extensions/buildx.yaml up -d --build | ||
``` | ||
|
||
This will modify the `otel-collector` configuration to emit buildx metrics to the debug exporter. | ||
|
||
Some of the files in this directory can be combined and some conflict with each other. In particular, | ||
configurations that modify the `otel-collector` probably conflict with each other. | ||
|
||
## Running the debugger | ||
|
||
The debugger is exposed for the local buildkit when `--build` is used to build the local image. | ||
This can be accessed using delve or any GUI client that uses delve (such as JetBrains GoLand). | ||
|
||
```bash | ||
$ dlv connect localhost:5000 | ||
``` | ||
|
||
More detailed documentation on remote debugging is [here](https://github.com/moby/buildkit/blob/master/docs/dev/remote-debugging.md#connecting-to-the-port-command-line). | ||
|
||
## OpenTelemetry | ||
|
||
OpenTelemetry is automatically configured for traces. | ||
These can be visualized through Jaeger. | ||
|
||
### Traces | ||
|
||
Traces are sent to [Jaeger](http://localhost:16686). | ||
Traces that happen in `buildctl` and `buildx` are automatically sent to `buildkit` which forwards them to Jaeger. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
debug = true | ||
|
||
[grpc] | ||
address = [ "tcp://0.0.0.0:1234" ] | ||
debugAddress = "0.0.0.0:6060" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
services: | ||
otel-collector: | ||
command: >- | ||
--config=file:/etc/otelcol-contrib/config.yaml | ||
--config=file:/etc/otelcol-contrib/buildx.yaml | ||
configs: | ||
- source: otelcol_buildx_config | ||
target: /etc/otelcol-contrib/buildx.yaml | ||
|
||
configs: | ||
otelcol_buildx_config: | ||
content: | | ||
processors: | ||
filter/buildx: | ||
metrics::metric: | ||
- 'instrumentation_scope.name != "github.com/docker/buildx"' | ||
exporters::debug::verbosity: detailed | ||
service::pipelines::metrics::receivers: [otlp] | ||
service::pipelines::metrics::processors: [filter/buildx] | ||
service::pipelines::metrics::exporters: [debug] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
receivers: | ||
otlp: | ||
protocols::grpc::endpoint: 0.0.0.0:4317 | ||
|
||
exporters: | ||
otlp/jaeger: | ||
endpoint: jaeger:4317 | ||
tls::insecure: true | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
exporters: [otlp/jaeger] |