Skip to content

Commit a47d28d

Browse files
author
Israel Blancas
authored
Merge branch 'main' into feature/3149
2 parents 7a494b9 + 91759b0 commit a47d28d

14 files changed

+735
-240
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: opentelemetry.io/v1alpha1
2+
kind: OpenTelemetryCollector
3+
metadata:
4+
name: sidecar
5+
spec:
6+
mode: sidecar
7+
config: |
8+
receivers:
9+
otlp:
10+
protocols:
11+
grpc:
12+
http:
13+
processors:
14+
15+
exporters:
16+
debug:
17+
18+
service:
19+
pipelines:
20+
traces:
21+
receivers: [otlp]
22+
exporters: [debug]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: opentelemetry.io/v1alpha1
2+
kind: Instrumentation
3+
metadata:
4+
name: go
5+
spec:
6+
env:
7+
- name: OTEL_TRACES_EXPORTER
8+
value: otlp
9+
- name: OTEL_EXPORTER_OTLP_ENDPOINT
10+
value: http://localhost:4317
11+
- name: OTEL_EXPORTER_OTLP_TIMEOUT
12+
value: "20"
13+
- name: OTEL_TRACES_SAMPLER
14+
value: parentbased_traceidratio
15+
- name: OTEL_TRACES_SAMPLER_ARG
16+
value: "0.85"
17+
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
18+
value: "true"
19+
exporter:
20+
endpoint: http://localhost:4317
21+
propagators:
22+
- jaeger
23+
- b3
24+
sampler:
25+
type: parentbased_traceidratio
26+
argument: "0.25"
27+
python:
28+
env:
29+
- name: OTEL_SERVICE_NAME
30+
value: "pythonapp"
31+
- name: OTEL_EXPORTER_OTLP_ENDPOINT
32+
value: http://localhost:4318
33+
go:
34+
env:
35+
- name: OTEL_SERVICE_NAME
36+
value: "goapp"
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: otel-instrumentation-go
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
annotations:
5+
instrumentation.opentelemetry.io/go-container-names: goapp
6+
instrumentation.opentelemetry.io/inject-go: "true"
7+
instrumentation.opentelemetry.io/inject-python: "true"
8+
instrumentation.opentelemetry.io/otel-go-auto-target-exe: /usr/src/app/productcatalogservice
9+
instrumentation.opentelemetry.io/python-container-names: pythonapp
10+
labels:
11+
app: my-golang-multiinst
12+
spec:
13+
containers:
14+
- name: goapp
15+
volumeMounts:
16+
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
17+
readOnly: true
18+
- command:
19+
- flask
20+
- run
21+
- -p
22+
- "8087"
23+
env:
24+
- name: OTEL_NODE_IP
25+
valueFrom:
26+
fieldRef:
27+
apiVersion: v1
28+
fieldPath: status.hostIP
29+
- name: OTEL_POD_IP
30+
valueFrom:
31+
fieldRef:
32+
apiVersion: v1
33+
fieldPath: status.podIP
34+
- name: OTEL_SERVICE_NAME
35+
value: pythonapp
36+
- name: OTEL_EXPORTER_OTLP_ENDPOINT
37+
value: http://localhost:4318
38+
- name: PYTHONPATH
39+
value: /otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation-python
40+
- name: OTEL_EXPORTER_OTLP_PROTOCOL
41+
value: http/protobuf
42+
- name: OTEL_TRACES_EXPORTER
43+
value: otlp
44+
- name: OTEL_METRICS_EXPORTER
45+
value: otlp
46+
- name: OTEL_EXPORTER_OTLP_TIMEOUT
47+
value: "20"
48+
- name: OTEL_TRACES_SAMPLER
49+
value: parentbased_traceidratio
50+
- name: OTEL_TRACES_SAMPLER_ARG
51+
value: "0.85"
52+
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
53+
value: "true"
54+
- name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME
55+
valueFrom:
56+
fieldRef:
57+
apiVersion: v1
58+
fieldPath: metadata.name
59+
- name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME
60+
valueFrom:
61+
fieldRef:
62+
apiVersion: v1
63+
fieldPath: spec.nodeName
64+
- name: OTEL_PROPAGATORS
65+
value: jaeger,b3
66+
- name: OTEL_RESOURCE_ATTRIBUTES
67+
name: pythonapp
68+
volumeMounts:
69+
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
70+
readOnly: true
71+
- mountPath: /otel-auto-instrumentation-python
72+
name: opentelemetry-auto-instrumentation-python
73+
- args:
74+
- --feature-gates=-component.UseLocalHostAsDefaultHost
75+
- --config=env:OTEL_CONFIG
76+
env:
77+
- name: POD_NAME
78+
valueFrom:
79+
fieldRef:
80+
apiVersion: v1
81+
fieldPath: metadata.name
82+
- name: OTEL_CONFIG
83+
value: |
84+
receivers:
85+
otlp:
86+
protocols:
87+
grpc: null
88+
http: null
89+
exporters:
90+
debug: null
91+
service:
92+
pipelines:
93+
traces:
94+
exporters:
95+
- debug
96+
receivers:
97+
- otlp
98+
- name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME
99+
valueFrom:
100+
fieldRef:
101+
apiVersion: v1
102+
fieldPath: metadata.name
103+
- name: OTEL_RESOURCE_ATTRIBUTES_POD_UID
104+
valueFrom:
105+
fieldRef:
106+
apiVersion: v1
107+
fieldPath: metadata.uid
108+
- name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME
109+
valueFrom:
110+
fieldRef:
111+
apiVersion: v1
112+
fieldPath: spec.nodeName
113+
- name: OTEL_RESOURCE_ATTRIBUTES
114+
name: otc-container
115+
volumeMounts:
116+
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
117+
readOnly: true
118+
- env:
119+
- name: OTEL_NODE_IP
120+
valueFrom:
121+
fieldRef:
122+
apiVersion: v1
123+
fieldPath: status.hostIP
124+
- name: OTEL_POD_IP
125+
valueFrom:
126+
fieldRef:
127+
apiVersion: v1
128+
fieldPath: status.podIP
129+
- name: OTEL_GO_AUTO_TARGET_EXE
130+
value: /usr/src/app/productcatalogservice
131+
- name: OTEL_SERVICE_NAME
132+
value: goapp
133+
- name: OTEL_TRACES_EXPORTER
134+
value: otlp
135+
- name: OTEL_EXPORTER_OTLP_ENDPOINT
136+
value: http://localhost:4317
137+
- name: OTEL_EXPORTER_OTLP_TIMEOUT
138+
value: "20"
139+
- name: OTEL_TRACES_SAMPLER
140+
value: parentbased_traceidratio
141+
- name: OTEL_TRACES_SAMPLER_ARG
142+
value: "0.85"
143+
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
144+
value: "true"
145+
- name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME
146+
valueFrom:
147+
fieldRef:
148+
apiVersion: v1
149+
fieldPath: metadata.name
150+
- name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME
151+
valueFrom:
152+
fieldRef:
153+
apiVersion: v1
154+
fieldPath: spec.nodeName
155+
- name: OTEL_PROPAGATORS
156+
value: jaeger,b3
157+
- name: OTEL_RESOURCE_ATTRIBUTES
158+
name: opentelemetry-auto-instrumentation
159+
volumeMounts:
160+
- mountPath: /sys/kernel/debug
161+
name: kernel-debug
162+
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
163+
readOnly: true
164+
initContainers:
165+
- command:
166+
- cp
167+
- -r
168+
- /autoinstrumentation/.
169+
- /otel-auto-instrumentation-python
170+
name: opentelemetry-auto-instrumentation-python
171+
volumeMounts:
172+
- mountPath: /otel-auto-instrumentation-python
173+
name: opentelemetry-auto-instrumentation-python
174+
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
175+
readOnly: true
176+
status:
177+
containerStatuses:
178+
- name: goapp
179+
ready: true
180+
started: true
181+
- name: opentelemetry-auto-instrumentation
182+
ready: true
183+
started: true
184+
- name: otc-container
185+
ready: true
186+
started: true
187+
- name: pythonapp
188+
ready: true
189+
started: true
190+
initContainerStatuses:
191+
- name: opentelemetry-auto-instrumentation-python
192+
ready: true
193+
state:
194+
terminated:
195+
reason: Completed
196+
phase: Running
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: my-golang-multiinst
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: my-golang-multiinst
9+
replicas: 1
10+
template:
11+
metadata:
12+
labels:
13+
app: my-golang-multiinst
14+
annotations:
15+
sidecar.opentelemetry.io/inject: "true"
16+
instrumentation.opentelemetry.io/inject-go: "true"
17+
instrumentation.opentelemetry.io/otel-go-auto-target-exe: /usr/src/app/productcatalogservice
18+
instrumentation.opentelemetry.io/inject-python: "true"
19+
instrumentation.opentelemetry.io/python-container-names: "pythonapp"
20+
instrumentation.opentelemetry.io/go-container-names: "goapp"
21+
spec:
22+
serviceAccountName: otel-instrumentation-go
23+
securityContext:
24+
runAsUser: 0
25+
runAsGroup: 3000
26+
fsGroup: 3000
27+
containers:
28+
- name: goapp
29+
image: ghcr.io/open-telemetry/opentelemetry-operator/e2e-test-app-golang:main
30+
- name: pythonapp
31+
image: ghcr.io/open-telemetry/opentelemetry-operator/e2e-test-app-python:main
32+
command: ["flask", "run", "-p", "8087"]
33+
securityContext:
34+
allowPrivilegeEscalation: false
35+
capabilities:
36+
drop: ["ALL"]
37+
seccompProfile:
38+
type: RuntimeDefault
39+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
if [[ "$(kubectl api-resources --api-group=operator.openshift.io -o name)" ]]; then
4+
kubectl apply -f scc.yaml
5+
oc adm policy add-scc-to-user otel-go-instrumentation -z otel-instrumentation-go -n $NAMESPACE
6+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Test
4+
metadata:
5+
creationTimestamp: null
6+
name: instrumentation-multi-multicontainer-go
7+
spec:
8+
steps:
9+
- name: step-00
10+
try:
11+
# 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.
12+
- command:
13+
entrypoint: kubectl
14+
args:
15+
- annotate
16+
- namespace
17+
- ${NAMESPACE}
18+
- openshift.io/sa.scc.uid-range=0/0
19+
- --overwrite
20+
- command:
21+
entrypoint: kubectl
22+
args:
23+
- annotate
24+
- namespace
25+
- ${NAMESPACE}
26+
- openshift.io/sa.scc.supplemental-groups=3000/3000
27+
- --overwrite
28+
- apply:
29+
file: 00-install-collector.yaml
30+
- apply:
31+
file: 00-install-instrumentation.yaml
32+
- name: step-01
33+
try:
34+
- script:
35+
content: ./add-scc.sh
36+
- apply:
37+
file: 01-add-scc.yaml
38+
- name: step-02
39+
try:
40+
- apply:
41+
file: 02-install-app.yaml
42+
- assert:
43+
file: 02-assert.yaml
44+
catch:
45+
- podLogs:
46+
selector: app=my-golang
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: security.openshift.io/v1
2+
kind: SecurityContextConstraints
3+
metadata:
4+
name: otel-go-instrumentation
5+
allowHostDirVolumePlugin: true
6+
allowPrivilegeEscalation: true
7+
allowPrivilegedContainer: true
8+
fsGroup:
9+
type: RunAsAny
10+
runAsUser:
11+
type: RunAsAny
12+
seLinuxContext:
13+
type: RunAsAny
14+
seccompProfiles:
15+
- '*'
16+
supplementalGroups:
17+
type: RunAsAny

tests/e2e-multi-instrumentation/instrumentation-multi-multicontainer/00-install-instrumentation.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,18 @@ spec:
3838
env:
3939
- name: OTEL_SERVICE_NAME
4040
value: "goapp"
41+
nginx:
42+
configFile: /etc/nginx/conf.d/default.conf
43+
env:
44+
- name: OTEL_SERVICE_NAME
45+
value: "nginxapp"
46+
attrs:
47+
- name: NginxModuleOtelMaxQueueSize
48+
value: "4096"
49+
apacheHttpd:
50+
env:
51+
- name: OTEL_SERVICE_NAME
52+
value: "apache-httpd-app"
53+
attrs:
54+
- name: ApacheModuleOtelMaxQueueSize
55+
value: "4096"

0 commit comments

Comments
 (0)