Skip to content

Commit

Permalink
add a label for policy endpoint refer to its mapped Network Policy (#45)
Browse files Browse the repository at this point in the history
<!--  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.
  • Loading branch information
haouc authored Nov 3, 2023
2 parents ae6577d + 6ccc79d commit caaf15f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ $(MOCKGEN): $(LOCALBIN)
test -s $(MOCKGEN) || GOBIN=$(LOCALBIN) go install github.com/golang/mock/[email protected]

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
Expand Down
7 changes: 7 additions & 0 deletions pkg/policyendpoints/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit caaf15f

Please sign in to comment.