Skip to content

Commit dfc7dd5

Browse files
committed
Fixes configuration for bundled collectors and e2e test for ClusterObservability
Follow-ups to the initial ClusterObservability framework so the generated agent and cluster collectors come up cleanly on stock distributions, plus a smoke e2e that exercises the pipelines end-to-end.
1 parent 327ef9c commit dfc7dd5

21 files changed

Lines changed: 833 additions & 236 deletions

.chloggen/clusterobs-fixes.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
change_type: bug_fix
2+
3+
component: cluster-observability
4+
5+
note: Fix dependencies (image, env, volumes) required by the bundled agent and cluster collector configs
6+
7+
issues: [3821, 3818]
8+
9+
subtext: |
10+
Follow-ups to the initial ClusterObservability framework so the generated
11+
agent and cluster collectors come up cleanly on stock distributions:
12+
- Generate the agent and cluster collectors with the k8s distribution of the
13+
collector image (same version as the operator's collector image), overridable
14+
via the `--clusterobservability-collector-image` flag.
15+
- Inject `K8S_NODE_NAME` on the agent pod, referenced by the bundled
16+
`kubeletstats` receiver's endpoint.
17+
- Report the cluster collector's readiness from its StatefulSet workload
18+
so `ClusterObservability` no longer stays in `Pending` when the cluster
19+
collector is fully healthy.
20+
- Mount the whole host root at `/hostfs` so the `hostmetrics` receiver
21+
can resolve symlinks and stat host mount points.
22+
Exclude virtual/container-runtime filesystems from its `filesystem` scraper
23+
to avoid `/sysroot` and `/boot` scrape errors on OpenShift.
24+
- Run the agent as root with the `spc_t` SELinux type (supplied by the
25+
generated SCC) on OpenShift so the `filelog` receiver can read the
26+
root-owned container logs under `/var/log/pods`.
27+
- Point the generated `Instrumentation` at the agent's OTLP HTTP port (4318),
28+
since most auto-instrumentation SDKs default `OTEL_EXPORTER_OTLP_PROTOCOL`
29+
to `http/protobuf`.

.github/workflows/e2e-reusable.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ jobs:
5858
e2e-tests:
5959
runs-on: ubuntu-latest
6060
needs: [ build-test-images ]
61+
# Allow opt-in matrix entries (those with `experimental: true` in their
62+
# `include` block) to fail without marking the workflow run red.
63+
continue-on-error: ${{ matrix.experimental == true }}
6164
strategy:
6265
fail-fast: false
6366
matrix:
@@ -71,6 +74,7 @@ jobs:
7174
- e2e
7275
- e2e-automatic-rbac
7376
- e2e-autoscale
77+
- e2e-clusterobservability
7478
- e2e-instrumentation-default
7579
- e2e-instrumentation
7680
- e2e-no-crds
@@ -89,6 +93,10 @@ jobs:
8993
- e2e-crd-validations
9094
- e2e-ta-standalone
9195
include:
96+
- group: e2e-clusterobservability
97+
# ClusterObservability is behind a feature gate and still maturing
98+
experimental: true
99+
setup: "prepare-e2e-clusterobservability"
92100
- group: e2e-instrumentation-default
93101
setup: "add-instrumentation-params prepare-e2e"
94102
- group: e2e-instrumentation

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,14 @@ e2e: chainsaw
401401
e2e-sidecar: chainsaw
402402
$(CHAINSAW) test --test-dir ./tests/e2e-sidecar --report-name e2e-sidecar $(CHAINSAW_SELECTOR)
403403

404+
# End-to-end tests for ClusterObservability. The CRD is not bundled, so install
405+
# it directly from config/crd/bases/. --parallel 1 because only the oldest
406+
# active ClusterObservability CR reconciles.
407+
.PHONY: e2e-clusterobservability
408+
e2e-clusterobservability: chainsaw
409+
kubectl apply -f config/crd/bases/opentelemetry.io_clusterobservabilities.yaml
410+
$(CHAINSAW) test --test-dir ./tests/e2e-clusterobservability --report-name e2e-clusterobservability --parallel 1
411+
404412
# end-to-end-test for testing automatic RBAC creation
405413
.PHONY: e2e-automatic-rbac
406414
e2e-automatic-rbac: chainsaw
@@ -541,6 +549,15 @@ prepare-e2e: chainsaw set-image-controller add-image-targetallocator add-image-o
541549
prepare-e2e-no-crds: chainsaw set-image-controller add-image-targetallocator add-image-opampbridge start-kind cert-manager install-metrics-server install-targetallocator-prometheus-crds load-image-all deploy-no-crds
542550
@mkdir -p ./.testresults/e2e
543551

552+
# ClusterObservability needs the kubelet to serve a cluster-CA-signed cert so the
553+
# bundled kubeletstats receiver can verify it via the SA-token CA bundle. Override
554+
# KIND_CONFIG to a kubelet-config that enables serverTLSBootstrap.
555+
.PHONY: prepare-e2e-clusterobservability
556+
prepare-e2e-clusterobservability: KIND_CONFIG = kind-clusterobservability-$(KUBE_VERSION).yaml
557+
prepare-e2e-clusterobservability: add-rbac-permissions-to-operator
558+
@$(MAKE) add-operator-arg OPERATOR_ARG=--feature-gates=+operator.clusterobservability
559+
@$(MAKE) prepare-e2e
560+
544561
# Run operator-sdk scorecard tests for bundles
545562
.PHONY: scorecard-tests
546563
scorecard-tests: operator-sdk
@@ -645,8 +662,15 @@ ifeq (true,$(START_KIND_CLUSTER))
645662
else \
646663
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config $(KIND_CONFIG); \
647664
fi
665+
@$(MAKE) approve-kubelet-csrs
648666
endif
649667

668+
# Approve any kubelet-serving CSRs created via serverTLSBootstrap. No-op for
669+
# kind configs that do not enable bootstrap.
670+
.PHONY: approve-kubelet-csrs
671+
approve-kubelet-csrs:
672+
@kubectl get csr -o jsonpath='{range .items[?(@.spec.signerName=="kubernetes.io/kubelet-serving")]}{.metadata.name}{" "}{end}' | xargs -r kubectl certificate approve
673+
650674
# Stop kind cluster
651675
.PHONY: stop-kind
652676
stop-kind: kind

internal/config/cli.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func CreateCLIParser(cfg Config) *pflag.FlagSet {
3939
f.Bool("create-sm-operator-metrics", cfg.CreateServiceMonitorOperatorMetrics, "Create a ServiceMonitor for the operator metrics")
4040
f.Bool("ignore-missing-collector-crds", cfg.IgnoreMissingCollectorCRDs, "Ignore missing OpenTelemetryCollector CRDs presence in the cluster")
4141
f.String("collector-image", cfg.CollectorImage, "The default OpenTelemetry collector image. This image is used when no image is specified in the CustomResource.")
42+
f.String("clusterobservability-collector-image", cfg.ClusterObservabilityCollectorImage, "The OpenTelemetry collector image used for collectors generated by the ClusterObservability reconciler. Defaults to the k8s distribution.")
4243
f.String("target-allocator-image", cfg.TargetAllocatorImage, "The default OpenTelemetry target allocator image. This image is used when no image is specified in the CustomResource.")
4344
f.String("operator-opamp-bridge-image", cfg.OperatorOpAMPBridgeImage, "The default OpenTelemetry Operator OpAMP Bridge image. This image is used when no image is specified in the CustomResource.")
4445
f.String("auto-instrumentation-java-image", cfg.AutoInstrumentationJavaImage, "The default OpenTelemetry Java instrumentation image. This image is used when no image is specified in the CustomResource.")
@@ -96,6 +97,8 @@ func ApplyCLI(cfg *Config) error {
9697
cfg.IgnoreMissingCollectorCRDs, _ = f.GetBool("ignore-missing-collector-crds")
9798
case "collector-image":
9899
cfg.CollectorImage, _ = f.GetString("collector-image")
100+
case "clusterobservability-collector-image":
101+
cfg.ClusterObservabilityCollectorImage, _ = f.GetString("clusterobservability-collector-image")
99102
case "target-allocator-image":
100103
cfg.TargetAllocatorImage, _ = f.GetString("target-allocator-image")
101104
case "operator-opamp-bridge-image":

internal/config/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ type Config struct {
4747
AutoInstrumentationPythonImage string `yaml:"auto-instrumentation-python-image"`
4848
// CollectorImage represents the flag to override the OpenTelemetry Collector container image.
4949
CollectorImage string `yaml:"collector-image"`
50+
// ClusterObservabilityCollectorImage is the collector image used for the agent and
51+
// cluster collectors generated by the ClusterObservability reconciler. It defaults to
52+
// the k8s distribution at the same version as CollectorImage, since the bundled configs
53+
// only use components shipped in that distribution.
54+
ClusterObservabilityCollectorImage string `yaml:"clusterobservability-collector-image"`
5055
// CollectorConfigMapEntry represents the configuration file name for the collector. Immutable.
5156
CollectorConfigMapEntry string `yaml:"collector-configmap-entry"`
5257
// CreateRBACPermissions is true when the operator can create RBAC permissions for SAs running a collector instance. Immutable.
@@ -172,6 +177,7 @@ func New() Config {
172177
v := version.Get()
173178
return Config{
174179
CollectorImage: fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:%s", v.OpenTelemetryCollector),
180+
ClusterObservabilityCollectorImage: fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:%s", v.OpenTelemetryCollector),
175181
CollectorConfigMapEntry: defaultCollectorConfigMapEntry,
176182
EnableMultiInstrumentation: true,
177183
EnableApacheHttpdInstrumentation: true,

internal/config/config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func TestToStringMap(t *testing.T) {
2929
"auto-instrumentation-python-image": "",
3030
"cert-manager-availability": "0",
3131
"collector-availability": "0",
32+
"clusterobservability-collector-image": "",
3233
"collector-configmap-entry": "",
3334
"collector-image": "myexample:1.0",
3435
"create-rbac-permissions": "0",

internal/config/testdata/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ targetallocator-image: ghcr.io/open-telemetry/opentelemetry-operator/target-allo
22
operatoropampbridge-image: ghcr.io/open-telemetry/opentelemetry-operator/operator-opamp-bridge:0.0.0
33
auto-instrumentation-python-image: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python:0.0.0
44
collector-image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:0.0.0
5+
clusterobservability-collector-image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-k8s:0.0.0
56
collector-configmap-entry: collector.yaml
67
create-rbac-permissions: 0
78
enable-multi-instrumentation: true

0 commit comments

Comments
 (0)