Skip to content

Commit caaf15f

Browse files
authored
add a label for policy endpoint refer to its mapped Network Policy (#45)
<!-- Thanks for sending a pull request! Here are some tips for you: 1. Ensure you have added the unit tests for your changes. 2. Ensure you have included output of manual testing done in the Testing section. 3. Ensure number of lines of code for new or existing methods are within the reasonable limit. 4. Ensure your change works on existing clusters after upgrade. --> **What type of PR is this?** <!-- Add one of the following: bug cleanup documentation feature --> improvement **Which issue does this PR fix**: **What does this PR do / Why do we need it**: We want to add a label to new created Policy Endpoint. The label refers to the parent network policy and will be used by node agent. **If an issue # is not available please add steps to reproduce and the controller logs**: **Testing done on this change**: <!-- output of manual testing/integration tests results and also attach logs showing the fix being resolved --> **Automation added to e2e**: <!-- List the e2e tests you added as part of this PR. If no, create an issue with enhancement/testing label --> **Will this PR introduce any new dependencies?**: <!-- e.g. new K8s API --> **Will this break upgrades or downgrades. Has updating a running cluster been tested?**: **Does this PR introduce any user-facing change?**: <!-- If yes, a release note update is required: Enter your extended release note in the block below. If the PR requires additional actions from users switching to the new release, include the string "action required". --> ```release-note ``` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
2 parents ae6577d + 6ccc79d commit caaf15f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ $(MOCKGEN): $(LOCALBIN)
170170
test -s $(MOCKGEN) || GOBIN=$(LOCALBIN) go install github.com/golang/mock/[email protected]
171171

172172
GOARCH=amd64
173-
BUILD_IMAGE=public.ecr.aws/docker/library/golang:1.20.6
173+
BUILD_IMAGE=public.ecr.aws/docker/library/golang:1.21.3
174174
BASE_IMAGE=public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:latest.2
175175
GO_RUNNER_IMAGE=public.ecr.aws/eks-distro/kubernetes/go-runner:v0.15.0-eks-1-27-3
176176
.PHONY: docker-buildx

pkg/policyendpoints/manager.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ import (
2323
"github.com/aws/amazon-network-policy-controller-k8s/pkg/resolvers"
2424
)
2525

26+
const (
27+
LabelKeyToParentPolicyName = "networking.k8s.io/parent-network-policy-name"
28+
)
29+
2630
type PolicyEndpointsManager interface {
2731
Reconcile(ctx context.Context, policy *networking.NetworkPolicy) error
2832
Cleanup(ctx context.Context, policy *networking.NetworkPolicy) error
@@ -298,6 +302,9 @@ func (m *policyEndpointsManager) newPolicyEndpoint(policy *networking.NetworkPol
298302
Controller: &isController,
299303
},
300304
},
305+
Labels: map[string]string{
306+
LabelKeyToParentPolicyName: policy.Name,
307+
},
301308
},
302309
Spec: policyinfo.PolicyEndpointSpec{
303310
PodSelector: &policy.Spec.PodSelector,

0 commit comments

Comments
 (0)