From 6311a0ea8623a48d1db971fd1b0197150519ed9e Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 16 Apr 2024 21:07:13 +0000 Subject: [PATCH 1/7] backport of commit 6982b65ec569b71bb987240ad984a76a7e4da272 --- .../connect-inject/webhook/consul_dataplane_sidecar.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go b/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go index 045fdea3e3..e841bfa017 100644 --- a/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go +++ b/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go @@ -139,6 +139,12 @@ func (w *MeshWebhook) consulDataplaneSidecar(namespace corev1.Namespace, pod cor FieldRef: &corev1.ObjectFieldSelector{FieldPath: "metadata.uid"}, }, }, + { + Name: "HOST_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{FieldPath: "status.hostIP"}, + }, + }, { Name: "DP_CREDENTIAL_LOGIN_META", Value: "pod=$(POD_NAMESPACE)/$(POD_NAME)", From 46f604eb9f43bcdeb14ee530871399814191d01c Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 16 Apr 2024 21:10:13 +0000 Subject: [PATCH 2/7] backport of commit 63df1186f352575202f5b38438e7b8b0b4504936 --- .../webhook/consul_dataplane_sidecar.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go b/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go index e841bfa017..a18c15b999 100644 --- a/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go +++ b/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go @@ -139,12 +139,6 @@ func (w *MeshWebhook) consulDataplaneSidecar(namespace corev1.Namespace, pod cor FieldRef: &corev1.ObjectFieldSelector{FieldPath: "metadata.uid"}, }, }, - { - Name: "HOST_IP", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{FieldPath: "status.hostIP"}, - }, - }, { Name: "DP_CREDENTIAL_LOGIN_META", Value: "pod=$(POD_NAMESPACE)/$(POD_NAME)", @@ -159,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{ { From 69d514673e335b99ffab2f5f377a23c3cfd2366a Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 16 Apr 2024 21:11:36 +0000 Subject: [PATCH 3/7] backport of commit fadb91efb9bb8cd1ab08c69f71654ae7c40edfd7 --- .../connect-inject/webhook/consul_dataplane_sidecar_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/control-plane/connect-inject/webhook/consul_dataplane_sidecar_test.go b/control-plane/connect-inject/webhook/consul_dataplane_sidecar_test.go index dd0c62d3ff..9edd91f9e2 100644 --- a/control-plane/connect-inject/webhook/consul_dataplane_sidecar_test.go +++ b/control-plane/connect-inject/webhook/consul_dataplane_sidecar_test.go @@ -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") @@ -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") }) } } From 57d5b9ee27b3425bc1e343e4a59001e3c0870f0d Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 16 Apr 2024 21:17:11 +0000 Subject: [PATCH 4/7] backport of commit 6e0710585db5956f7611fd714e4407c70f5685a5 --- control-plane/connect-inject/webhook/3916.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 control-plane/connect-inject/webhook/3916.txt diff --git a/control-plane/connect-inject/webhook/3916.txt b/control-plane/connect-inject/webhook/3916.txt new file mode 100644 index 0000000000..a653f63480 --- /dev/null +++ b/control-plane/connect-inject/webhook/3916.txt @@ -0,0 +1,3 @@ +```release-note:bug +control-plane: add missing `$HOST_IP` environment variable to to consul-dataplane sidecar containers +``` From fabeeb8eb0e2f6c4ab445ab30c6e7bdae8e75ac6 Mon Sep 17 00:00:00 2001 From: woz5999 Date: Tue, 16 Apr 2024 21:20:32 +0000 Subject: [PATCH 5/7] backport of commit 7f7aa406671fa886196a6e30ca9bed9a1fe2324c --- {control-plane/connect-inject/webhook => .changelog}/3916.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {control-plane/connect-inject/webhook => .changelog}/3916.txt (100%) diff --git a/control-plane/connect-inject/webhook/3916.txt b/.changelog/3916.txt similarity index 100% rename from control-plane/connect-inject/webhook/3916.txt rename to .changelog/3916.txt From 2713b78b457d4d49d456f3360635095ac4e37518 Mon Sep 17 00:00:00 2001 From: woz5999 Date: Tue, 16 Apr 2024 21:20:39 +0000 Subject: [PATCH 6/7] backport of commit 2bae8a516f8614c82fab41528518d74d24f87064 --- .../connect-inject/webhookv2/consul_dataplane_sidecar.go | 6 ++++++ .../webhookv2/consul_dataplane_sidecar_test.go | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar.go b/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar.go index e49e3b44e3..7ea1379c5a 100644 --- a/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar.go +++ b/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar.go @@ -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{ { diff --git a/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar_test.go b/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar_test.go index e5eb319a02..79ec3127c1 100644 --- a/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar_test.go +++ b/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar_test.go @@ -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") @@ -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[6].Name, "HOST_IP") }) } } From 9d737bb259fb72036fe6bae50ce400b2a6eacbf0 Mon Sep 17 00:00:00 2001 From: woz5999 Date: Tue, 16 Apr 2024 21:35:57 +0000 Subject: [PATCH 7/7] backport of commit f20395b795f60082516f1875d78037beef76b16f --- .../connect-inject/webhookv2/consul_dataplane_sidecar_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar_test.go b/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar_test.go index 79ec3127c1..1b3dcc0493 100644 --- a/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar_test.go +++ b/control-plane/connect-inject/webhookv2/consul_dataplane_sidecar_test.go @@ -229,7 +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[6].Name, "HOST_IP") + require.Equal(t, container.Env[7].Name, "HOST_IP") }) } }