From fd6ddd11ef810f92190fe0d7490f2314ce21d595 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Wed, 17 Jul 2024 21:41:15 +0400 Subject: [PATCH] feat: provide POD_IP env var to scheduler and controller-manager Fixes #9031 Signed-off-by: Andrey Smirnov --- .../k8s/control_plane_static_pod.go | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/internal/app/machined/pkg/controllers/k8s/control_plane_static_pod.go b/internal/app/machined/pkg/controllers/k8s/control_plane_static_pod.go index ed7bac7faa..5b54319571 100644 --- a/internal/app/machined/pkg/controllers/k8s/control_plane_static_pod.go +++ b/internal/app/machined/pkg/controllers/k8s/control_plane_static_pod.go @@ -646,7 +646,18 @@ func (ctrl *ControlPlaneStaticPodController) manageControllerManager(ctx context Name: k8s.ControllerManagerID, Image: cfg.Image, Command: args, - Env: env, + Env: append( + []v1.EnvVar{ + { + Name: "POD_IP", + ValueFrom: &v1.EnvVarSource{ + FieldRef: &v1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, + }, + env...), VolumeMounts: append([]v1.VolumeMount{ { Name: "secrets", @@ -785,7 +796,18 @@ func (ctrl *ControlPlaneStaticPodController) manageScheduler(ctx context.Context Name: k8s.SchedulerID, Image: cfg.Image, Command: args, - Env: env, + Env: append( + []v1.EnvVar{ + { + Name: "POD_IP", + ValueFrom: &v1.EnvVarSource{ + FieldRef: &v1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, + }, + env...), VolumeMounts: append([]v1.VolumeMount{ { Name: "secrets",