Skip to content

Commit

Permalink
Add a k8s distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHelmuth committed Mar 21, 2024
1 parent 52c80c0 commit 7322e3f
Show file tree
Hide file tree
Showing 13 changed files with 509 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/workflows/ci-goreleaser-k8s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Continuous Integration - k8s - GoReleaser

on:
push:
branches: [main]
paths:
- "distributions/otelcol-k8s/**"
pull_request:
branches: [main]
paths:
- "distributions/otelcol-k8s/**"

jobs:
check-goreleaser:
name: Continuous Integration - k8s - GoReleaser
uses: ./.github/workflows/base-ci-goreleaser.yaml
with:
distribution: otelcol-k8s
secrets: inherit
14 changes: 14 additions & 0 deletions .github/workflows/release-k8s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release k8s

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

jobs:
release:
name: Release Contrib
uses: ./.github/workflows/base-release.yaml
with:
distribution: otelcol-k8s
secrets: inherit
permissions: write-all
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ OTELCOL_BUILDER_VERSION ?= 0.96.0
OTELCOL_BUILDER_DIR ?= ${HOME}/bin
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb

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

ci: check build
check: ensure-goreleaser-up-to-date
Expand Down
245 changes: 245 additions & 0 deletions distributions/otelcol-k8s/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
partial:
by: target
project_name: opentelemetry-collector-releases
env:
- COSIGN_YES=true
builds:
- id: otelcol-k8s
goos:
- darwin
- linux
- windows
goarch:
- "386"
- amd64
- arm
- arm64
- ppc64le
- s390x
goarm:
- "7"
ignore:
- goos: darwin
goarch: "386"
- goos: darwin
goarch: arm
- goos: darwin
goarch: s390x
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
- goos: windows
goarch: 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 }}'
nfpms:
- package_name: otelcol-k8s
contents:
- src: otelcol-k8s.service
dst: /lib/systemd/system/otelcol-k8s.service
- src: otelcol-k8s.conf
dst: /etc/otelcol-k8s/otelcol-k8s.conf
type: config|noreplace
- src: config.yaml
dst: /etc/otelcol-k8s/config.yaml
type: config
scripts:
preinstall: preinstall.sh
postinstall: postinstall.sh
preremove: preremove.sh
id: otelcol-k8s
builds:
- otelcol-k8s
formats:
- apk
- deb
- rpm
maintainer: The OpenTelemetry Collector maintainers <[email protected]>
description: OpenTelemetry Collector - otelcol-k8s
license: Apache 2.0
checksum:
name_template: '{{ .ProjectName }}_otelcol-k8s_checksums.txt'
dockers:
- goos: linux
goarch: "386"
dockerfile: Dockerfile
image_templates:
- otel/opentelemetry-collector-k8s:{{ .Version }}-386
- otel/opentelemetry-collector-k8s:latest-386
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-386
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-386
extra_files:
- config.yaml
build_flag_templates:
- --pull
- --platform=linux/386
- --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: 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
extra_files:
- config.yaml
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: arm
goarm: "7"
dockerfile: Dockerfile
image_templates:
- otel/opentelemetry-collector-k8s:{{ .Version }}-armv7
- otel/opentelemetry-collector-k8s:latest-armv7
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-armv7
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-armv7
extra_files:
- config.yaml
build_flag_templates:
- --pull
- --platform=linux/arm/v7
- --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
extra_files:
- config.yaml
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
extra_files:
- config.yaml
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
extra_files:
- config.yaml
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 }}-386
- otel/opentelemetry-collector-k8s:{{ .Version }}-amd64
- otel/opentelemetry-collector-k8s:{{ .Version }}-armv7
- 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-386
- otel/opentelemetry-collector-k8s:latest-amd64
- otel/opentelemetry-collector-k8s:latest-armv7
- 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 }}-386
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-amd64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:{{ .Version }}-armv7
- 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-386
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-amd64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:latest-armv7
- 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
14 changes: 14 additions & 0 deletions distributions/otelcol-k8s/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM alpine:3.16 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
COPY config.yaml /etc/otelcol-k8s/config.yaml
ENTRYPOINT ["/otelcol-k8s"]
CMD ["--config", "/etc/otelcol-k8s/config.yaml"]
EXPOSE 4317 55678 55679
19 changes: 19 additions & 0 deletions distributions/otelcol-k8s/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# OpenTelemetry Collector Kubernetes Distro

This distribution is made specifically to be used in a Kubernetes Cluster to monitor Kubernetes and services running in Kubernetes. It contains a subset of components from [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector) and [OpenTelemetry Collector Contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib).

## Components

The full list of components is available in the [manifest](manifest.yaml)

### Rules for Component Inclusion

- Only includes components from Contrib and Core.
- Only components that are Alpha or higher.
- The logging exporter is an exception.
- All receivers must facilitate the collection of data that is generated by Kubernetes or services running in Kubernetes
- Although you could run a collector in Kubernetes to reach out to any endpoint, this distribution is not targeting that use case. This distribution is for monitoring Kubernetes and the processes it runs.
- All components must be vendor-neutral.
- Only exporters that use OTLP are allowed.
- The debug exporter and logging exporter are an exception.
- All technologies OTel promised to support will be included as receivers. Specifically this means the `jaegerreceiver`, `zipkinreceiver`, `opencensusreceiver`, and `prometheusreceiver` will be included.
46 changes: 46 additions & 0 deletions distributions/otelcol-k8s/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# To limit exposure to denial of service attacks, change the host in endpoints below from 0.0.0.0 to a specific network interface.
# See https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks

extensions:
health_check:

receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318

# Collect own metrics
prometheus:
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 10s
static_configs:
- targets: ['0.0.0.0:8888']

processors:
memory_limiter:
batch:

exporters:
debug:
verbosity: detailed

service:
extensions: [health_check]
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [debug]
metrics:
receivers: [otlp, prometheus]
processors: [memory_limiter, batch]
exporters: [debug]
logs:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [debug]
Loading

0 comments on commit 7322e3f

Please sign in to comment.