From 499a14c3afa118916f0e16f5d22cbf553f9c01ab 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 6fcb136099..1070842451 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 53c03c5f80c838b7b54cc7000d72a12ef4841576 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 1070842451..fb509df400 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 24c20b431bcd83b5174b9e793c78a156fa83c9eb 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 ea33f60133..1506f06835 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 18a4c42478c12c7113693cf94e79eca910d8fe40 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 e53d409d3414b1799adc1b15dab662d2436293d9 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 03f5c5dc06b1baef925eb09e1bb829aa780b6aac 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 c2a14d900175100e3d97f79664092aa522d71cd0 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") }) } }