Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kuma-cp): implement possibility to select proxies in policies by new kind Dataplane #12573

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Automaat
Copy link
Contributor

Motivation

We want to be able to target proxies by new kind Dataplane. We want to select Dataplanes by name/namespace, by labels and select single inbound by its name

Supporting documentation

This is based on Inbound policies MADR

Fix #12359

@Automaat Automaat requested a review from a team as a code owner January 16, 2025 13:52
Copy link
Contributor

Reviewer Checklist

🔍 Each of these sections need to be checked by the reviewer of the PR 🔍:
If something doesn't apply please check the box and add a justification if the reason is non obvious.

  • Is the PR title satisfactory? Is this part of a larger feature and should be grouped using > Changelog?
  • PR description is clear and complete. It Links to relevant issue as well as docs and UI issues
  • This will not break child repos: it doesn't hardcode values (.e.g "kumahq" as an image registry)
  • IPv6 is taken into account (.e.g: no string concatenation of host port)
  • Tests (Unit test, E2E tests, manual test on universal and k8s)
    • Don't forget ci/ labels to run additional/fewer tests
  • Does this contain a change that needs to be notified to users? In this case, UPGRADE.md should be updated.
  • Does it need to be backported according to the backporting policy? (this GH action will add "backport" label based on these file globs, if you want to prevent it from adding the "backport" label use no-backport-autolabel label)

@@ -13,6 +13,8 @@ import (
"github.com/kumahq/kuma/test/framework"
)

const secondaryPort = 8080
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've purposefully hardcoded this stuff as I wanted something simple, as it is used in single test, we can improve on this in the future if we need some more customizability

Signed-off-by: Marcin Skalski <[email protected]>
}

func isSelectedByName(dpp *core_mesh.DataplaneResource, ref common_api.TargetRef) bool {
return core_model.GetDisplayName(dpp.GetMeta()) == ref.Name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name and namespace in targetRefs refer to the real name/namespace of the resource, you shouldn't check the displayName, you have to construct ResourceIdentifiers from DPP and from targetRef and see if they're equal (with ==). See how we handle to[].targetRef

func resolveTargetRef[T interface {

@@ -162,6 +162,12 @@ func dppSelectedByPolicy(
return inbounds, gwListeners, gateway, nil
}
return []core_rules.InboundListener{}, nil, false, nil
case common_api.Dataplane:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extracted the function that resolves targetRefs to rules_common package, I think it should be possible to use it for DPPs as it exactly the same approach (the change is not in master yet):

func ResolveTargetRef(targetRef common_api.TargetRef, tMeta core_model.ResourceMeta, reader ResourceReader) []*ResourceSection {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement matching for the new top-level targetRef kind Dataplane
2 participants