Skip to content

Commit 75c589d

Browse files
authored
Initial working version (#2)
* Initial working version Signed-off-by: Juraci Paixão Kröhling <[email protected]> * Fixes based on the review Signed-off-by: Juraci Paixão Kröhling <[email protected]>
1 parent 52fca8c commit 75c589d

32 files changed

+872
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
name: Build
12+
runs-on: ubuntu-20.04
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.16
23+
24+
- name: Verify
25+
run: make ci

.github/workflows/release.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
8+
9+
jobs:
10+
release:
11+
name: Release
12+
runs-on: ubuntu-20.04
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.16
23+
24+
- name: Generate distribution sources
25+
run: make generate-sources
26+
27+
- name: Log into Quay.io
28+
run: echo "${{ secrets.QUAY_PASSWORD }}" | docker login quay.io -u ${{ secrets.QUAY_USERNAME }} --password-stdin
29+
30+
- name: Run GoReleaser
31+
uses: goreleaser/goreleaser-action@v2
32+
with:
33+
version: latest
34+
args: release --rm-dist
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vendor
2+
**/_build
3+
dist/
4+
.generated-yaml

.goreleaser.yaml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
project_name: opentelemetry-collector-releases
2+
checksum:
3+
name_template: "{{ .ProjectName }}_checksums.txt"
4+
archives:
5+
- id: "opentelemetry-collector"
6+
name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
7+
builds:
8+
- "opentelemetry-collector"
9+
- id: "opentelemetry-collector-loadbalancer"
10+
name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
11+
builds:
12+
- "opentelemetry-collector-loadbalancer"
13+
builds:
14+
- id: "opentelemetry-collector"
15+
dir: "opentelemetry-collector/_build"
16+
binary: "opentelemetry-collector"
17+
env:
18+
- CGO_ENABLED=0
19+
goos:
20+
- darwin
21+
- linux
22+
- windows
23+
goarch:
24+
- 386
25+
- amd64
26+
- arm
27+
- arm64
28+
- s390x
29+
goarm:
30+
- 6
31+
- 7
32+
flags:
33+
- -trimpath
34+
ldflags:
35+
- -s -w
36+
ignore:
37+
- goos: windows
38+
goarch: arm
39+
- id: "opentelemetry-collector-loadbalancer"
40+
dir: "opentelemetry-collector-loadbalancer/_build"
41+
binary: "opentelemetry-collector-loadbalancer"
42+
env:
43+
- CGO_ENABLED=0
44+
goos:
45+
- darwin
46+
- linux
47+
- windows
48+
goarch:
49+
- 386
50+
- amd64
51+
- arm
52+
- arm64
53+
- s390x
54+
goarm:
55+
- 6
56+
- 7
57+
flags:
58+
- -trimpath
59+
ldflags:
60+
- -s -w
61+
ignore:
62+
- goos: windows
63+
goarch: arm
64+
docker_manifests:
65+
- name_template: quay.io/jpkroehling/opentelemetry-collector:{{ .Tag }}
66+
image_templates:
67+
- quay.io/jpkroehling/opentelemetry-collector:{{ .Tag }}-amd64
68+
- name_template: quay.io/jpkroehling/opentelemetry-collector-loadbalancer:{{ .Tag }}
69+
image_templates:
70+
- quay.io/jpkroehling/opentelemetry-collector-loadbalancer:{{ .Tag }}-amd64
71+
dockers:
72+
- image_templates:
73+
- "quay.io/jpkroehling/opentelemetry-collector:{{ .Tag }}-amd64"
74+
dockerfile: "opentelemetry-collector/Dockerfile"
75+
use: buildx
76+
build_flag_templates:
77+
- "--pull"
78+
- "--label=org.opencontainers.image.created={{.Date}}"
79+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
80+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
81+
- "--label=org.opencontainers.image.version={{.Version}}"
82+
- "--label=org.opencontainers.image.source={{.GitURL}}"
83+
- "--platform=linux/amd64"
84+
extra_files:
85+
- "configs/opentelemetry-collector.yaml"
86+
goarch: amd64
87+
- image_templates:
88+
- "quay.io/jpkroehling/opentelemetry-collector-loadbalancer:{{ .Tag }}-amd64"
89+
dockerfile: "opentelemetry-collector-loadbalancer/Dockerfile"
90+
use: buildx
91+
build_flag_templates:
92+
- "--pull"
93+
- "--label=org.opencontainers.image.created={{.Date}}"
94+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
95+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
96+
- "--label=org.opencontainers.image.version={{.Version}}"
97+
- "--label=org.opencontainers.image.source={{.GitURL}}"
98+
- "--platform=linux/amd64"
99+
extra_files:
100+
- "configs/opentelemetry-collector-loadbalancer.yaml"
101+
goarch: amd64
102+
nfpms:
103+
- id: "opentelemetry-collector-loadbalancer"
104+
package_name: "opentelemetry-collector-loadbalancer"
105+
license: Apache 2.0
106+
description: "OpenTelemetry Collector - opentelemetry-collector-loadbalancer"
107+
formats:
108+
- apk
109+
- deb
110+
- rpm
111+
scripts:
112+
preinstall: "opentelemetry-collector-loadbalancer/preinstall.sh"
113+
postinstall: "opentelemetry-collector-loadbalancer/postinstall.sh"
114+
preremove: "opentelemetry-collector-loadbalancer/preremove.sh"
115+
builds:
116+
- "opentelemetry-collector-loadbalancer"
117+
contents:
118+
- src: "opentelemetry-collector-loadbalancer/opentelemetry-collector-loadbalancer.service"
119+
dst: "/lib/systemd/system/opentelemetry-collector-loadbalancer.service"
120+
- src: "opentelemetry-collector-loadbalancer/opentelemetry-collector-loadbalancer.conf"
121+
dst: "/etc/opentelemetry-collector-loadbalancer/opentelemetry-collector-loadbalancer.conf"
122+
type: "config|noreplace"
123+
- src: "configs/opentelemetry-collector-loadbalancer.yaml"
124+
dst: "/etc/opentelemetry-collector-loadbalancer/config.yaml"
125+
type: config
126+
- id: "opentelemetry-collector"
127+
package_name: "opentelemetry-collector"
128+
license: Apache 2.0
129+
description: "OpenTelemetry Collector - opentelemetry-collector"
130+
formats:
131+
- apk
132+
- deb
133+
- rpm
134+
scripts:
135+
preinstall: "opentelemetry-collector/preinstall.sh"
136+
postinstall: "opentelemetry-collector/postinstall.sh"
137+
preremove: "opentelemetry-collector/preremove.sh"
138+
builds:
139+
- "opentelemetry-collector"
140+
contents:
141+
- src: "opentelemetry-collector/opentelemetry-collector.service"
142+
dst: "/lib/systemd/system/opentelemetry-collector.service"
143+
- src: "opentelemetry-collector/opentelemetry-collector.conf"
144+
dst: "/etc/opentelemetry-collector/opentelemetry-collector.conf"
145+
type: "config|noreplace"
146+
- src: "configs/opentelemetry-collector.yaml"
147+
dst: "/etc/opentelemetry-collector/config.yaml"
148+
type: config

CONTRIBUTING.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Contribution guidelines
2+
3+
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.
4+
5+
## Understanding this repository
6+
7+
### Distribution directory
8+
9+
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:
10+
11+
- `Dockerfile`, determining how to build the container image for this distribution
12+
- `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.
13+
14+
Within each distribution, you are expected to be able to build it using the builder, like:
15+
16+
$ opentelemetry-collector-builder --config manifest.yaml
17+
18+
You can build all distributions by running:
19+
20+
$ make build
21+
22+
If you only interested in generating the sources for the distributions, use:
23+
24+
$ make generate
25+
26+
### Distribution configurations
27+
28+
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.
29+
30+
### Scripts
31+
32+
The main `Makefile` is mostly a wrapper around scripts under the [./scripts](./scripts) directory.
33+
34+
### goreleaser
35+
36+
[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.
37+
38+
Once there's a change either to the templates or to the list of distributions, a new `.goreleaser` file can be generated with:
39+
40+
$ make generate-goreleaser
41+

Makefile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
GO=$(shell which go)
2+
OTELCOL_BUILDER_VERSION ?= 0.30.0
3+
OTELCOL_BUILDER_DIR ?= ~/bin
4+
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/opentelemetry-collector-builder
5+
6+
YQ_VERSION ?= 4.11.1
7+
YQ_DIR ?= ${OTELCOL_BUILDER_DIR}
8+
YQ ?= ${YQ_DIR}/yq
9+
10+
DISTRIBUTIONS ?= "opentelemetry-collector,opentelemetry-collector-loadbalancer"
11+
12+
ci: check build
13+
check: ensure-goreleaser-up-to-date
14+
15+
build: otelcol-builder
16+
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER} -g ${GO}
17+
18+
generate: generate-sources generate-goreleaser
19+
20+
generate-goreleaser: yq
21+
@./scripts/generate-goreleaser-config.sh -d "${DISTRIBUTIONS}" -y "${YQ}"
22+
23+
generate-sources: otelcol-builder
24+
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER} -g ${GO}
25+
26+
goreleaser-verify:
27+
@goreleaser release --snapshot --rm-dist
28+
29+
ensure-goreleaser-up-to-date: generate-goreleaser
30+
@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)
31+
32+
otelcol-builder:
33+
ifeq (, $(shell which opentelemetry-collector-builder))
34+
@{ \
35+
set -e ;\
36+
echo Installing opentelemetry-collector-builder at $(OTELCOL_BUILDER_DIR);\
37+
mkdir -p $(OTELCOL_BUILDER_DIR) ;\
38+
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 ;\
39+
chmod +x $(OTELCOL_BUILDER) ;\
40+
}
41+
else
42+
OTELCOL_BUILDER=$(shell which opentelemetry-collector-builder)
43+
endif
44+
45+
yq:
46+
ifeq (, $(shell which yq))
47+
@{ \
48+
set -e ;\
49+
echo Installing yq at $(YQ_DIR);\
50+
mkdir -p $(YQ_DIR) ;\
51+
curl -sLo $(YQ) https://github.com/mikefarah/yq/releases/download/v$(YQ_VERSION)/yq_linux_amd64 ;\
52+
chmod +x $(YQ) ;\
53+
}
54+
else
55+
YQ=$(shell which yq)
56+
endif

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
OpenTelemetry Collector distributions
2+
===
3+
4+
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.
5+
6+
Each distribution contains:
7+
8+
- Binaries for a multitude of platforms and architectures
9+
- Multi-arch container images
10+
- Packages to be used with Linux distributions (apk, RPM, deb), Mac OS (brew)
11+
12+
More details about each individual distribution can be seen in its own readme files.
13+
14+
Current list of distributions:
15+
16+
- [OpenTelemetry Collector (also known as "core")](./opentelemetry-collector)
17+
- [Load balancer](./opentelemetry-collector-loadbalancer)

configs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
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.
2+
3+
This problem is solvable in a better way, but for now, storing the configs in this directory is the simplest solution that works.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
receivers:
2+
otlp:
3+
protocols:
4+
grpc:
5+
endpoint: localhost:4317
6+
7+
processors:
8+
9+
exporters:
10+
loadbalancing:
11+
protocol:
12+
otlp:
13+
timeout: 1s
14+
resolver:
15+
static:
16+
hostnames:
17+
- backend-1:4317
18+
- backend-2:4317
19+
- backend-3:4317
20+
- backend-4:4317
21+
22+
service:
23+
pipelines:
24+
traces:
25+
receivers:
26+
- otlp
27+
processors: []
28+
exporters:
29+
- loadbalancing
30+
logs:
31+
receivers:
32+
- otlp
33+
processors: []
34+
exporters:
35+
- loadbalancing

0 commit comments

Comments
 (0)