Skip to content

Commit

Permalink
Backport of Add HOST_IP environment variable to consul_dataplane_side…
Browse files Browse the repository at this point in the history
…car.go into release/1.3.x (#4283)

* backport of commit 6982b65

* backport of commit 63df118

* backport of commit fadb91e

* backport of commit 6e07105

* backport of commit 7f7aa40

* backport of commit 2bae8a5

* backport of commit f20395b

---------

Co-authored-by: Jeff <[email protected]>
Co-authored-by: woz5999 <[email protected]>
  • Loading branch information
3 people authored Aug 30, 2024
1 parent 72239bd commit dc6700c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/3916.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
control-plane: add missing `$HOST_IP` environment variable to to consul-dataplane sidecar containers
```
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ func (w *MeshWebhook) consulDataplaneSidecar(namespace corev1.Namespace, pod cor
Name: "DP_CREDENTIAL_LOGIN_META2",
Value: "pod-uid=$(POD_UID)",
},
{
Name: "HOST_IP",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{FieldPath: "status.hostIP"},
},
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func TestHandlerConsulDataplaneSidecar(t *testing.T) {
}
require.Equal(t, expectedProbe, container.ReadinessProbe)
require.Nil(t, container.StartupProbe)
require.Len(t, container.Env, 9)
require.Len(t, container.Env, 10)
require.Equal(t, container.Env[0].Name, "TMPDIR")
require.Equal(t, container.Env[0].Value, "/consul/connect-inject")
require.Equal(t, container.Env[2].Name, "DP_SERVICE_NODE_NAME")
Expand All @@ -235,6 +235,7 @@ func TestHandlerConsulDataplaneSidecar(t *testing.T) {
require.Equal(t, container.Env[7].Value, "pod=$(POD_NAMESPACE)/$(POD_NAME)")
require.Equal(t, container.Env[8].Name, "DP_CREDENTIAL_LOGIN_META2")
require.Equal(t, container.Env[8].Value, "pod-uid=$(POD_UID)")
require.Equal(t, container.Env[9].Name, "HOST_IP")
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ func (w *MeshWebhook) consulDataplaneSidecar(namespace corev1.Namespace, pod cor
Name: "DP_CREDENTIAL_LOGIN_META1",
Value: "pod=$(POD_NAMESPACE)/$(POD_NAME)",
},
{
Name: "HOST_IP",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{FieldPath: "status.hostIP"},
},
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func TestHandlerConsulDataplaneSidecar(t *testing.T) {
}
require.Equal(t, expectedProbe, container.ReadinessProbe)
require.Nil(t, container.StartupProbe)
require.Len(t, container.Env, 7)
require.Len(t, container.Env, 8)
require.Equal(t, container.Env[0].Name, "TMPDIR")
require.Equal(t, container.Env[0].Value, "/consul/mesh-inject")
require.Equal(t, container.Env[2].Name, "POD_NAME")
Expand All @@ -229,6 +229,7 @@ func TestHandlerConsulDataplaneSidecar(t *testing.T) {
require.Equal(t, container.Env[4].Value, "$(POD_NAME)")
require.Equal(t, container.Env[5].Name, "DP_CREDENTIAL_LOGIN_META")
require.Equal(t, container.Env[5].Value, "pod=$(POD_NAMESPACE)/$(POD_NAME)")
require.Equal(t, container.Env[7].Name, "HOST_IP")
})
}
}
Expand Down

0 comments on commit dc6700c

Please sign in to comment.