-
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 multi-container multi-instrumentation for ApacheHTTPD, Golang, S…
…DK (#3316)
- Loading branch information
1 parent
05c901f
commit 91759b0
Showing
14 changed files
with
735 additions
and
240 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...e-multi-instrumentation/instrumentation-multi-multicontainer-go/00-install-collector.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/v1alpha1 | ||
kind: OpenTelemetryCollector | ||
metadata: | ||
name: sidecar | ||
spec: | ||
mode: sidecar | ||
config: | | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
http: | ||
processors: | ||
exporters: | ||
debug: | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
exporters: [debug] |
37 changes: 37 additions & 0 deletions
37
...i-instrumentation/instrumentation-multi-multicontainer-go/00-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,37 @@ | ||
apiVersion: opentelemetry.io/v1alpha1 | ||
kind: Instrumentation | ||
metadata: | ||
name: go | ||
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" | ||
exporter: | ||
endpoint: http://localhost:4317 | ||
propagators: | ||
- jaeger | ||
- b3 | ||
sampler: | ||
type: parentbased_traceidratio | ||
argument: "0.25" | ||
python: | ||
env: | ||
- name: OTEL_SERVICE_NAME | ||
value: "pythonapp" | ||
- name: OTEL_EXPORTER_OTLP_ENDPOINT | ||
value: http://localhost:4318 | ||
go: | ||
env: | ||
- name: OTEL_SERVICE_NAME | ||
value: "goapp" | ||
|
4 changes: 4 additions & 0 deletions
4
tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/01-add-scc.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,4 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: otel-instrumentation-go |
196 changes: 196 additions & 0 deletions
196
tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-assert.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,196 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
instrumentation.opentelemetry.io/go-container-names: goapp | ||
instrumentation.opentelemetry.io/inject-go: "true" | ||
instrumentation.opentelemetry.io/inject-python: "true" | ||
instrumentation.opentelemetry.io/otel-go-auto-target-exe: /usr/src/app/productcatalogservice | ||
instrumentation.opentelemetry.io/python-container-names: pythonapp | ||
labels: | ||
app: my-golang-multiinst | ||
spec: | ||
containers: | ||
- name: goapp | ||
volumeMounts: | ||
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount | ||
readOnly: true | ||
- command: | ||
- flask | ||
- run | ||
- -p | ||
- "8087" | ||
env: | ||
- name: OTEL_NODE_IP | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: status.hostIP | ||
- name: OTEL_POD_IP | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: status.podIP | ||
- name: OTEL_SERVICE_NAME | ||
value: pythonapp | ||
- name: OTEL_EXPORTER_OTLP_ENDPOINT | ||
value: http://localhost:4318 | ||
- name: PYTHONPATH | ||
value: /otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation-python | ||
- name: OTEL_EXPORTER_OTLP_PROTOCOL | ||
value: http/protobuf | ||
- name: OTEL_TRACES_EXPORTER | ||
value: otlp | ||
- name: OTEL_METRICS_EXPORTER | ||
value: otlp | ||
- 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_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: pythonapp | ||
volumeMounts: | ||
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount | ||
readOnly: true | ||
- mountPath: /otel-auto-instrumentation-python | ||
name: opentelemetry-auto-instrumentation-python | ||
- args: | ||
- --feature-gates=-component.UseLocalHostAsDefaultHost | ||
- --config=env:OTEL_CONFIG | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: metadata.name | ||
- name: OTEL_CONFIG | ||
value: | | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: null | ||
http: null | ||
exporters: | ||
debug: null | ||
service: | ||
pipelines: | ||
traces: | ||
exporters: | ||
- debug | ||
receivers: | ||
- otlp | ||
- name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: metadata.name | ||
- name: OTEL_RESOURCE_ATTRIBUTES_POD_UID | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: metadata.uid | ||
- name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: spec.nodeName | ||
- name: OTEL_RESOURCE_ATTRIBUTES | ||
name: otc-container | ||
volumeMounts: | ||
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount | ||
readOnly: true | ||
- env: | ||
- name: OTEL_NODE_IP | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: status.hostIP | ||
- name: OTEL_POD_IP | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: status.podIP | ||
- name: OTEL_GO_AUTO_TARGET_EXE | ||
value: /usr/src/app/productcatalogservice | ||
- name: OTEL_SERVICE_NAME | ||
value: goapp | ||
- 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_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: opentelemetry-auto-instrumentation | ||
volumeMounts: | ||
- mountPath: /sys/kernel/debug | ||
name: kernel-debug | ||
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount | ||
readOnly: true | ||
initContainers: | ||
- command: | ||
- cp | ||
- -r | ||
- /autoinstrumentation/. | ||
- /otel-auto-instrumentation-python | ||
name: opentelemetry-auto-instrumentation-python | ||
volumeMounts: | ||
- mountPath: /otel-auto-instrumentation-python | ||
name: opentelemetry-auto-instrumentation-python | ||
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount | ||
readOnly: true | ||
status: | ||
containerStatuses: | ||
- name: goapp | ||
ready: true | ||
started: true | ||
- name: opentelemetry-auto-instrumentation | ||
ready: true | ||
started: true | ||
- name: otc-container | ||
ready: true | ||
started: true | ||
- name: pythonapp | ||
ready: true | ||
started: true | ||
initContainerStatuses: | ||
- name: opentelemetry-auto-instrumentation-python | ||
ready: true | ||
state: | ||
terminated: | ||
reason: Completed | ||
phase: Running |
39 changes: 39 additions & 0 deletions
39
tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/02-install-app.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,39 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: my-golang-multiinst | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: my-golang-multiinst | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: my-golang-multiinst | ||
annotations: | ||
sidecar.opentelemetry.io/inject: "true" | ||
instrumentation.opentelemetry.io/inject-go: "true" | ||
instrumentation.opentelemetry.io/otel-go-auto-target-exe: /usr/src/app/productcatalogservice | ||
instrumentation.opentelemetry.io/inject-python: "true" | ||
instrumentation.opentelemetry.io/python-container-names: "pythonapp" | ||
instrumentation.opentelemetry.io/go-container-names: "goapp" | ||
spec: | ||
serviceAccountName: otel-instrumentation-go | ||
securityContext: | ||
runAsUser: 0 | ||
runAsGroup: 3000 | ||
fsGroup: 3000 | ||
containers: | ||
- name: goapp | ||
image: ghcr.io/open-telemetry/opentelemetry-operator/e2e-test-app-golang:main | ||
- name: pythonapp | ||
image: ghcr.io/open-telemetry/opentelemetry-operator/e2e-test-app-python:main | ||
command: ["flask", "run", "-p", "8087"] | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: ["ALL"] | ||
seccompProfile: | ||
type: RuntimeDefault | ||
|
6 changes: 6 additions & 0 deletions
6
tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/add-scc.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,6 @@ | ||
#!/bin/bash | ||
|
||
if [[ "$(kubectl api-resources --api-group=operator.openshift.io -o name)" ]]; then | ||
kubectl apply -f scc.yaml | ||
oc adm policy add-scc-to-user otel-go-instrumentation -z otel-instrumentation-go -n $NAMESPACE | ||
fi |
46 changes: 46 additions & 0 deletions
46
tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/chainsaw-test.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,46 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
creationTimestamp: null | ||
name: instrumentation-multi-multicontainer-go | ||
spec: | ||
steps: | ||
- name: step-00 | ||
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=0/0 | ||
- --overwrite | ||
- command: | ||
entrypoint: kubectl | ||
args: | ||
- annotate | ||
- namespace | ||
- ${NAMESPACE} | ||
- openshift.io/sa.scc.supplemental-groups=3000/3000 | ||
- --overwrite | ||
- apply: | ||
file: 00-install-collector.yaml | ||
- apply: | ||
file: 00-install-instrumentation.yaml | ||
- name: step-01 | ||
try: | ||
- script: | ||
content: ./add-scc.sh | ||
- apply: | ||
file: 01-add-scc.yaml | ||
- name: step-02 | ||
try: | ||
- apply: | ||
file: 02-install-app.yaml | ||
- assert: | ||
file: 02-assert.yaml | ||
catch: | ||
- podLogs: | ||
selector: app=my-golang |
17 changes: 17 additions & 0 deletions
17
tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer-go/scc.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,17 @@ | ||
apiVersion: security.openshift.io/v1 | ||
kind: SecurityContextConstraints | ||
metadata: | ||
name: otel-go-instrumentation | ||
allowHostDirVolumePlugin: true | ||
allowPrivilegeEscalation: true | ||
allowPrivilegedContainer: true | ||
fsGroup: | ||
type: RunAsAny | ||
runAsUser: | ||
type: RunAsAny | ||
seLinuxContext: | ||
type: RunAsAny | ||
seccompProfiles: | ||
- '*' | ||
supplementalGroups: | ||
type: RunAsAny |
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
Oops, something went wrong.