-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test OpenTelemetry must-gather script (#3387)
- Loading branch information
1 parent
99bf725
commit 3ab821e
Showing
12 changed files
with
515 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
instrumentation.opentelemetry.io/inject-nodejs: "true" | ||
sidecar.opentelemetry.io/inject: "true" | ||
labels: | ||
app: my-nodejs | ||
spec: | ||
containers: | ||
- env: | ||
- name: OTEL_NODE_IP | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.hostIP | ||
- name: OTEL_POD_IP | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.podIP | ||
- name: NODE_PATH | ||
value: /usr/local/lib/node_modules | ||
- name: OTEL_NODEJS_DEBUG | ||
value: "true" | ||
- name: NODE_OPTIONS | ||
value: ' --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js' | ||
- name: OTEL_TRACES_EXPORTER | ||
value: otlp | ||
- name: OTEL_EXPORTER_OTLP_ENDPOINT | ||
value: http://localhost:4317 | ||
- name: OTEL_EXPORTER_OTLP_TIMEOUT | ||
value: "20" | ||
- name: OTEL_TRACES_SAMPLER | ||
value: parentbased_traceidratio | ||
- name: OTEL_TRACES_SAMPLER_ARG | ||
value: "0.85" | ||
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED | ||
value: "true" | ||
- name: OTEL_METRICS_EXPORTER | ||
value: prometheus | ||
- name: OTEL_SERVICE_NAME | ||
value: my-nodejs | ||
- name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: metadata.name | ||
- name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: spec.nodeName | ||
- name: OTEL_PROPAGATORS | ||
value: jaeger,b3 | ||
- name: OTEL_RESOURCE_ATTRIBUTES | ||
name: myapp | ||
volumeMounts: | ||
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount | ||
readOnly: true | ||
- mountPath: /otel-auto-instrumentation-nodejs | ||
name: opentelemetry-auto-instrumentation-nodejs | ||
- args: | ||
- --config=env:OTEL_CONFIG | ||
name: otc-container | ||
initContainers: | ||
- name: opentelemetry-auto-instrumentation-nodejs | ||
status: | ||
containerStatuses: | ||
- name: myapp | ||
ready: true | ||
started: true | ||
- name: otc-container | ||
ready: true | ||
started: true | ||
initContainerStatuses: | ||
- name: opentelemetry-auto-instrumentation-nodejs | ||
ready: true | ||
phase: Running |
93 changes: 93 additions & 0 deletions
93
tests/e2e-openshift/must-gather/assert-install-target-allocator.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: stateful-collector | ||
status: | ||
readyReplicas: 1 | ||
replicas: 1 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: stateful-targetallocator | ||
status: | ||
observedGeneration: 1 | ||
readyReplicas: 1 | ||
replicas: 1 | ||
--- | ||
apiVersion: v1 | ||
data: | ||
collector.yaml: | | ||
exporters: | ||
debug: {} | ||
processors: {} | ||
receivers: | ||
jaeger: | ||
protocols: | ||
grpc: | ||
endpoint: 0.0.0.0:14250 | ||
prometheus: | ||
config: | ||
global: | ||
scrape_interval: 30s | ||
scrape_protocols: | ||
- PrometheusProto | ||
- OpenMetricsText1.0.0 | ||
- OpenMetricsText0.0.1 | ||
- PrometheusText0.0.4 | ||
target_allocator: | ||
collector_id: ${POD_NAME} | ||
endpoint: http://stateful-targetallocator:80 | ||
interval: 30s | ||
service: | ||
pipelines: | ||
traces: | ||
exporters: | ||
- debug | ||
receivers: | ||
- jaeger | ||
telemetry: | ||
metrics: | ||
address: 0.0.0.0:8888 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app.kubernetes.io/component: opentelemetry-collector | ||
app.kubernetes.io/instance: chainsaw-must-gather.stateful | ||
app.kubernetes.io/managed-by: opentelemetry-operator | ||
app.kubernetes.io/name: stateful-collector | ||
app.kubernetes.io/part-of: opentelemetry | ||
name: stateful-collector-2729987d | ||
namespace: chainsaw-must-gather | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: stateful-targetallocator | ||
namespace: ($namespace) | ||
data: | ||
targetallocator.yaml: | ||
(parse_yaml(@)): | ||
allocation_strategy: consistent-hashing | ||
collector_selector: | ||
matchlabels: | ||
app.kubernetes.io/component: opentelemetry-collector | ||
app.kubernetes.io/instance: (join('.', [$namespace, 'stateful'])) | ||
app.kubernetes.io/managed-by: opentelemetry-operator | ||
app.kubernetes.io/part-of: opentelemetry | ||
matchexpressions: [ ] | ||
config: | ||
global: | ||
scrape_interval: 30s | ||
scrape_protocols: | ||
- PrometheusProto | ||
- OpenMetricsText1.0.0 | ||
- OpenMetricsText0.0.1 | ||
- PrometheusText0.0.4 | ||
scrape_configs: | ||
- job_name: otel-collector | ||
scrape_interval: 10s | ||
static_configs: | ||
- targets: | ||
- 0.0.0.0:8888 | ||
filter_strategy: relabel-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: must-gather | ||
spec: | ||
namespace: chainsaw-must-gather | ||
steps: | ||
- name: Install Target Allocator | ||
try: | ||
- apply: | ||
template: true | ||
file: install-target-allocator.yaml | ||
- assert: | ||
file: assert-install-target-allocator.yaml | ||
catch: | ||
- podLogs: | ||
selector: app.kubernetes.io/component=opentelemetry-targetallocator | ||
- name: Create instrumentation CR and sidecar collector instance | ||
try: | ||
# In OpenShift, when a namespace is created, all necessary SCC annotations are automatically added. However, if a namespace is created using a resource file with only selected SCCs, the other auto-added SCCs are not included. Therefore, the UID-range and supplemental groups SCC annotations must be set after the namespace is created. | ||
- command: | ||
entrypoint: kubectl | ||
args: | ||
- annotate | ||
- namespace | ||
- ${NAMESPACE} | ||
- openshift.io/sa.scc.uid-range=1000/1000 | ||
- --overwrite | ||
- command: | ||
entrypoint: kubectl | ||
args: | ||
- annotate | ||
- namespace | ||
- ${NAMESPACE} | ||
- openshift.io/sa.scc.supplemental-groups=3000/3000 | ||
- --overwrite | ||
- apply: | ||
file: install-collector-sidecar.yaml | ||
- apply: | ||
file: install-instrumentation.yaml | ||
- name: Install app | ||
try: | ||
- apply: | ||
file: install-app.yaml | ||
- assert: | ||
file: assert-install-app.yaml | ||
catch: | ||
- podLogs: | ||
selector: app=my-nodejs | ||
- name: Run the must-gather and verify the contents | ||
try: | ||
- command: | ||
entrypoint: oc | ||
args: | ||
- get | ||
- pods | ||
- -A | ||
- -l control-plane=controller-manager | ||
- -l app.kubernetes.io/name=opentelemetry-operator | ||
- -o | ||
- jsonpath={.items[0].metadata.namespace} | ||
outputs: | ||
- name: OTEL_NAMESPACE | ||
value: ($stdout) | ||
- script: | ||
env: | ||
- name: otelnamespace | ||
value: ($OTEL_NAMESPACE) | ||
timeout: 5m | ||
content: ./check_must_gather.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# Create a temporary directory to store must-gather | ||
MUST_GATHER_DIR=$(mktemp -d) | ||
|
||
# Run the must-gather script | ||
oc adm must-gather --dest-dir=$MUST_GATHER_DIR --image=ghcr.io/open-telemetry/opentelemetry-operator/must-gather:latest -- /usr/bin/must-gather --operator-namespace $otelnamespace | ||
|
||
# Define required files and directories | ||
REQUIRED_ITEMS=( | ||
event-filter.html | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/olm/*opentelemetry-operato*.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/olm/clusterserviceversion-opentelemetry-operator-v*.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/olm/installplan-install-*.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/olm/subscription-opentelemetry-operator-v*-sub.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/service-stateful-collector-headless.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/service-stateful-collector.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/deployment-stateful-targetallocator.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/service-stateful-collector-monitoring.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/poddisruptionbudget-stateful-targetallocator.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/poddisruptionbudget-stateful-collector.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/service-stateful-targetallocator.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/configmap-stateful-collector-2729987d.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/configmap-stateful-targetallocator.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/statefulset-stateful-collector.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/opentelemetrycollector-stateful.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/stateful/serviceaccount-stateful-collector.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/sidecar/service-sidecar-collector.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/sidecar/opentelemetrycollector-sidecar.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/sidecar/service-sidecar-collector-monitoring.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/sidecar/configmap-sidecar-collector-3826c0e7.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/sidecar/serviceaccount-sidecar-collector.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/namespaces/chainsaw-must-gather/sidecar/service-sidecar-collector-headless.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/chainsaw-must-gather/instrumentation-nodejs.yaml | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/opentelemetry-operator-controller-manager-* | ||
ghcr-io-open-telemetry-opentelemetry-operator-must-gather-sha256-*/deployment-opentelemetry-operator-controller-manager.yaml | ||
timestamp | ||
) | ||
|
||
# Verify each required item | ||
for item in "${REQUIRED_ITEMS[@]}"; do | ||
if ! find "$MUST_GATHER_DIR" -path "$MUST_GATHER_DIR/$item" -print -quit | grep -q .; then | ||
echo "Missing: $item" | ||
exit 1 | ||
else | ||
echo "Found: $item" | ||
fi | ||
done | ||
|
||
# Cleanup the must-gather directory | ||
rm -rf $MUST_GATHER_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: my-nodejs | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: my-nodejs | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: my-nodejs | ||
annotations: | ||
sidecar.opentelemetry.io/inject: "true" | ||
instrumentation.opentelemetry.io/inject-nodejs: "true" | ||
spec: | ||
securityContext: | ||
runAsUser: 1000 | ||
runAsGroup: 3000 | ||
fsGroup: 3000 | ||
containers: | ||
- name: myapp | ||
image: ghcr.io/open-telemetry/opentelemetry-operator/e2e-test-app-nodejs:main | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: ["ALL"] | ||
env: | ||
- name: NODE_PATH | ||
value: /usr/local/lib/node_modules |
22 changes: 22 additions & 0 deletions
22
tests/e2e-openshift/must-gather/install-collector-sidecar.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: opentelemetry.io/v1beta1 | ||
kind: OpenTelemetryCollector | ||
metadata: | ||
name: sidecar | ||
spec: | ||
config: | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: {} | ||
http: {} | ||
processors: {} | ||
|
||
exporters: | ||
debug: | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
exporters: [debug] | ||
mode: sidecar |
33 changes: 33 additions & 0 deletions
33
tests/e2e-openshift/must-gather/install-instrumentation.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apiVersion: opentelemetry.io/v1alpha1 | ||
kind: Instrumentation | ||
metadata: | ||
name: nodejs | ||
spec: | ||
env: | ||
- name: OTEL_TRACES_EXPORTER | ||
value: otlp | ||
- name: OTEL_EXPORTER_OTLP_ENDPOINT | ||
value: http://localhost:4317 | ||
- name: OTEL_EXPORTER_OTLP_TIMEOUT | ||
value: "20" | ||
- name: OTEL_TRACES_SAMPLER | ||
value: parentbased_traceidratio | ||
- name: OTEL_TRACES_SAMPLER_ARG | ||
value: "0.85" | ||
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED | ||
value: "true" | ||
- name: OTEL_METRICS_EXPORTER | ||
value: prometheus | ||
exporter: | ||
endpoint: http://localhost:4317 | ||
propagators: | ||
- jaeger | ||
- b3 | ||
sampler: | ||
type: parentbased_traceidratio | ||
argument: "0.25" | ||
nodejs: | ||
env: | ||
- name: OTEL_NODEJS_DEBUG | ||
value: "true" | ||
|
Oops, something went wrong.