-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial working version Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de> * Fixes based on the review Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
- Loading branch information
1 parent
52fca8c
commit 75c589d
Showing
32 changed files
with
872 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
|
||
- name: Verify | ||
run: make ci |
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,36 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: ["v*"] | ||
|
||
|
||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
|
||
- name: Generate distribution sources | ||
run: make generate-sources | ||
|
||
- name: Log into Quay.io | ||
run: echo "${{ secrets.QUAY_PASSWORD }}" | docker login quay.io -u ${{ secrets.QUAY_USERNAME }} --password-stdin | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,4 @@ | ||
vendor | ||
**/_build | ||
dist/ | ||
.generated-yaml |
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,148 @@ | ||
project_name: opentelemetry-collector-releases | ||
checksum: | ||
name_template: "{{ .ProjectName }}_checksums.txt" | ||
archives: | ||
- id: "opentelemetry-collector" | ||
name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}" | ||
builds: | ||
- "opentelemetry-collector" | ||
- id: "opentelemetry-collector-loadbalancer" | ||
name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}" | ||
builds: | ||
- "opentelemetry-collector-loadbalancer" | ||
builds: | ||
- id: "opentelemetry-collector" | ||
dir: "opentelemetry-collector/_build" | ||
binary: "opentelemetry-collector" | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- darwin | ||
- linux | ||
- windows | ||
goarch: | ||
- 386 | ||
- amd64 | ||
- arm | ||
- arm64 | ||
- s390x | ||
goarm: | ||
- 6 | ||
- 7 | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w | ||
ignore: | ||
- goos: windows | ||
goarch: arm | ||
- id: "opentelemetry-collector-loadbalancer" | ||
dir: "opentelemetry-collector-loadbalancer/_build" | ||
binary: "opentelemetry-collector-loadbalancer" | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- darwin | ||
- linux | ||
- windows | ||
goarch: | ||
- 386 | ||
- amd64 | ||
- arm | ||
- arm64 | ||
- s390x | ||
goarm: | ||
- 6 | ||
- 7 | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w | ||
ignore: | ||
- goos: windows | ||
goarch: arm | ||
docker_manifests: | ||
- name_template: quay.io/jpkroehling/opentelemetry-collector:{{ .Tag }} | ||
image_templates: | ||
- quay.io/jpkroehling/opentelemetry-collector:{{ .Tag }}-amd64 | ||
- name_template: quay.io/jpkroehling/opentelemetry-collector-loadbalancer:{{ .Tag }} | ||
image_templates: | ||
- quay.io/jpkroehling/opentelemetry-collector-loadbalancer:{{ .Tag }}-amd64 | ||
dockers: | ||
- image_templates: | ||
- "quay.io/jpkroehling/opentelemetry-collector:{{ .Tag }}-amd64" | ||
dockerfile: "opentelemetry-collector/Dockerfile" | ||
use: buildx | ||
build_flag_templates: | ||
- "--pull" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.name={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- "--label=org.opencontainers.image.source={{.GitURL}}" | ||
- "--platform=linux/amd64" | ||
extra_files: | ||
- "configs/opentelemetry-collector.yaml" | ||
goarch: amd64 | ||
- image_templates: | ||
- "quay.io/jpkroehling/opentelemetry-collector-loadbalancer:{{ .Tag }}-amd64" | ||
dockerfile: "opentelemetry-collector-loadbalancer/Dockerfile" | ||
use: buildx | ||
build_flag_templates: | ||
- "--pull" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.name={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- "--label=org.opencontainers.image.source={{.GitURL}}" | ||
- "--platform=linux/amd64" | ||
extra_files: | ||
- "configs/opentelemetry-collector-loadbalancer.yaml" | ||
goarch: amd64 | ||
nfpms: | ||
- id: "opentelemetry-collector-loadbalancer" | ||
package_name: "opentelemetry-collector-loadbalancer" | ||
license: Apache 2.0 | ||
description: "OpenTelemetry Collector - opentelemetry-collector-loadbalancer" | ||
formats: | ||
- apk | ||
- deb | ||
- rpm | ||
scripts: | ||
preinstall: "opentelemetry-collector-loadbalancer/preinstall.sh" | ||
postinstall: "opentelemetry-collector-loadbalancer/postinstall.sh" | ||
preremove: "opentelemetry-collector-loadbalancer/preremove.sh" | ||
builds: | ||
- "opentelemetry-collector-loadbalancer" | ||
contents: | ||
- src: "opentelemetry-collector-loadbalancer/opentelemetry-collector-loadbalancer.service" | ||
dst: "/lib/systemd/system/opentelemetry-collector-loadbalancer.service" | ||
- src: "opentelemetry-collector-loadbalancer/opentelemetry-collector-loadbalancer.conf" | ||
dst: "/etc/opentelemetry-collector-loadbalancer/opentelemetry-collector-loadbalancer.conf" | ||
type: "config|noreplace" | ||
- src: "configs/opentelemetry-collector-loadbalancer.yaml" | ||
dst: "/etc/opentelemetry-collector-loadbalancer/config.yaml" | ||
type: config | ||
- id: "opentelemetry-collector" | ||
package_name: "opentelemetry-collector" | ||
license: Apache 2.0 | ||
description: "OpenTelemetry Collector - opentelemetry-collector" | ||
formats: | ||
- apk | ||
- deb | ||
- rpm | ||
scripts: | ||
preinstall: "opentelemetry-collector/preinstall.sh" | ||
postinstall: "opentelemetry-collector/postinstall.sh" | ||
preremove: "opentelemetry-collector/preremove.sh" | ||
builds: | ||
- "opentelemetry-collector" | ||
contents: | ||
- src: "opentelemetry-collector/opentelemetry-collector.service" | ||
dst: "/lib/systemd/system/opentelemetry-collector.service" | ||
- src: "opentelemetry-collector/opentelemetry-collector.conf" | ||
dst: "/etc/opentelemetry-collector/opentelemetry-collector.conf" | ||
type: "config|noreplace" | ||
- src: "configs/opentelemetry-collector.yaml" | ||
dst: "/etc/opentelemetry-collector/config.yaml" | ||
type: config |
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,41 @@ | ||
# Contribution guidelines | ||
|
||
This repository contains a set of resources that ultimately results in OpenTelemetry Collector distributions. This document contains information needed to start contributing to this repository, including how to add new distributions. | ||
|
||
## Understanding this repository | ||
|
||
### Distribution directory | ||
|
||
Each distribution has its own directory at the root of this repository, such as `opentelemetry-collector` or `opentelemetry-collector-loadbalancer`. Within each one of those, you'll find at least two files: | ||
|
||
- `Dockerfile`, determining how to build the container image for this distribution | ||
- `manifest.yaml`, which is used with the [opentelemetry-collector-builder](https://github.com/open-telemetry/opentelemetry-collector-builder) to generate the sources for the distribution. | ||
|
||
Within each distribution, you are expected to be able to build it using the builder, like: | ||
|
||
$ opentelemetry-collector-builder --config manifest.yaml | ||
|
||
You can build all distributions by running: | ||
|
||
$ make build | ||
|
||
If you only interested in generating the sources for the distributions, use: | ||
|
||
$ make generate | ||
|
||
### Distribution configurations | ||
|
||
Due to an incompatibility between `goreleaser` and how this directory is structured, the default configuration files to be included in the container images should be placed under [./configs](./configs) instead of within the distribution's main directory. | ||
|
||
### Scripts | ||
|
||
The main `Makefile` is mostly a wrapper around scripts under the [./scripts](./scripts) directory. | ||
|
||
### goreleaser | ||
|
||
[goreleaser](https://goreleaser.com) plays a big role in producing the final artifacts. Given that the final configuration file for this tool would be huge and would cause relatively big changes for each new distribution, a `Makefile` target exists to generate the `.goreleaser.yaml` for the repository. The `Makefile` contains a list of distributions (`DISTRIBUTIONS`) that is passed down to the script, which will generate snippets based on the templates from `./scripts/goreleaser-templates/`. Adding a new distribution is then only a matter of adding the distribution's directory, plus adding it to the Makefile. Adding a new snippet is only a matter of adding a new template. | ||
|
||
Once there's a change either to the templates or to the list of distributions, a new `.goreleaser` file can be generated with: | ||
|
||
$ make generate-goreleaser | ||
|
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,56 @@ | ||
GO=$(shell which go) | ||
OTELCOL_BUILDER_VERSION ?= 0.30.0 | ||
OTELCOL_BUILDER_DIR ?= ~/bin | ||
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/opentelemetry-collector-builder | ||
|
||
YQ_VERSION ?= 4.11.1 | ||
YQ_DIR ?= ${OTELCOL_BUILDER_DIR} | ||
YQ ?= ${YQ_DIR}/yq | ||
|
||
DISTRIBUTIONS ?= "opentelemetry-collector,opentelemetry-collector-loadbalancer" | ||
|
||
ci: check build | ||
check: ensure-goreleaser-up-to-date | ||
|
||
build: otelcol-builder | ||
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER} -g ${GO} | ||
|
||
generate: generate-sources generate-goreleaser | ||
|
||
generate-goreleaser: yq | ||
@./scripts/generate-goreleaser-config.sh -d "${DISTRIBUTIONS}" -y "${YQ}" | ||
|
||
generate-sources: otelcol-builder | ||
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER} -g ${GO} | ||
|
||
goreleaser-verify: | ||
@goreleaser release --snapshot --rm-dist | ||
|
||
ensure-goreleaser-up-to-date: generate-goreleaser | ||
@git diff -s --exit-code .goreleaser.yaml || (echo "Build failed: The goreleaser templates have changed but the .goreleaser.yaml hasn't. Run 'make generate-goreleaser' and update your PR." && exit 1) | ||
|
||
otelcol-builder: | ||
ifeq (, $(shell which opentelemetry-collector-builder)) | ||
@{ \ | ||
set -e ;\ | ||
echo Installing opentelemetry-collector-builder at $(OTELCOL_BUILDER_DIR);\ | ||
mkdir -p $(OTELCOL_BUILDER_DIR) ;\ | ||
curl -sLo $(OTELCOL_BUILDER) https://github.com/open-telemetry/opentelemetry-collector-builder/releases/download/v$(OTELCOL_BUILDER_VERSION)/opentelemetry-collector-builder_$(OTELCOL_BUILDER_VERSION)_linux_amd64 ;\ | ||
chmod +x $(OTELCOL_BUILDER) ;\ | ||
} | ||
else | ||
OTELCOL_BUILDER=$(shell which opentelemetry-collector-builder) | ||
endif | ||
|
||
yq: | ||
ifeq (, $(shell which yq)) | ||
@{ \ | ||
set -e ;\ | ||
echo Installing yq at $(YQ_DIR);\ | ||
mkdir -p $(YQ_DIR) ;\ | ||
curl -sLo $(YQ) https://github.com/mikefarah/yq/releases/download/v$(YQ_VERSION)/yq_linux_amd64 ;\ | ||
chmod +x $(YQ) ;\ | ||
} | ||
else | ||
YQ=$(shell which yq) | ||
endif |
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,17 @@ | ||
OpenTelemetry Collector distributions | ||
=== | ||
|
||
This repository assembles OpenTelemetry Collector distributions, such as the "core" distribution, or "contrib". It may contain non-official distributions, focused on specific use-cases, such as the load-balancer. | ||
|
||
Each distribution contains: | ||
|
||
- Binaries for a multitude of platforms and architectures | ||
- Multi-arch container images | ||
- Packages to be used with Linux distributions (apk, RPM, deb), Mac OS (brew) | ||
|
||
More details about each individual distribution can be seen in its own readme files. | ||
|
||
Current list of distributions: | ||
|
||
- [OpenTelemetry Collector (also known as "core")](./opentelemetry-collector) | ||
- [Load balancer](./opentelemetry-collector-loadbalancer) |
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,3 @@ | ||
This file contains the default configuration files for the container images. Due to a problem with goreleaser, these cannot be in the a directory with the same name as the binary for that image. For intance, if the binary is `opentelemetry-collector`, the container image cannot include anything from a directory named `opentelemetry-collector`, which is exactly what we have. | ||
|
||
This problem is solvable in a better way, but for now, storing the configs in this directory is the simplest solution that works. |
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,35 @@ | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
endpoint: localhost:4317 | ||
|
||
processors: | ||
|
||
exporters: | ||
loadbalancing: | ||
protocol: | ||
otlp: | ||
timeout: 1s | ||
resolver: | ||
static: | ||
hostnames: | ||
- backend-1:4317 | ||
- backend-2:4317 | ||
- backend-3:4317 | ||
- backend-4:4317 | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: | ||
- otlp | ||
processors: [] | ||
exporters: | ||
- loadbalancing | ||
logs: | ||
receivers: | ||
- otlp | ||
processors: [] | ||
exporters: | ||
- loadbalancing |
Oops, something went wrong.