diff --git a/pkg/networkservice/common/createpod/option.go b/pkg/networkservice/common/createpod/option.go index e6f4811..f527564 100644 --- a/pkg/networkservice/common/createpod/option.go +++ b/pkg/networkservice/common/createpod/option.go @@ -26,16 +26,6 @@ func WithNamespace(namespace string) Option { } } -// WithLabelsKey sets labels key value. Default value is "NSM_LABELS". -// -// Environment variable with specified labels key is set on pod creation, -// to notify the pod about the node it is being create on. -func WithLabelsKey(labelsKey string) Option { - return func(t *createPodServer) { - t.labelsKey = labelsKey - } -} - // WithNameGenerator sets function to be used for pod name generation. // Default behavior is to append a random uuid to the template name. func WithNameGenerator(nameGenerator func(templateName, nodeName string) string) Option { diff --git a/pkg/networkservice/common/createpod/server.go b/pkg/networkservice/common/createpod/server.go index c72ebca..bb7d0a8 100644 --- a/pkg/networkservice/common/createpod/server.go +++ b/pkg/networkservice/common/createpod/server.go @@ -43,7 +43,6 @@ type createPodServer struct { client kubernetes.Interface podTemplate *corev1.Pod namespace string - labelsKey string nodeMap nodeInfoMap nameGenerator func(templateName, nodeName string) string } @@ -63,8 +62,7 @@ func NewServer(ctx context.Context, client kubernetes.Interface, podTemplate *co podTemplate: podTemplate.DeepCopy(), client: client, namespace: "default", - labelsKey: "NSM_LABELS", - nameGenerator: func(templateName, nodeName string) string { return templateName + uuid.New().String() }, + nameGenerator: func(templateName, nodeName string) string { return templateName + "-" + uuid.New().String() }, } for _, opt := range options { @@ -137,12 +135,6 @@ func (s *createPodServer) createPod(ctx context.Context, nodeName, podName strin podTemplate := s.podTemplate.DeepCopy() podTemplate.ObjectMeta.Name = podName podTemplate.Spec.NodeName = nodeName - for i := range podTemplate.Spec.Containers { - podTemplate.Spec.Containers[i].Env = append(podTemplate.Spec.Containers[i].Env, corev1.EnvVar{ - Name: s.labelsKey, - Value: "nodeName: " + nodeName, - }) - } _, err := s.client.CoreV1().Pods(s.namespace).Create(ctx, podTemplate, metav1.CreateOptions{}) return err diff --git a/pkg/networkservice/common/createpod/server_test.go b/pkg/networkservice/common/createpod/server_test.go index 88f028e..c520712 100644 --- a/pkg/networkservice/common/createpod/server_test.go +++ b/pkg/networkservice/common/createpod/server_test.go @@ -87,8 +87,6 @@ func TestCreatePod_RepeatedRequest(t *testing.T) { want := podTemplate.DeepCopy() want.Spec.NodeName = nodeName1 - want.Spec.Containers[0].Env = []corev1.EnvVar{{Name: "NSM_LABELS", Value: "nodeName: " + nodeName1}} - want.Spec.Containers[1].Env = []corev1.EnvVar{{Name: "NSM_LABELS", Value: "nodeName: " + nodeName1}} require.Equal(t, pod.Spec, want.Spec) pod.Status.Phase = "Succeeded"