Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 04d36c0

Browse files
committed
Inject pod_ip into initcontainer
Signed-off-by: Keith Mattix II <[email protected]>
1 parent dc50d7e commit 04d36c0

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

pkg/injector/init_container.go

+11
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,16 @@ func getInitContainerSpec(containerName string, cfg configurator.Configurator, o
3232
"-c",
3333
iptablesInitCommand,
3434
},
35+
Env: []corev1.EnvVar{
36+
{
37+
Name: "POD_IP",
38+
ValueFrom: &corev1.EnvVarSource{
39+
FieldRef: &corev1.ObjectFieldSelector{
40+
APIVersion: "v1",
41+
FieldPath: "status.podIP",
42+
},
43+
},
44+
},
45+
},
3546
}
3647
}

pkg/injector/init_container_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ EOF
8484
RunAsNonRoot: &runAsNonRootFalse,
8585
RunAsUser: &runAsUserID,
8686
},
87+
Env: []corev1.EnvVar{
88+
{
89+
Name: "POD_IP",
90+
ValueFrom: &corev1.EnvVarSource{
91+
FieldRef: &corev1.ObjectFieldSelector{
92+
APIVersion: "v1",
93+
FieldPath: "status.podIP",
94+
},
95+
},
96+
},
97+
},
8798
Stdin: false,
8899
StdinOnce: false,
89100
TTY: false,
@@ -150,6 +161,17 @@ EOF
150161
RunAsNonRoot: &runAsNonRootFalse,
151162
RunAsUser: &runAsUserID,
152163
},
164+
Env: []corev1.EnvVar{
165+
{
166+
Name: "POD_IP",
167+
ValueFrom: &corev1.EnvVarSource{
168+
FieldRef: &corev1.ObjectFieldSelector{
169+
APIVersion: "v1",
170+
FieldPath: "status.podIP",
171+
},
172+
},
173+
},
174+
},
153175
Stdin: false,
154176
StdinOnce: false,
155177
TTY: false,

0 commit comments

Comments
 (0)