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

[NET-5586][rebased] v2: Support virtual port references in config #20371

Merged
merged 5 commits into from
Jan 29, 2024

Conversation

ndhanushkodi
Copy link
Contributor

@ndhanushkodi ndhanushkodi commented Jan 26, 2024

Description

Rebased @zalimeni's PR #20327 on top of the computed failover policy changes and pushed here just to not lose the changes on the original PR in case something is wrong with this one.

I needed to change the failover controller and failover controller test to make it work with the new computed failover policy changes that got merged into main.

Original PR contents:

Currently, when referencing a service in a parent/backend ref in an xRoute (example), destination ref in a Destinations resource, or port in an xPolicy config key, we only allow operators to specify workload port name (i.e the Service's spec.ports[0].targetPort in K8s terms). This is not an intuitive UX for K8s users, who will be thinking of the service ports (i.e. Service spec.ports[0].port in K8s) rather than workload ports when creating these objects.

This change updates our interpretation of these reference fields/keys (parent, backend, destination), s.t.:

  • A numeric value will be exclusively interpreted to indicate a ServicePort.virtual_port
  • A non-numeric value will be exclusively interpreted to indicate a ServicePort.target_port (this supports VMs/Nomad and other cases where network virtual ports are not used, and port names are expected to be in reference to workload ports, not service ports)

The effect should be a superset of existing functionality, with the additional option of specifying a virtual port (numeric string) where a service target port was previously required. Note that this does not apply to workload port definitions and endpoints config (which references workload port names), as virtual ports are only a facility of the service abstraction.


Testing & Reproduction steps

Links

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

zalimeni and others added 5 commits January 26, 2024 15:16
In addition to Service target port references, allow users to specify a
port by stringified virtual port value. This is useful in environments
such as Kubernetes where typical configuration is written in terms of
Service virtual ports rather than workload (pod) target port names.

Retaining the option of referencing target ports by name supports VMs,
Nomad, and other use cases where virtual ports are not used by default.

To support both uses cases at once, we will strictly interpret port
references based on whether the value is numeric. See updated
`ServicePort` docs for more details.
Update proto and generated .go files with docs reflecting virtual port
reference support.
Add coverage for mixed virtual and target port references to existing
test.
…r policy and assert error conditions against FailoverPolicy and ComputedFailoverPolicy resources
@ndhanushkodi ndhanushkodi requested a review from a team as a code owner January 26, 2024 23:19
@ndhanushkodi ndhanushkodi added pr/no-backport pr/no-changelog PR does not need a corresponding .changelog entry labels Jan 26, 2024
@ndhanushkodi ndhanushkodi merged commit 92aab7e into main Jan 29, 2024
101 of 105 checks passed
@ndhanushkodi ndhanushkodi deleted the zalimeni/net-5586-virtual-port-backup branch January 29, 2024 18:43
ndhanushkodi added a commit to hashicorp/consul-k8s that referenced this pull request Jan 31, 2024
…#3528)

- [This change in consul](hashicorp/consul#20371) involves now interpreting whether xRoute/FailoverPolicy/DestinationPolicy resource service references use either the service port (virtualPort in consul) or service target port (targetPort in consul). To make this decision unambiguously:
> This change updates our interpretation of these reference fields/keys (parent, backend, destination), s.t.:
>
> * A numeric value will be exclusively interpreted to indicate a ServicePort.virtual_port
> * A non-numeric value will be exclusively interpreted to indicate a ServicePort.target_port (this supports VMs/Nomad and other cases where network virtual ports are not used, and port names are expected to be in reference to workload ports, not service ports)

- If a K8s service targetport is allowed to be the stringified version of a number, it will be ambiguous in consul what to interpret the string "portID" as. 

- This change makes it such that the string port can never be a number, and will always also have alpha characters by prefixing "cslport-" to the workload port if the workload port name is unspecified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/no-backport pr/no-changelog PR does not need a corresponding .changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants