diff --git a/README.md b/README.md index 6a1cdcd86c..c3dab63bfd 100644 --- a/README.md +++ b/README.md @@ -324,4 +324,4 @@ Thanks to all the people who already contributed! [godoc-img]: https://godoc.org/github.com/open-telemetry/opentelemetry-operator?status.svg [godoc]: https://godoc.org/github.com/open-telemetry/opentelemetry-operator/pkg/apis/opentelemetry/v1alpha1#OpenTelemetryCollector [contributors]: https://github.com/open-telemetry/opentelemetry-operator/graphs/contributors -[contributors-img]: https://contributors-img.web.app/image?repo=open-telemetry/opentelemetry-operator +[contributors-img]: https://contributors-img.web.app/image?repo=open-telemetry/opentelemetry-operator \ No newline at end of file diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 7394a6d059..bffbe8a58a 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,2 +1,2 @@ resources: - - manager.yaml + - manager.yaml \ No newline at end of file diff --git a/kuttl-test.yaml b/kuttl-test.yaml index fe9805a5ca..de2c6041f4 100644 --- a/kuttl-test.yaml +++ b/kuttl-test.yaml @@ -11,4 +11,4 @@ commands: - command: sleep 5s testDirs: - ./tests/e2e/ -timeout: 150 +timeout: 150 \ No newline at end of file diff --git a/pkg/instrumentation/annotation.go b/pkg/instrumentation/annotation.go index 8ce17a7c6f..3f1519b2cb 100644 --- a/pkg/instrumentation/annotation.go +++ b/pkg/instrumentation/annotation.go @@ -23,9 +23,10 @@ import ( const ( // annotationInjectJava indicates whether java auto-instrumentation should be injected or not. // Possible values are "true", "false" or "" name. - annotationInjectJava = "instrumentation.opentelemetry.io/inject-java" - annotationInjectNodeJS = "instrumentation.opentelemetry.io/inject-nodejs" - annotationInjectPython = "instrumentation.opentelemetry.io/inject-python" + annotationInjectJava = "instrumentation.opentelemetry.io/inject-java" + annotationInjectNodeJS = "instrumentation.opentelemetry.io/inject-nodejs" + annotationInjectPython = "instrumentation.opentelemetry.io/inject-python" + annotationInjectContainerName = "instrumentation.opentelemetry.io/container-names" ) // annotationValue returns the effective annotationInjectJava value, based on the annotations from the pod and namespace. diff --git a/pkg/instrumentation/helper.go b/pkg/instrumentation/helper.go new file mode 100644 index 0000000000..92a66df995 --- /dev/null +++ b/pkg/instrumentation/helper.go @@ -0,0 +1,27 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package instrumentation + +import corev1 "k8s.io/api/core/v1" + +// Calculate if we already inject InitContainers. +func IsInitContainerMissing(pod corev1.Pod) bool { + for _, initContainer := range pod.Spec.InitContainers { + if initContainer.Name == initContainerName { + return false + } + } + return true +} diff --git a/pkg/instrumentation/helper_test.go b/pkg/instrumentation/helper_test.go new file mode 100644 index 0000000000..2de3132b09 --- /dev/null +++ b/pkg/instrumentation/helper_test.go @@ -0,0 +1,74 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package instrumentation + +import ( + "testing" + + "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" +) + +func TestInitContainerMissing(t *testing.T) { + tests := []struct { + name string + pod corev1.Pod + expected bool + }{ + { + name: "InitContainer_Already_Inject", + pod: corev1.Pod{ + Spec: corev1.PodSpec{ + InitContainers: []corev1.Container{ + { + Name: "istio-init", + }, + { + Name: initContainerName, + }, + }, + }, + }, + expected: false, + }, + { + name: "InitContainer_Absent_1", + pod: corev1.Pod{ + Spec: corev1.PodSpec{ + InitContainers: []corev1.Container{ + { + Name: "istio-init", + }, + }, + }, + }, + expected: true, + }, + { + name: "InitContainer_Absent_2", + pod: corev1.Pod{ + Spec: corev1.PodSpec{}, + }, + expected: true, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + result := IsInitContainerMissing(test.pod) + assert.Equal(t, test.expected, result) + }) + } +} diff --git a/pkg/instrumentation/javaagent.go b/pkg/instrumentation/javaagent.go index aba5501100..61a3d54e2f 100644 --- a/pkg/instrumentation/javaagent.go +++ b/pkg/instrumentation/javaagent.go @@ -26,9 +26,9 @@ const ( javaJVMArgument = " -javaagent:/otel-auto-instrumentation/javaagent.jar" ) -func injectJavaagent(logger logr.Logger, javaSpec v1alpha1.Java, pod corev1.Pod) corev1.Pod { +func injectJavaagent(logger logr.Logger, javaSpec v1alpha1.Java, pod corev1.Pod, index int) corev1.Pod { // caller checks if there is at least one container - container := &pod.Spec.Containers[0] + container := &pod.Spec.Containers[index] // inject env vars for _, env := range javaSpec.Env { @@ -57,21 +57,24 @@ func injectJavaagent(logger logr.Logger, javaSpec v1alpha1.Java, pod corev1.Pod) MountPath: "/otel-auto-instrumentation", }) - pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{ - Name: volumeName, - VolumeSource: corev1.VolumeSource{ - EmptyDir: &corev1.EmptyDirVolumeSource{}, - }}) + // We just inject Volumes and init containers for the first processed container + if IsInitContainerMissing(pod) { + pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{ + Name: volumeName, + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }}) - pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{ - Name: initContainerName, - Image: javaSpec.Image, - Command: []string{"cp", "/javaagent.jar", "/otel-auto-instrumentation/javaagent.jar"}, - VolumeMounts: []corev1.VolumeMount{{ - Name: volumeName, - MountPath: "/otel-auto-instrumentation", - }}, - }) + pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{ + Name: initContainerName, + Image: javaSpec.Image, + Command: []string{"cp", "/javaagent.jar", "/otel-auto-instrumentation/javaagent.jar"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }}, + }) + } return pod } diff --git a/pkg/instrumentation/javaagent_test.go b/pkg/instrumentation/javaagent_test.go index 28573d34fa..d97853bbfb 100644 --- a/pkg/instrumentation/javaagent_test.go +++ b/pkg/instrumentation/javaagent_test.go @@ -174,7 +174,7 @@ func TestInjectJavaagent(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - pod := injectJavaagent(logr.Discard(), test.Java, test.pod) + pod := injectJavaagent(logr.Discard(), test.Java, test.pod, 0) assert.Equal(t, test.expected, pod) }) } diff --git a/pkg/instrumentation/nodejs.go b/pkg/instrumentation/nodejs.go index 810866a0af..645f9356a0 100644 --- a/pkg/instrumentation/nodejs.go +++ b/pkg/instrumentation/nodejs.go @@ -26,9 +26,9 @@ const ( nodeRequireArgument = " --require /otel-auto-instrumentation/autoinstrumentation.js" ) -func injectNodeJSSDK(logger logr.Logger, nodeJSSpec v1alpha1.NodeJS, pod corev1.Pod) corev1.Pod { +func injectNodeJSSDK(logger logr.Logger, nodeJSSpec v1alpha1.NodeJS, pod corev1.Pod, index int) corev1.Pod { // caller checks if there is at least one container - container := &pod.Spec.Containers[0] + container := &pod.Spec.Containers[index] // inject env vars for _, env := range nodeJSSpec.Env { @@ -57,21 +57,24 @@ func injectNodeJSSDK(logger logr.Logger, nodeJSSpec v1alpha1.NodeJS, pod corev1. MountPath: "/otel-auto-instrumentation", }) - pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{ - Name: volumeName, - VolumeSource: corev1.VolumeSource{ - EmptyDir: &corev1.EmptyDirVolumeSource{}, - }}) + // We just inject Volumes and init containers for the first processed container + if IsInitContainerMissing(pod) { + pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{ + Name: volumeName, + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }}) - pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{ - Name: initContainerName, - Image: nodeJSSpec.Image, - Command: []string{"cp", "-a", "/autoinstrumentation/.", "/otel-auto-instrumentation/"}, - VolumeMounts: []corev1.VolumeMount{{ - Name: volumeName, - MountPath: "/otel-auto-instrumentation", - }}, - }) + pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{ + Name: initContainerName, + Image: nodeJSSpec.Image, + Command: []string{"cp", "-a", "/autoinstrumentation/.", "/otel-auto-instrumentation/"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }}, + }) + } return pod } diff --git a/pkg/instrumentation/nodejs_test.go b/pkg/instrumentation/nodejs_test.go index f5a8bf93ad..e0a187f0ab 100644 --- a/pkg/instrumentation/nodejs_test.go +++ b/pkg/instrumentation/nodejs_test.go @@ -174,7 +174,7 @@ func TestInjectNodeJSSDK(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - pod := injectNodeJSSDK(logr.Discard(), test.NodeJS, test.pod) + pod := injectNodeJSSDK(logr.Discard(), test.NodeJS, test.pod, 0) assert.Equal(t, test.expected, pod) }) } diff --git a/pkg/instrumentation/podmutator.go b/pkg/instrumentation/podmutator.go index ba40d73b51..c442af5532 100644 --- a/pkg/instrumentation/podmutator.go +++ b/pkg/instrumentation/podmutator.go @@ -94,9 +94,17 @@ func (pm *instPodMutator) Mutate(ctx context.Context, ns corev1.Namespace, pod c return pod, nil } + // We retrieve the annotation for podname + var targetContainers = annotationValue(ns.ObjectMeta, pod.ObjectMeta, annotationInjectContainerName) + // once it's been determined that instrumentation is desired, none exists yet, and we know which instance it should talk to, // we should inject the instrumentation. - return pm.sdkInjector.inject(ctx, insts, ns, pod), nil + modifiedPod := pod + for _, currentContainer := range strings.Split(targetContainers, ",") { + modifiedPod = pm.sdkInjector.inject(ctx, insts, ns, modifiedPod, strings.TrimSpace(currentContainer)) + } + + return modifiedPod, nil } func (pm *instPodMutator) getInstrumentationInstance(ctx context.Context, ns corev1.Namespace, pod corev1.Pod, instAnnotation string) (*v1alpha1.Instrumentation, error) { diff --git a/pkg/instrumentation/python.go b/pkg/instrumentation/python.go index d6ebdddb97..6f2a77bdda 100644 --- a/pkg/instrumentation/python.go +++ b/pkg/instrumentation/python.go @@ -30,9 +30,9 @@ const ( pythonPathSuffix = "/otel-auto-instrumentation" ) -func injectPythonSDK(logger logr.Logger, pythonSpec v1alpha1.Python, pod corev1.Pod) corev1.Pod { +func injectPythonSDK(logger logr.Logger, pythonSpec v1alpha1.Python, pod corev1.Pod, index int) corev1.Pod { // caller checks if there is at least one container - container := &pod.Spec.Containers[0] + container := &pod.Spec.Containers[index] // inject env vars for _, env := range pythonSpec.Env { @@ -71,21 +71,24 @@ func injectPythonSDK(logger logr.Logger, pythonSpec v1alpha1.Python, pod corev1. MountPath: "/otel-auto-instrumentation", }) - pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{ - Name: volumeName, - VolumeSource: corev1.VolumeSource{ - EmptyDir: &corev1.EmptyDirVolumeSource{}, - }}) + // We just inject Volumes and init containers for the first processed container + if IsInitContainerMissing(pod) { + pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{ + Name: volumeName, + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }}) - pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{ - Name: initContainerName, - Image: pythonSpec.Image, - Command: []string{"cp", "-a", "/autoinstrumentation/.", "/otel-auto-instrumentation/"}, - VolumeMounts: []corev1.VolumeMount{{ - Name: volumeName, - MountPath: "/otel-auto-instrumentation", - }}, - }) + pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{ + Name: initContainerName, + Image: pythonSpec.Image, + Command: []string{"cp", "-a", "/autoinstrumentation/.", "/otel-auto-instrumentation/"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: volumeName, + MountPath: "/otel-auto-instrumentation", + }}, + }) + } return pod } diff --git a/pkg/instrumentation/python_test.go b/pkg/instrumentation/python_test.go index 3fa6d68b2a..2d510fca38 100644 --- a/pkg/instrumentation/python_test.go +++ b/pkg/instrumentation/python_test.go @@ -244,7 +244,7 @@ func TestInjectPythonSDK(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - pod := injectPythonSDK(logr.Discard(), test.Python, test.pod) + pod := injectPythonSDK(logr.Discard(), test.Python, test.pod, 0) assert.Equal(t, test.expected, pod) }) } diff --git a/pkg/instrumentation/sdk.go b/pkg/instrumentation/sdk.go index a5bf12e656..03b4259623 100644 --- a/pkg/instrumentation/sdk.go +++ b/pkg/instrumentation/sdk.go @@ -46,39 +46,48 @@ type sdkInjector struct { client client.Client } -func (i *sdkInjector) inject(ctx context.Context, insts languageInstrumentations, ns corev1.Namespace, pod corev1.Pod) corev1.Pod { +func (i *sdkInjector) inject(ctx context.Context, insts languageInstrumentations, ns corev1.Namespace, pod corev1.Pod, containerName string) corev1.Pod { if len(pod.Spec.Containers) < 1 { return pod } + // We search for specific container to inject variables and if no one is found + // We fallback to first container + var index = 0 + for idx, ctnair := range pod.Spec.Containers { + if ctnair.Name == containerName { + index = idx + } + } + // inject only to the first container for now // in the future we can define an annotation to configure this if insts.Java != nil { otelinst := *insts.Java i.logger.V(1).Info("injecting java instrumentation into pod", "otelinst-namespace", otelinst.Namespace, "otelinst-name", otelinst.Name) - pod = injectJavaagent(i.logger, otelinst.Spec.Java, pod) - pod = i.injectCommonEnvVar(otelinst, pod) - pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod) + pod = injectJavaagent(i.logger, otelinst.Spec.Java, pod, index) + pod = i.injectCommonEnvVar(otelinst, pod, index) + pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod, index) } if insts.NodeJS != nil { otelinst := *insts.NodeJS i.logger.V(1).Info("injecting nodejs instrumentation into pod", "otelinst-namespace", otelinst.Namespace, "otelinst-name", otelinst.Name) - pod = injectNodeJSSDK(i.logger, otelinst.Spec.NodeJS, pod) - pod = i.injectCommonEnvVar(otelinst, pod) - pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod) + pod = injectNodeJSSDK(i.logger, otelinst.Spec.NodeJS, pod, index) + pod = i.injectCommonEnvVar(otelinst, pod, index) + pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod, index) } if insts.Python != nil { otelinst := *insts.Python i.logger.V(1).Info("injecting python instrumentation into pod", "otelinst-namespace", otelinst.Namespace, "otelinst-name", otelinst.Name) - pod = injectPythonSDK(i.logger, otelinst.Spec.Python, pod) - pod = i.injectCommonEnvVar(otelinst, pod) - pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod) + pod = injectPythonSDK(i.logger, otelinst.Spec.Python, pod, index) + pod = i.injectCommonEnvVar(otelinst, pod, index) + pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod, index) } return pod } -func (i *sdkInjector) injectCommonEnvVar(otelinst v1alpha1.Instrumentation, pod corev1.Pod) corev1.Pod { - container := &pod.Spec.Containers[0] +func (i *sdkInjector) injectCommonEnvVar(otelinst v1alpha1.Instrumentation, pod corev1.Pod, index int) corev1.Pod { + container := &pod.Spec.Containers[index] for _, env := range otelinst.Spec.Env { idx := getIndexOfEnv(container.Env, env.Name) if idx == -1 { @@ -88,14 +97,14 @@ func (i *sdkInjector) injectCommonEnvVar(otelinst v1alpha1.Instrumentation, pod return pod } -func (i *sdkInjector) injectCommonSDKConfig(ctx context.Context, otelinst v1alpha1.Instrumentation, ns corev1.Namespace, pod corev1.Pod) corev1.Pod { - container := &pod.Spec.Containers[0] - resourceMap := i.createResourceMap(ctx, otelinst, ns, pod) +func (i *sdkInjector) injectCommonSDKConfig(ctx context.Context, otelinst v1alpha1.Instrumentation, ns corev1.Namespace, pod corev1.Pod, index int) corev1.Pod { + container := &pod.Spec.Containers[index] + resourceMap := i.createResourceMap(ctx, otelinst, ns, pod, index) idx := getIndexOfEnv(container.Env, constants.EnvOTELServiceName) if idx == -1 { container.Env = append(container.Env, corev1.EnvVar{ Name: constants.EnvOTELServiceName, - Value: chooseServiceName(pod, resourceMap), + Value: chooseServiceName(pod, resourceMap, index), }) } if otelinst.Spec.Exporter.Endpoint != "" { @@ -189,7 +198,7 @@ func (i *sdkInjector) injectCommonSDKConfig(ctx context.Context, otelinst v1alph return pod } -func chooseServiceName(pod corev1.Pod, resources map[string]string) string { +func chooseServiceName(pod corev1.Pod, resources map[string]string, index int) string { if name := resources[string(semconv.K8SDeploymentNameKey)]; name != "" { return name } @@ -205,17 +214,17 @@ func chooseServiceName(pod corev1.Pod, resources map[string]string) string { if name := resources[string(semconv.K8SPodNameKey)]; name != "" { return name } - return pod.Spec.Containers[0].Name + return pod.Spec.Containers[index].Name } // createResourceMap creates resource attribute map. // User defined attributes (in explicitly set env var) have higher precedence. -func (i *sdkInjector) createResourceMap(ctx context.Context, otelinst v1alpha1.Instrumentation, ns corev1.Namespace, pod corev1.Pod) map[string]string { +func (i *sdkInjector) createResourceMap(ctx context.Context, otelinst v1alpha1.Instrumentation, ns corev1.Namespace, pod corev1.Pod, index int) map[string]string { // get existing resources env var and parse it into a map existingRes := map[string]bool{} - existingResourceEnvIdx := getIndexOfEnv(pod.Spec.Containers[0].Env, constants.EnvOTELResourceAttrs) + existingResourceEnvIdx := getIndexOfEnv(pod.Spec.Containers[index].Env, constants.EnvOTELResourceAttrs) if existingResourceEnvIdx > -1 { - existingResArr := strings.Split(pod.Spec.Containers[0].Env[existingResourceEnvIdx].Value, ",") + existingResArr := strings.Split(pod.Spec.Containers[index].Env[existingResourceEnvIdx].Value, ",") for _, kv := range existingResArr { keyValueArr := strings.Split(strings.TrimSpace(kv), "=") if len(keyValueArr) != 2 { @@ -234,7 +243,7 @@ func (i *sdkInjector) createResourceMap(ctx context.Context, otelinst v1alpha1.I k8sResources := map[attribute.Key]string{} k8sResources[semconv.K8SNamespaceNameKey] = ns.Name - k8sResources[semconv.K8SContainerNameKey] = pod.Spec.Containers[0].Name + k8sResources[semconv.K8SContainerNameKey] = pod.Spec.Containers[index].Name // Some fields might be empty - node name, pod name // The pod name might be empty if the pod is created form deployment template k8sResources[semconv.K8SPodNameKey] = pod.Name diff --git a/pkg/instrumentation/sdk_test.go b/pkg/instrumentation/sdk_test.go index 4ee0e63c0f..4b9659439f 100644 --- a/pkg/instrumentation/sdk_test.go +++ b/pkg/instrumentation/sdk_test.go @@ -364,7 +364,7 @@ func TestSDKInjection(t *testing.T) { inj := sdkInjector{ client: k8sClient, } - pod := inj.injectCommonSDKConfig(context.Background(), test.inst, corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: test.pod.Namespace}}, test.pod) + pod := inj.injectCommonSDKConfig(context.Background(), test.inst, corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: test.pod.Namespace}}, test.pod, 0) _, err = json.MarshalIndent(pod, "", " ") assert.NoError(t, err) assert.Equal(t, test.expected, pod) @@ -399,7 +399,7 @@ func TestInjectJava(t *testing.T) { }, }, }, - }) + }, "") assert.Equal(t, corev1.Pod{ Spec: corev1.PodSpec{ Volumes: []corev1.Volume{ @@ -497,7 +497,7 @@ func TestInjectNodeJS(t *testing.T) { }, }, }, - }) + }, "") assert.Equal(t, corev1.Pod{ Spec: corev1.PodSpec{ Volumes: []corev1.Volume{ @@ -596,7 +596,7 @@ func TestInjectPython(t *testing.T) { }, }, }, - }) + }, "") assert.Equal(t, corev1.Pod{ Spec: corev1.PodSpec{ Volumes: []corev1.Volume{ diff --git a/tests/e2e/instrumentation-java-multicontainer/00-install-collector.yaml b/tests/e2e/instrumentation-java-multicontainer/00-install-collector.yaml new file mode 100644 index 0000000000..f8e1e98e07 --- /dev/null +++ b/tests/e2e/instrumentation-java-multicontainer/00-install-collector.yaml @@ -0,0 +1,23 @@ +apiVersion: opentelemetry.io/v1alpha1 +kind: OpenTelemetryCollector +metadata: + name: sidecar +spec: + mode: sidecar + config: | + receivers: + otlp: + protocols: + grpc: + http: + processors: + + exporters: + logging: + + service: + pipelines: + traces: + receivers: [otlp] + processors: [] + exporters: [logging] diff --git a/tests/e2e/instrumentation-java-multicontainer/00-install-instrumentation.yaml b/tests/e2e/instrumentation-java-multicontainer/00-install-instrumentation.yaml new file mode 100644 index 0000000000..f77a3f835f --- /dev/null +++ b/tests/e2e/instrumentation-java-multicontainer/00-install-instrumentation.yaml @@ -0,0 +1,34 @@ +apiVersion: opentelemetry.io/v1alpha1 +kind: Instrumentation +metadata: + name: java +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" + java: + env: + - name: OTEL_JAVAAGENT_DEBUG + value: "true" + - name: OTEL_INSTRUMENTATION_JDBC_ENABLED + value: "false" + - name: SPLUNK_PROFILER_ENABLED + value: "false" diff --git a/tests/e2e/instrumentation-java-multicontainer/01-assert.yaml b/tests/e2e/instrumentation-java-multicontainer/01-assert.yaml new file mode 100644 index 0000000000..0b1b9d37e2 --- /dev/null +++ b/tests/e2e/instrumentation-java-multicontainer/01-assert.yaml @@ -0,0 +1,80 @@ +apiVersion: v1 +kind: Pod +metadata: + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/container-names: myapp,myrabbit + instrumentation.opentelemetry.io/inject-java: "true" + labels: + app: my-pod-with-sidecar +spec: + containers: + - name: myapp + env: + - name: OTEL_JAVAAGENT_DEBUG + value: "true" + - name: OTEL_INSTRUMENTATION_JDBC_ENABLED + value: "false" + - name: SPLUNK_PROFILER_ENABLED + value: "false" + - name: JAVA_TOOL_OPTIONS + value: " -javaagent:/otel-auto-instrumentation/javaagent.jar" + - 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_SERVICE_NAME + value: my-deployment-with-sidecar + - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME + - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME + - name: OTEL_RESOURCE_ATTRIBUTES + - name: OTEL_PROPAGATORS + value: jaeger,b3 + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - mountPath: /otel-auto-instrumentation + name: opentelemetry-auto-instrumentation + - name: myrabbit + env: + - name: OTEL_JAVAAGENT_DEBUG + value: "true" + - name: OTEL_INSTRUMENTATION_JDBC_ENABLED + value: "false" + - name: SPLUNK_PROFILER_ENABLED + value: "false" + - name: JAVA_TOOL_OPTIONS + value: " -javaagent:/otel-auto-instrumentation/javaagent.jar" + - 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_SERVICE_NAME + value: my-deployment-with-sidecar + - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME + - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME + - name: OTEL_RESOURCE_ATTRIBUTES + - name: OTEL_PROPAGATORS + value: jaeger,b3 + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - mountPath: /otel-auto-instrumentation + name: opentelemetry-auto-instrumentation + - name: otc-container +status: + phase: Running \ No newline at end of file diff --git a/tests/e2e/instrumentation-java-multicontainer/01-install-app.yaml b/tests/e2e/instrumentation-java-multicontainer/01-install-app.yaml new file mode 100644 index 0000000000..b051624357 --- /dev/null +++ b/tests/e2e/instrumentation-java-multicontainer/01-install-app.yaml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-deployment-with-sidecar +spec: + selector: + matchLabels: + app: my-pod-with-sidecar + replicas: 1 + template: + metadata: + labels: + app: my-pod-with-sidecar + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/inject-java: "true" + instrumentation.opentelemetry.io/container-names: "myapp,myrabbit" + spec: + containers: + - name: myapp + image: ghcr.io/pavolloffay/spring-petclinic:latest + - name: myrabbit + image: rabbitmq diff --git a/tests/e2e/instrumentation-java-multicontainer/02-assert.yaml b/tests/e2e/instrumentation-java-multicontainer/02-assert.yaml new file mode 100644 index 0000000000..9ff62f1ee1 --- /dev/null +++ b/tests/e2e/instrumentation-java-multicontainer/02-assert.yaml @@ -0,0 +1,50 @@ +apiVersion: v1 +kind: Pod +metadata: + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/container-names: myrabbit + instrumentation.opentelemetry.io/inject-java: "true" + labels: + app: my-pod-with-sidecar +spec: + containers: + - name: myapp + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - name: myrabbit + env: + - name: OTEL_JAVAAGENT_DEBUG + value: "true" + - name: OTEL_INSTRUMENTATION_JDBC_ENABLED + value: "false" + - name: SPLUNK_PROFILER_ENABLED + value: "false" + - name: JAVA_TOOL_OPTIONS + value: " -javaagent:/otel-auto-instrumentation/javaagent.jar" + - 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_SERVICE_NAME + value: my-deployment-with-sidecar + - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME + - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME + - name: OTEL_RESOURCE_ATTRIBUTES + - name: OTEL_PROPAGATORS + value: jaeger,b3 + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - mountPath: /otel-auto-instrumentation + name: opentelemetry-auto-instrumentation + - name: otc-container +status: + phase: Running \ No newline at end of file diff --git a/tests/e2e/instrumentation-java-multicontainer/02-install-app.yaml b/tests/e2e/instrumentation-java-multicontainer/02-install-app.yaml new file mode 100644 index 0000000000..c963b87377 --- /dev/null +++ b/tests/e2e/instrumentation-java-multicontainer/02-install-app.yaml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-deployment-with-sidecar +spec: + selector: + matchLabels: + app: my-pod-with-sidecar + replicas: 1 + template: + metadata: + labels: + app: my-pod-with-sidecar + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/inject-java: "true" + instrumentation.opentelemetry.io/container-names: "myrabbit" + spec: + containers: + - name: myapp + image: ghcr.io/pavolloffay/spring-petclinic:latest + - name: myrabbit + image: rabbitmq diff --git a/tests/e2e/instrumentation-nodejs-multicontainer/00-install-collector.yaml b/tests/e2e/instrumentation-nodejs-multicontainer/00-install-collector.yaml new file mode 100644 index 0000000000..f8e1e98e07 --- /dev/null +++ b/tests/e2e/instrumentation-nodejs-multicontainer/00-install-collector.yaml @@ -0,0 +1,23 @@ +apiVersion: opentelemetry.io/v1alpha1 +kind: OpenTelemetryCollector +metadata: + name: sidecar +spec: + mode: sidecar + config: | + receivers: + otlp: + protocols: + grpc: + http: + processors: + + exporters: + logging: + + service: + pipelines: + traces: + receivers: [otlp] + processors: [] + exporters: [logging] diff --git a/tests/e2e/instrumentation-nodejs-multicontainer/00-install-instrumentation.yaml b/tests/e2e/instrumentation-nodejs-multicontainer/00-install-instrumentation.yaml new file mode 100644 index 0000000000..f77a3f835f --- /dev/null +++ b/tests/e2e/instrumentation-nodejs-multicontainer/00-install-instrumentation.yaml @@ -0,0 +1,34 @@ +apiVersion: opentelemetry.io/v1alpha1 +kind: Instrumentation +metadata: + name: java +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" + java: + env: + - name: OTEL_JAVAAGENT_DEBUG + value: "true" + - name: OTEL_INSTRUMENTATION_JDBC_ENABLED + value: "false" + - name: SPLUNK_PROFILER_ENABLED + value: "false" diff --git a/tests/e2e/instrumentation-nodejs-multicontainer/01-assert.yaml b/tests/e2e/instrumentation-nodejs-multicontainer/01-assert.yaml new file mode 100644 index 0000000000..88c16084e5 --- /dev/null +++ b/tests/e2e/instrumentation-nodejs-multicontainer/01-assert.yaml @@ -0,0 +1,68 @@ +apiVersion: v1 +kind: Pod +metadata: + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/container-names: myapp,myrabbit + instrumentation.opentelemetry.io/inject-nodejs: "true" + labels: + app: my-pod-with-sidecar +spec: + containers: + - name: myapp + env: + - name: NODE_OPTIONS + value: ' --require /otel-auto-instrumentation/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_SERVICE_NAME + value: my-deployment-with-sidecar + - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME + - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME + - name: OTEL_RESOURCE_ATTRIBUTES + - name: OTEL_PROPAGATORS + value: jaeger,b3 + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - mountPath: /otel-auto-instrumentation + name: opentelemetry-auto-instrumentation + - name: myrabbit + env: + - name: NODE_OPTIONS + value: ' --require /otel-auto-instrumentation/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_SERVICE_NAME + value: my-deployment-with-sidecar + - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME + - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME + - name: OTEL_RESOURCE_ATTRIBUTES + - name: OTEL_PROPAGATORS + value: jaeger,b3 + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - mountPath: /otel-auto-instrumentation + name: opentelemetry-auto-instrumentation + - name: otc-container +status: + phase: Running \ No newline at end of file diff --git a/tests/e2e/instrumentation-nodejs-multicontainer/01-install-app.yaml b/tests/e2e/instrumentation-nodejs-multicontainer/01-install-app.yaml new file mode 100644 index 0000000000..2514ba5e5f --- /dev/null +++ b/tests/e2e/instrumentation-nodejs-multicontainer/01-install-app.yaml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-deployment-with-sidecar +spec: + selector: + matchLabels: + app: my-pod-with-sidecar + replicas: 1 + template: + metadata: + labels: + app: my-pod-with-sidecar + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/inject-nodejs: "true" + instrumentation.opentelemetry.io/container-names: "myapp,myrabbit" + spec: + containers: + - name: myapp + image: ghcr.io/anuraaga/express-hello-world:latest + - name: myrabbit + image: rabbitmq diff --git a/tests/e2e/instrumentation-nodejs-multicontainer/02-assert.yaml b/tests/e2e/instrumentation-nodejs-multicontainer/02-assert.yaml new file mode 100644 index 0000000000..c54cdd1679 --- /dev/null +++ b/tests/e2e/instrumentation-nodejs-multicontainer/02-assert.yaml @@ -0,0 +1,44 @@ +apiVersion: v1 +kind: Pod +metadata: + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/container-names: myrabbit + instrumentation.opentelemetry.io/inject-nodejs: "true" + labels: + app: my-pod-with-sidecar +spec: + containers: + - name: myapp + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - name: myrabbit + env: + - name: NODE_OPTIONS + value: ' --require /otel-auto-instrumentation/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_SERVICE_NAME + value: my-deployment-with-sidecar + - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME + - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME + - name: OTEL_RESOURCE_ATTRIBUTES + - name: OTEL_PROPAGATORS + value: jaeger,b3 + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - mountPath: /otel-auto-instrumentation + name: opentelemetry-auto-instrumentation + - name: otc-container +status: + phase: Running \ No newline at end of file diff --git a/tests/e2e/instrumentation-nodejs-multicontainer/02-install-app.yaml b/tests/e2e/instrumentation-nodejs-multicontainer/02-install-app.yaml new file mode 100644 index 0000000000..ea8f74d0b0 --- /dev/null +++ b/tests/e2e/instrumentation-nodejs-multicontainer/02-install-app.yaml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-deployment-with-sidecar +spec: + selector: + matchLabels: + app: my-pod-with-sidecar + replicas: 1 + template: + metadata: + labels: + app: my-pod-with-sidecar + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/inject-nodejs: "true" + instrumentation.opentelemetry.io/container-names: "myrabbit" + spec: + containers: + - name: myapp + image: ghcr.io/anuraaga/express-hello-world:latest + - name: myrabbit + image: rabbitmq diff --git a/tests/e2e/instrumentation-python-multicontainer/00-install-collector.yaml b/tests/e2e/instrumentation-python-multicontainer/00-install-collector.yaml new file mode 100644 index 0000000000..f8e1e98e07 --- /dev/null +++ b/tests/e2e/instrumentation-python-multicontainer/00-install-collector.yaml @@ -0,0 +1,23 @@ +apiVersion: opentelemetry.io/v1alpha1 +kind: OpenTelemetryCollector +metadata: + name: sidecar +spec: + mode: sidecar + config: | + receivers: + otlp: + protocols: + grpc: + http: + processors: + + exporters: + logging: + + service: + pipelines: + traces: + receivers: [otlp] + processors: [] + exporters: [logging] diff --git a/tests/e2e/instrumentation-python-multicontainer/00-install-instrumentation.yaml b/tests/e2e/instrumentation-python-multicontainer/00-install-instrumentation.yaml new file mode 100644 index 0000000000..f77a3f835f --- /dev/null +++ b/tests/e2e/instrumentation-python-multicontainer/00-install-instrumentation.yaml @@ -0,0 +1,34 @@ +apiVersion: opentelemetry.io/v1alpha1 +kind: Instrumentation +metadata: + name: java +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" + java: + env: + - name: OTEL_JAVAAGENT_DEBUG + value: "true" + - name: OTEL_INSTRUMENTATION_JDBC_ENABLED + value: "false" + - name: SPLUNK_PROFILER_ENABLED + value: "false" diff --git a/tests/e2e/instrumentation-python-multicontainer/01-assert.yaml b/tests/e2e/instrumentation-python-multicontainer/01-assert.yaml new file mode 100644 index 0000000000..6f09aa6137 --- /dev/null +++ b/tests/e2e/instrumentation-python-multicontainer/01-assert.yaml @@ -0,0 +1,68 @@ +apiVersion: v1 +kind: Pod +metadata: + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/container-names: myapp,myrabbit + instrumentation.opentelemetry.io/inject-python: "true" + labels: + app: my-pod-with-sidecar +spec: + containers: + - name: myapp + env: + - name: PYTHONPATH + value: /otel-auto-instrumentation/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation + - name: OTEL_TRACES_EXPORTER + value: otlp_proto_http + - 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_SERVICE_NAME + value: my-deployment-with-sidecar + - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME + - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME + - name: OTEL_RESOURCE_ATTRIBUTES + - name: OTEL_PROPAGATORS + value: jaeger,b3 + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - mountPath: /otel-auto-instrumentation + name: opentelemetry-auto-instrumentation + - name: myrabbit + env: + - name: PYTHONPATH + value: /otel-auto-instrumentation/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation + - name: OTEL_TRACES_EXPORTER + value: otlp_proto_http + - 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_SERVICE_NAME + value: my-deployment-with-sidecar + - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME + - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME + - name: OTEL_RESOURCE_ATTRIBUTES + - name: OTEL_PROPAGATORS + value: jaeger,b3 + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - mountPath: /otel-auto-instrumentation + name: opentelemetry-auto-instrumentation + - name: otc-container +status: + phase: Running \ No newline at end of file diff --git a/tests/e2e/instrumentation-python-multicontainer/01-install-app.yaml b/tests/e2e/instrumentation-python-multicontainer/01-install-app.yaml new file mode 100644 index 0000000000..82910ec979 --- /dev/null +++ b/tests/e2e/instrumentation-python-multicontainer/01-install-app.yaml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-deployment-with-sidecar +spec: + selector: + matchLabels: + app: my-pod-with-sidecar + replicas: 1 + template: + metadata: + labels: + app: my-pod-with-sidecar + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/inject-python: "true" + instrumentation.opentelemetry.io/container-names: "myapp,myrabbit" + spec: + containers: + - name: myapp + image: ghcr.io/anuraaga/flask-hello-world:latest + - name: myrabbit + image: rabbitmq diff --git a/tests/e2e/instrumentation-python-multicontainer/02-assert.yaml b/tests/e2e/instrumentation-python-multicontainer/02-assert.yaml new file mode 100644 index 0000000000..904fa1d382 --- /dev/null +++ b/tests/e2e/instrumentation-python-multicontainer/02-assert.yaml @@ -0,0 +1,44 @@ +apiVersion: v1 +kind: Pod +metadata: + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/container-names: myrabbit + instrumentation.opentelemetry.io/inject-python: "true" + labels: + app: my-pod-with-sidecar +spec: + containers: + - name: myapp + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - name: myrabbit + env: + - name: PYTHONPATH + value: /otel-auto-instrumentation/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation + - name: OTEL_TRACES_EXPORTER + value: otlp_proto_http + - 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_SERVICE_NAME + value: my-deployment-with-sidecar + - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME + - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME + - name: OTEL_RESOURCE_ATTRIBUTES + - name: OTEL_PROPAGATORS + value: jaeger,b3 + volumeMounts: + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - mountPath: /otel-auto-instrumentation + name: opentelemetry-auto-instrumentation + - name: otc-container +status: + phase: Running \ No newline at end of file diff --git a/tests/e2e/instrumentation-python-multicontainer/02-install-app.yaml b/tests/e2e/instrumentation-python-multicontainer/02-install-app.yaml new file mode 100644 index 0000000000..8101f7d169 --- /dev/null +++ b/tests/e2e/instrumentation-python-multicontainer/02-install-app.yaml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-deployment-with-sidecar +spec: + selector: + matchLabels: + app: my-pod-with-sidecar + replicas: 1 + template: + metadata: + labels: + app: my-pod-with-sidecar + annotations: + sidecar.opentelemetry.io/inject: "true" + instrumentation.opentelemetry.io/inject-python: "true" + instrumentation.opentelemetry.io/container-names: "myrabbit" + spec: + containers: + - name: myapp + image: ghcr.io/anuraaga/flask-hello-world:latest + - name: myrabbit + image: rabbitmq