File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,9 @@ const (
33
33
34
34
EnvPodName = "OTEL_RESOURCE_ATTRIBUTES_POD_NAME"
35
35
EnvPodUID = "OTEL_RESOURCE_ATTRIBUTES_POD_UID"
36
+ EnvPodIP = "OTEL_POD_IP"
36
37
EnvNodeName = "OTEL_RESOURCE_ATTRIBUTES_NODE_NAME"
38
+ EnvNodeIP = "OTEL_NODE_IP"
37
39
38
40
FlagApacheHttpd = "enable-apache-httpd-instrumentation"
39
41
FlagDotNet = "enable-dotnet-instrumentation"
Original file line number Diff line number Diff line change @@ -235,6 +235,32 @@ func getContainerIndex(containerName string, pod corev1.Pod) int {
235
235
236
236
func (i * sdkInjector ) injectCommonEnvVar (otelinst v1alpha1.Instrumentation , pod corev1.Pod , index int ) corev1.Pod {
237
237
container := & pod .Spec .Containers [index ]
238
+
239
+ idx := getIndexOfEnv (container .Env , constants .EnvNodeIP )
240
+ if idx == - 1 {
241
+ container .Env = append (container .Env , corev1.EnvVar {
242
+ Name : constants .EnvNodeIP ,
243
+ ValueFrom : & corev1.EnvVarSource {
244
+ FieldRef : & corev1.ObjectFieldSelector {
245
+ FieldPath : "status.hostIP" ,
246
+ },
247
+ },
248
+ })
249
+ }
250
+
251
+ idx = getIndexOfEnv (container .Env , constants .EnvPodIP )
252
+ if idx == - 1 {
253
+ container .Env = append (container .Env , corev1.EnvVar {
254
+ Name : constants .EnvPodIP ,
255
+ ValueFrom : & corev1.EnvVarSource {
256
+ FieldRef : & corev1.ObjectFieldSelector {
257
+ APIVersion : "v1" ,
258
+ FieldPath : "status.podIP" ,
259
+ },
260
+ },
261
+ })
262
+ }
263
+
238
264
for _ , env := range otelinst .Spec .Env {
239
265
idx := getIndexOfEnv (container .Env , env .Name )
240
266
if idx == - 1 {
You can’t perform that action at this time.
0 commit comments