From 47ebc4d784d36919052693f1767c40c4cd2c45fd Mon Sep 17 00:00:00 2001 From: Hao Zhou Date: Fri, 20 Oct 2023 21:29:45 +0000 Subject: [PATCH] add a label for policy endpoint refer to its mapped Network Policy --- Makefile | 2 +- pkg/policyendpoints/manager.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cbac00f..c9b3af8 100644 --- a/Makefile +++ b/Makefile @@ -170,7 +170,7 @@ $(MOCKGEN): $(LOCALBIN) test -s $(MOCKGEN) || GOBIN=$(LOCALBIN) go install github.com/golang/mock/mockgen@v1.6.0 GOARCH=amd64 -BUILD_IMAGE=public.ecr.aws/docker/library/golang:1.20.6 +BUILD_IMAGE=public.ecr.aws/docker/library/golang:1.21.3 BASE_IMAGE=public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:latest.2 GO_RUNNER_IMAGE=public.ecr.aws/eks-distro/kubernetes/go-runner:v0.15.0-eks-1-27-3 .PHONY: docker-buildx diff --git a/pkg/policyendpoints/manager.go b/pkg/policyendpoints/manager.go index 14b68e9..44a35c3 100644 --- a/pkg/policyendpoints/manager.go +++ b/pkg/policyendpoints/manager.go @@ -23,6 +23,10 @@ import ( "github.com/aws/amazon-network-policy-controller-k8s/pkg/resolvers" ) +const ( + LabelKeyToParentPolicyName = "networking.k8s.io/parent-network-policy-name" +) + type PolicyEndpointsManager interface { Reconcile(ctx context.Context, policy *networking.NetworkPolicy) error Cleanup(ctx context.Context, policy *networking.NetworkPolicy) error @@ -298,6 +302,9 @@ func (m *policyEndpointsManager) newPolicyEndpoint(policy *networking.NetworkPol Controller: &isController, }, }, + Labels: map[string]string{ + LabelKeyToParentPolicyName: policy.Name, + }, }, Spec: policyinfo.PolicyEndpointSpec{ PodSelector: &policy.Spec.PodSelector,