Skip to content

Commit

Permalink
Add a Kubernetes Distribution (#507)
Browse files Browse the repository at this point in the history
* Add a k8s distribution

* Remove logging exporter

* Update ports

* Remove prometheus scrape from default config

* Add the fileexporter

* Remove httpforwarderextension

* Explain docker ports

* Reduce k8s distro artifacts

* Fix makefile

* Update manifest to be v0.97.0

* Update when CI runs

* Allow matrix to by dynamic

* remove unneeded file

* Remove default config

* Fix dockerfile

* Add additional code owners for k8s distro

* Apply feedback

* Apply feedback
  • Loading branch information
TylerHelmuth authored Apr 10, 2024
1 parent 82f01d1 commit cc6bd2d
Show file tree
Hide file tree
Showing 15 changed files with 359 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
#

* @open-telemetry/collector-contrib-approvers

distributions/otelcol-k8s/ @open-telemetry/collector-contrib-approvers @open-telemetry/helm-approvers @open-telemetry/operator-approvers
10 changes: 8 additions & 2 deletions .github/workflows/base-ci-goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ on:
distribution:
required: true
type: string
goos:
required: true
type: string
goarch:
required: true
type: string

jobs:
check-goreleaser:
strategy:
matrix:
GOOS: [ linux, windows, darwin ]
GOARCH: [ "386", amd64, arm64, ppc64le, arm, s390x ]
GOOS: ${{ fromJSON( inputs.goos) }}
GOARCH: ${{ fromJSON( inputs.goarch) }}
exclude:
- GOOS: darwin
GOARCH: "386"
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/base-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ on:
distribution:
required: true
type: string
goos:
required: true
type: string
goarch:
required: true
type: string

jobs:
prepare:
strategy:
matrix:
GOOS: [linux, windows, darwin]
GOARCH: ["386", amd64, arm64, ppc64le, arm, s390x]
GOOS: ${{ fromJSON( inputs.goos) }}
GOARCH: ${{ fromJSON( inputs.goarch) }}
exclude:
- GOOS: darwin
GOARCH: "386"
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/ci-goreleaser-contrib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,29 @@ on:
branches: [main]
paths:
- "distributions/otelcol-contrib/**"
- "cmd/**"
- ".github/**"
- "scripts/**"
- "Makefile"
- "go.mod"
- "go.sum"
pull_request:
branches: [main]
paths:
- "distributions/otelcol-contrib/**"
- "cmd/**"
- ".github/**"
- "scripts/**"
- "Makefile"
- "go.mod"
- "go.sum"

jobs:
check-goreleaser:
name: Continuous Integration - Contrib - GoReleaser
uses: ./.github/workflows/base-ci-goreleaser.yaml
with:
distribution: otelcol-contrib
goos: '[ "linux", "windows", "darwin" ]'
goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]'
secrets: inherit
14 changes: 14 additions & 0 deletions .github/workflows/ci-goreleaser-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@ on:
branches: [main]
paths:
- "distributions/otelcol/**"
- "cmd/**"
- ".github/**"
- "scripts/**"
- "Makefile"
- "go.mod"
- "go.sum"
pull_request:
branches: [main]
paths:
- "distributions/otelcol/**"
- "cmd/**"
- ".github/**"
- "scripts/**"
- "Makefile"
- "go.mod"
- "go.sum"


jobs:
Expand All @@ -17,4 +29,6 @@ jobs:
uses: ./.github/workflows/base-ci-goreleaser.yaml
with:
distribution: otelcol
goos: '[ "linux", "windows", "darwin" ]'
goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]'
secrets: inherit
33 changes: 33 additions & 0 deletions .github/workflows/ci-goreleaser-k8s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Continuous Integration - k8s - GoReleaser

on:
push:
branches: [main]
paths:
- "distributions/otelcol-k8s/**"
- "cmd/**"
- ".github/**"
- "scripts/**"
- "Makefile"
- "go.mod"
- "go.sum"
pull_request:
branches: [main]
paths:
- "distributions/otelcol-k8s/**"
- "cmd/**"
- ".github/**"
- "scripts/**"
- "Makefile"
- "go.mod"
- "go.sum"

jobs:
check-goreleaser:
name: Continuous Integration - k8s - GoReleaser
uses: ./.github/workflows/base-ci-goreleaser.yaml
with:
distribution: otelcol-k8s
goos: '[ "linux" ]'
goarch: '[ "amd64", "arm64", "ppc64le", "s390x" ]'
secrets: inherit
4 changes: 3 additions & 1 deletion .github/workflows/release-contrib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ jobs:
uses: ./.github/workflows/base-release.yaml
with:
distribution: otelcol-contrib
goos: '[ "linux", "windows", "darwin" ]'
goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]'
secrets: inherit
permissions: write-all
permissions: write-all
2 changes: 2 additions & 0 deletions .github/workflows/release-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ jobs:
uses: ./.github/workflows/base-release.yaml
with:
distribution: otelcol
goos: '[ "linux", "windows", "darwin" ]'
goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]'
secrets: inherit
permissions: write-all
16 changes: 16 additions & 0 deletions .github/workflows/release-k8s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Release k8s

on:
push:
tags: ["v*"]

jobs:
release:
name: Release Contrib
uses: ./.github/workflows/base-release.yaml
with:
distribution: otelcol-k8s
goos: '[ "linux" ]'
goarch: '[ "amd64", "arm64", "ppc64le", "s390x" ]'
secrets: inherit
permissions: write-all
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ OTELCOL_BUILDER_VERSION ?= 0.97.0
OTELCOL_BUILDER_DIR ?= ${HOME}/bin
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb

DISTRIBUTIONS ?= "otelcol,otelcol-contrib"
DISTRIBUTIONS ?= "otelcol,otelcol-contrib,otelcol-k8s"
GEN_CONFIG_DISTRIBUTIONS ?= "otelcol,otelcol-contrib"

ci: check build
check: ensure-goreleaser-up-to-date
Expand All @@ -16,7 +17,7 @@ build: go ocb
generate: generate-sources generate-goreleaser

generate-goreleaser: go
@./scripts/generate-goreleaser.sh -d "${DISTRIBUTIONS}" -g ${GO}
@./scripts/generate-goreleaser.sh -d "${GEN_CONFIG_DISTRIBUTIONS}" -g ${GO}

generate-sources: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER} -g ${GO}
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

> :warning: **Important note:** Git tags in this repository may change at any time to fix any issues found during a release. They are only meant to trigger Github releases and should not be relied upon.
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.
This repository assembles OpenTelemetry Collector distributions, such as the "core" distribution, or "contrib".

Each distribution contains:

- Binaries for a multitude of platforms and architectures (at least linux_amd64, linux_arm64, windows_amd64 and darwin_arm64)
- Multi-arch container images (at least amd64 and arm64)
- 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) for the above-mentioned architectures

More details about each individual distribution can be seen in its own readme files.
Expand All @@ -16,3 +16,4 @@ Current list of distributions:

- [OpenTelemetry Collector (also known as "otelcol")](./distributions/otelcol)
- [OpenTelemetry Collector Contrib (also known as "otelcol-contrib")](./distributions/otelcol-contrib)
- [OpenTelemetry Collector for Kubernetes (also known as "otelcol-k8s")](./distributions/otelcol-k8s)
146 changes: 146 additions & 0 deletions distributions/otelcol-k8s/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
partial:
by: target
project_name: opentelemetry-collector-releases
env:
- COSIGN_YES=true
builds:
- id: otelcol-k8s
goos:
- linux
goarch:
- amd64
- arm64
- ppc64le
- s390x
dir: _build
binary: otelcol-k8s
ldflags:
- -s
- -w
flags:
- -trimpath
env:
- CGO_ENABLED=0
archives:
- id: otelcol-k8s
builds:
- otelcol-k8s
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
checksum:
name_template: '{{ .ProjectName }}_otelcol-k8s_checksums.txt'
dockers:
- goos: linux
goarch: amd64
dockerfile: Dockerfile
image_templates:
- otel/opentelemetry-collector-k8s:{{ .Version }}-amd64
- otel/opentelemetry-collector-k8s:latest-amd64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-amd64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-amd64
build_flag_templates:
- --pull
- --platform=linux/amd64
- --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}}
use: buildx
- goos: linux
goarch: arm64
dockerfile: Dockerfile
image_templates:
- otel/opentelemetry-collector-k8s:{{ .Version }}-arm64
- otel/opentelemetry-collector-k8s:latest-arm64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-arm64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-arm64
build_flag_templates:
- --pull
- --platform=linux/arm64
- --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}}
use: buildx
- goos: linux
goarch: ppc64le
dockerfile: Dockerfile
image_templates:
- otel/opentelemetry-collector-k8s:{{ .Version }}-ppc64le
- otel/opentelemetry-collector-k8s:latest-ppc64le
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-ppc64le
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-ppc64le
build_flag_templates:
- --pull
- --platform=linux/ppc64le
- --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}}
use: buildx
- goos: linux
goarch: s390x
dockerfile: Dockerfile
image_templates:
- otel/opentelemetry-collector-k8s:{{ .Version }}-s390x
- otel/opentelemetry-collector-k8s:latest-s390x
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-s390x
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-s390x
build_flag_templates:
- --pull
- --platform=linux/s390x
- --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}}
use: buildx
docker_manifests:
- name_template: otel/opentelemetry-collector-k8s:{{ .Version }}
image_templates:
- otel/opentelemetry-collector-k8s:{{ .Version }}-amd64
- otel/opentelemetry-collector-k8s:{{ .Version }}-arm64
- otel/opentelemetry-collector-k8s:{{ .Version }}-ppc64le
- otel/opentelemetry-collector-k8s:{{ .Version }}-s390x
- name_template: otel/opentelemetry-collector-k8s:latest
image_templates:
- otel/opentelemetry-collector-k8s:latest-amd64
- otel/opentelemetry-collector-k8s:latest-arm64
- otel/opentelemetry-collector-k8s:latest-ppc64le
- otel/opentelemetry-collector-k8s:latest-s390x
- name_template: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}
image_templates:
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-amd64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-arm64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-ppc64le
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-s390x
- name_template: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest
image_templates:
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-amd64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-arm64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-ppc64le
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-s390x
signs:
- cmd: cosign
args:
- sign-blob
- --output-signature
- ${artifact}.sig
- --output-certificate
- ${artifact}.pem
- ${artifact}
signature: ${artifact}.sig
artifacts: all
certificate: ${artifact}.pem
docker_signs:
- args:
- sign
- ${artifact}
artifacts: all
sboms:
- id: archive
artifacts: archive
- id: package
artifacts: package
17 changes: 17 additions & 0 deletions distributions/otelcol-k8s/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM alpine:3.19 as certs
RUN apk --update add ca-certificates

FROM scratch

ARG USER_UID=10001
USER ${USER_UID}

COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --chmod=755 otelcol-k8s /otelcol-k8s
ENTRYPOINT ["/otelcol-k8s"]
# `4137` and `4318`: OTLP
# `55678`: OpenCensus
# `55679`: zpages
# `6831`, `14268`, and `14250`: Jaeger
# `9411`: Zipkin
EXPOSE 4317 4318 55678 55679 6831 14268 14250 9411
Loading

0 comments on commit cc6bd2d

Please sign in to comment.