Skip to content

Commit 50a5e71

Browse files
committed
feat: add k8s node and cluster config
1 parent e75cc26 commit 50a5e71

File tree

29 files changed

+1448
-201
lines changed

29 files changed

+1448
-201
lines changed

.github/workflows/ci-config-drift.yaml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,6 @@ jobs:
1616
- name: Set up Helm
1717
uses: azure/[email protected]
1818

19-
- name: Setup local kind cluster
20-
uses: helm/kind-action@v1
21-
with:
22-
version: v0.21.0
23-
cluster_name: "config-drift"
24-
wait: 60s
25-
26-
- name: Install nr-k8s-otel-collector chart
19+
- name: Sync k8s distro configs from helm chart
2720
run: |
28-
helm repo add newrelic https://newrelic.github.io/helm-charts
29-
30-
helm install test newrelic/nr-k8s-otel-collector -n default \
31-
--set cluster=config-drift --set licenseKey=PLACEHOLDER \
32-
--create-namespace --dependency-update
33-
34-
kubectl get configmaps -n default test-nr-k8s-otel-collector-daemonset-config \
35-
-o "jsonpath={.data['daemonset-config\.yaml']}" | yq .
36-
37-
kubectl get configmaps -n default test-nr-k8s-otel-collector-deployment-config \
38-
-o "jsonpath={.data['deployment-config\.yaml']}" | yq .
21+
make -f ./distributions/nrdot-collector-k8s/Makefile sync-configs

.github/workflows/ci-nightly.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
distribution:
4949
- nr-otel-collector
5050
- nrdot-collector-host
51+
- nrdot-collector-k8s
5152
steps:
5253
- name: Checkout
5354
uses: actions/checkout@v4

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
distribution:
1919
- nr-otel-collector
2020
- nrdot-collector-host
21+
- nrdot-collector-k8s
2122
uses: ./.github/workflows/ci-base.yaml
2223
with:
2324
distribution: ${{ matrix.distribution }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(shell echo $(TOOLS_
1616
GO_LICENCE_DETECTOR := $(TOOLS_BIN_DIR)/go-licence-detector
1717
GO_LICENCE_DETECTOR_CONFIG := $(SRC_ROOT)/internal/assets/license/rules.json
1818

19-
DISTRIBUTIONS ?= "nr-otel-collector,nrdot-collector-host"
19+
DISTRIBUTIONS ?= "nr-otel-collector,nrdot-collector-host,nrdot-collector-k8s"
2020

2121
ci: check build licenses-check
2222
check: ensure-goreleaser-up-to-date

cmd/goreleaser/internal/configure.go

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,20 @@ const (
4242
var (
4343
ImagePrefixes = []string{DockerHub}
4444
NightlyImagePrefixes = []string{EnvRegistry}
45-
46-
Architectures = []string{"amd64", "arm64"}
47-
DefaultConfigDists = map[string]bool{LegacyDistro: true, HostDistro: true}
45+
Architectures = []string{"amd64", "arm64"}
46+
SkipBinaries = map[string]bool{
47+
K8sDistro: true,
48+
}
49+
NfpmDefaultConfig = map[string]string{
50+
LegacyDistro: "config.yaml",
51+
HostDistro: "config.yaml",
52+
// k8s missing due to not packaged via nfpm
53+
}
54+
DockerIncludedConfigs = map[string][]string{
55+
LegacyDistro: {"config.yaml"},
56+
HostDistro: {"config.yaml"},
57+
K8sDistro: {"config-node.yaml", "config-cluster.yaml"},
58+
}
4859
K8sDockerSkipArchs = map[string]bool{"arm": true, "386": true}
4960
K8sGoos = []string{"linux"}
5061
K8sArchs = []string{"amd64", "arm64"}
@@ -85,10 +96,9 @@ func Generate(dist string, nightly bool) config.Project {
8596
}
8697

8798
func Blobs(dist string, nightly bool) []config.Blob {
88-
if dist == K8sDistro {
99+
if skip, ok := SkipBinaries[dist]; ok && skip {
89100
return nil
90101
}
91-
92102
version := "{{ .Version }}"
93103

94104
if nightly {
@@ -154,6 +164,9 @@ func ArmVersions(dist string) []string {
154164
}
155165

156166
func Archives(dist string) []config.Archive {
167+
if skip, ok := SkipBinaries[dist]; ok && skip {
168+
return nil
169+
}
157170
return []config.Archive{
158171
Archive(dist),
159172
}
@@ -175,7 +188,7 @@ func Archive(dist string) config.Archive {
175188
}
176189

177190
func Packages(dist string) []config.NFPM {
178-
if dist == K8sDistro {
191+
if skip, ok := SkipBinaries[dist]; ok && skip {
179192
return nil
180193
}
181194
return []config.NFPM{
@@ -197,9 +210,9 @@ func Package(dist string) config.NFPM {
197210
Type: "config|noreplace",
198211
},
199212
}
200-
if _, ok := DefaultConfigDists[dist]; ok {
213+
if defaultConfig, ok := NfpmDefaultConfig[dist]; ok {
201214
nfpmContents = append(nfpmContents, config.NFPMContent{
202-
Source: "config.yaml",
215+
Source: defaultConfig,
203216
Destination: path.Join("/etc", dist, "config.yaml"),
204217
Type: "config",
205218
})
@@ -294,8 +307,10 @@ func DockerImage(dist string, nightly bool, arch string, armVersion string) conf
294307
return fmt.Sprintf("--label=org.opencontainers.image.%s={{%s}}", name, template)
295308
}
296309
files := make([]string, 0)
297-
if _, ok := DefaultConfigDists[dist]; ok {
298-
files = append(files, "config.yaml")
310+
if configFiles, ok := DockerIncludedConfigs[dist]; ok {
311+
for _, configFile := range configFiles {
312+
files = append(files, configFile)
313+
}
299314
}
300315
return config.Docker{
301316
ImageTemplates: imageTemplates,

configs/README.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

configs/nr-otel-collector-gateway.yaml

Lines changed: 0 additions & 46 deletions
This file was deleted.

distributions/README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,26 @@
22

33
## Installation
44

5-
### General
5+
### Docker
66

7-
#### Environment variables
8-
- `NEW_RELIC_LICENSE_KEY`: New Relic ingest key.
9-
- `NEW_RELIC_MEMORY_LIMIT_MIB`: Maximum amount of memory to be used.
10-
- `OTEL_EXPORTER_OTLP_ENDPOINT`: New Relic OTLP endpoint to export metrics to, see [official docs](https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp/)
7+
Each distribution is available as a Docker image under the [newrelic](https://hub.docker.com/u/newrelic?page=1&search=nrdot-collector) organization on Docker Hub.
8+
9+
### OS-specific packages
10+
For certain distributions, signed OS-specific packages are also available under [Releases](https://github.com/newrelic/opentelemetry-collector-releases/releases) on GitHub.
11+
12+
## Configuration
1113

1214
### Components
1315

1416
The full list of components is available in the respective `manifest.yaml`
1517

16-
### Configuration
18+
### Customize Default Configuration
19+
20+
The default configuration exposes some options via environment variables:
21+
22+
| Environment Variable | Description | Default |
23+
|---|---|---|
24+
| `NEW_RELIC_LICENSE_KEY` | New Relic ingest key | N/A - Required |
25+
| `NEW_RELIC_MEMORY_LIMIT_MIB` | Maximum amount of memory to be used | 100 |
26+
| `OTEL_EXPORTER_OTLP_ENDPOINT` | New Relic OTLP endpoint to export metrics to, see [official docs](https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp/) | `https://otlp.nr-data.net:4317` |
1727

18-
The default configuration is `config.yaml` which is embedded in the `Dockerfile` and any OS-specific packaging (if available).

distributions/nrdot-collector-host/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ Note: See [general README](../README.md) for information that applies to all dis
55
A distribution of the NRDOT collector focused on
66
- monitoring the host the collector is deployed on via `hostmetricsreceiver` and `filelogreceiver`
77
- support piping other telemetry through it via the `otlpreceiver`
8+
9+
Distribution is available as docker image and as OS-specific package.

distributions/nrdot-collector-k8s/.goreleaser-nightly.yaml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
version: 2
22
project_name: nrdot-collector-releases-nightly
3+
release:
4+
disable: "true"
35
builds:
46
- id: nrdot-collector-k8s
57
goos:
@@ -16,15 +18,6 @@ builds:
1618
- -trimpath
1719
env:
1820
- CGO_ENABLED=0
19-
archives:
20-
- id: nrdot-collector-k8s
21-
builds:
22-
- nrdot-collector-k8s
23-
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
24-
format_overrides:
25-
- goos: windows
26-
formats:
27-
- zip
2821
snapshot:
2922
version_template: '{{ incpatch .Version }}-SNAPSHOT-{{.ShortCommit}}'
3023
checksum:
@@ -38,6 +31,9 @@ dockers:
3831
image_templates:
3932
- '{{ .Env.REGISTRY }}/nrdot-collector-k8s:{{ .Version }}-nightly-amd64'
4033
- '{{ .Env.REGISTRY }}/nrdot-collector-k8s:nightly-amd64'
34+
extra_files:
35+
- config-node.yaml
36+
- config-cluster.yaml
4137
build_flag_templates:
4238
- --pull
4339
- --platform=linux/amd64
@@ -54,6 +50,9 @@ dockers:
5450
image_templates:
5551
- '{{ .Env.REGISTRY }}/nrdot-collector-k8s:{{ .Version }}-nightly-arm64'
5652
- '{{ .Env.REGISTRY }}/nrdot-collector-k8s:nightly-arm64'
53+
extra_files:
54+
- config-node.yaml
55+
- config-cluster.yaml
5756
build_flag_templates:
5857
- --pull
5958
- --platform=linux/arm64
@@ -82,9 +81,3 @@ signs:
8281
- ${artifact}
8382
signature: ${artifact}.sig
8483
artifacts: all
85-
certificate: ${artifact}.pem
86-
docker_signs:
87-
- args:
88-
- sign
89-
- ${artifact}
90-
artifacts: all

0 commit comments

Comments
 (0)