From c24535a6800d2686c484cbe8449e1d30db948943 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Thu, 21 Mar 2024 09:44:13 -0600 Subject: [PATCH] Add a k8s distribution --- .github/workflows/ci-goreleaser-k8s.yaml | 19 ++ .github/workflows/release-k8s.yaml | 14 + Makefile | 2 +- distributions/otelcol-k8s/.goreleaser.yaml | 245 ++++++++++++++++++ distributions/otelcol-k8s/Dockerfile | 14 + distributions/otelcol-k8s/README.md | 18 ++ distributions/otelcol-k8s/config.yaml | 46 ++++ distributions/otelcol-k8s/manifest.yaml | 71 +++++ distributions/otelcol-k8s/otelcol-k8s.conf | 5 + distributions/otelcol-k8s/otelcol-k8s.service | 15 ++ distributions/otelcol-k8s/postinstall.sh | 22 ++ distributions/otelcol-k8s/preinstall.sh | 17 ++ distributions/otelcol-k8s/preremove.sh | 20 ++ 13 files changed, 507 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci-goreleaser-k8s.yaml create mode 100644 .github/workflows/release-k8s.yaml create mode 100644 distributions/otelcol-k8s/.goreleaser.yaml create mode 100644 distributions/otelcol-k8s/Dockerfile create mode 100644 distributions/otelcol-k8s/README.md create mode 100644 distributions/otelcol-k8s/config.yaml create mode 100644 distributions/otelcol-k8s/manifest.yaml create mode 100644 distributions/otelcol-k8s/otelcol-k8s.conf create mode 100644 distributions/otelcol-k8s/otelcol-k8s.service create mode 100755 distributions/otelcol-k8s/postinstall.sh create mode 100755 distributions/otelcol-k8s/preinstall.sh create mode 100755 distributions/otelcol-k8s/preremove.sh diff --git a/.github/workflows/ci-goreleaser-k8s.yaml b/.github/workflows/ci-goreleaser-k8s.yaml new file mode 100644 index 00000000..0f431a43 --- /dev/null +++ b/.github/workflows/ci-goreleaser-k8s.yaml @@ -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 diff --git a/.github/workflows/release-k8s.yaml b/.github/workflows/release-k8s.yaml new file mode 100644 index 00000000..89137c01 --- /dev/null +++ b/.github/workflows/release-k8s.yaml @@ -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 \ No newline at end of file diff --git a/Makefile b/Makefile index 6d2c0f2b..70e29bed 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/distributions/otelcol-k8s/.goreleaser.yaml b/distributions/otelcol-k8s/.goreleaser.yaml new file mode 100644 index 00000000..62ff655d --- /dev/null +++ b/distributions/otelcol-k8s/.goreleaser.yaml @@ -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 + 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 diff --git a/distributions/otelcol-k8s/Dockerfile b/distributions/otelcol-k8s/Dockerfile new file mode 100644 index 00000000..3ef88e02 --- /dev/null +++ b/distributions/otelcol-k8s/Dockerfile @@ -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 diff --git a/distributions/otelcol-k8s/README.md b/distributions/otelcol-k8s/README.md new file mode 100644 index 00000000..398bc7f0 --- /dev/null +++ b/distributions/otelcol-k8s/README.md @@ -0,0 +1,18 @@ +# 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 + - 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 is 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. \ No newline at end of file diff --git a/distributions/otelcol-k8s/config.yaml b/distributions/otelcol-k8s/config.yaml new file mode 100644 index 00000000..8eafe1a1 --- /dev/null +++ b/distributions/otelcol-k8s/config.yaml @@ -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] diff --git a/distributions/otelcol-k8s/manifest.yaml b/distributions/otelcol-k8s/manifest.yaml new file mode 100644 index 00000000..438ae693 --- /dev/null +++ b/distributions/otelcol-k8s/manifest.yaml @@ -0,0 +1,71 @@ +dist: + module: github.com/open-telemetry/opentelemetry-collector-releases/k8s + name: otelcol-k8s + description: OpenTelemetry Collector for Kubernetes + version: 0.96.0 + output_path: ./_build + otelcol_version: 0.96.0 + +extensions: + - gomod: go.opentelemetry.io/collector/extension/zpagesextension v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/bearertokenauthextension v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/headerssetterextension v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/httpforwarderextension v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/oauth2clientauthextension v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/hostobserver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/k8sobserver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/oidcauthextension v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage v0.96.0 + import: github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage + +exporters: + - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.96.0 + - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.96.0 + - gomod: go.opentelemetry.io/collector/exporter/otlphttpexporter v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter v0.96.0 + +processors: + - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.96.0 + - gomod: go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/cumulativetodeltaprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatorateprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbyattrsprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbytraceprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/metricstransformprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/redactionprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/remotetapprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.96.0 + +receivers: + - gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/fluentforwardreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/httpcheckreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8seventsreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sobjectsreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/opencensusreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/receivercreator v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.96.0 + +connectors: + - gomod: go.opentelemetry.io/collector/connector/forwardconnector v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector v0.96.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.96.0 diff --git a/distributions/otelcol-k8s/otelcol-k8s.conf b/distributions/otelcol-k8s/otelcol-k8s.conf new file mode 100644 index 00000000..f5725308 --- /dev/null +++ b/distributions/otelcol-k8s/otelcol-k8s.conf @@ -0,0 +1,5 @@ +# Systemd environment file for the otelcol-k8s service + +# Command-line options for the otelcol-k8s service. +# Run `/usr/bin/otelcol-k8s --help` to see all available options. +OTELCOL_OPTIONS="--config=/etc/otelcol-k8s/config.yaml" diff --git a/distributions/otelcol-k8s/otelcol-k8s.service b/distributions/otelcol-k8s/otelcol-k8s.service new file mode 100644 index 00000000..73873edf --- /dev/null +++ b/distributions/otelcol-k8s/otelcol-k8s.service @@ -0,0 +1,15 @@ +[Unit] +Description=OpenTelemetry Collector k8s +After=network.target + +[Service] +EnvironmentFile=/etc/otelcol-k8s/otelcol-k8s.conf +ExecStart=/usr/bin/otelcol-k8s $OTELCOL_OPTIONS +KillMode=mixed +Restart=on-failure +Type=simple +User=otelcol-k8s +Group=otelcol-k8s + +[Install] +WantedBy=multi-user.target diff --git a/distributions/otelcol-k8s/postinstall.sh b/distributions/otelcol-k8s/postinstall.sh new file mode 100755 index 00000000..71b906af --- /dev/null +++ b/distributions/otelcol-k8s/postinstall.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if command -v systemctl >/dev/null 2>&1; then + systemctl enable otelcol-k8s.service + if [ -f /etc/otelcol-k8s/config.yaml ]; then + systemctl start otelcol-k8s.service + fi +fi diff --git a/distributions/otelcol-k8s/preinstall.sh b/distributions/otelcol-k8s/preinstall.sh new file mode 100755 index 00000000..553f0ae4 --- /dev/null +++ b/distributions/otelcol-k8s/preinstall.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +getent passwd otelcol-k8s >/dev/null || useradd --system --user-group --no-create-home --shell /sbin/nologin otelcol-k8s diff --git a/distributions/otelcol-k8s/preremove.sh b/distributions/otelcol-k8s/preremove.sh new file mode 100755 index 00000000..7e1e2723 --- /dev/null +++ b/distributions/otelcol-k8s/preremove.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if command -v systemctl >/dev/null 2>&1; then + systemctl stop otelcol-k8s.service + systemctl disable otelcol-k8s.service +fi