Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Adds Network Publishing API #151

Merged
merged 4 commits into from
Jan 29, 2021
Merged

Conversation

danehans
Copy link
Contributor

@danehans danehans commented Dec 4, 2020

Updates the Contour API type to support network endpoint management.

Note: The API design supports managing Envoy network endpoints with the ability to add Contour network endpoints in the future.

Fixes: #70

Signed-off-by: Daneyon Hansen daneyonhansen@gmail.com

@@ -89,6 +96,49 @@ type NamespaceSpec struct {
RemoveOnDeletion bool `json:"removeOnDeletion,omitempty"`
}

// EndpointPublishing defines the schema to publish network endpoints and represents
// the publishing type.
type EndpointPublishing struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the future, fields will be added to support config knobs for the different endpoint publishing types. EndpointPublishing will become a union type and Type will be the union discriminator.

Copy link
Contributor

@jpeach jpeach left a comment

Choose a reason for hiding this comment

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

Approving, since this seems like a very reasonable API to me. Not merging yet, since I think the EndpointPublishing nomenclature is confusing and I'd like to give people a chance to suggest alternatives.

@danehans
Copy link
Contributor Author

danehans commented Dec 4, 2020

@jpeach during yesterday's community meeting we discussed whether it's necessary to manage the network endpoints of Contour. @stevesloka provided a use-case where Contour runs in a separate cluster from the managed Envoys, but we agreed that's not applicable since each cluster would run contour-operator. If Contour network endpoint publishing is not required today, should this API be designed to support the use case in the future. For example:

Current

spec:
  endpointPublishing:
    type: LoadBalancerService # Publishes Envoy's network endpoints using a k8s LB svc.

Here is an example of an API that can support Envoy (dataPlane) and Contour (controlPlane) network endpoint publishing.
Option 1

spec:
  endpointPublishing:
    dataPlane:
      type: LoadBalancerService # Publishes Envoy's network endpoints using a k8s LB svc.
    # future (if needed)
    controlPlane:
      type: LoadBalancerService # Publishes Contour's network endpoints using a k8s LB svc.

Here is an example of an API that abstracts the control and data planes at spec:
Option 2

spec:
  controlPlane:
    endpointPublishing:
      type: LoadBalancerService # Publishes Envoy's network endpoints using a k8s LB svc.
  # future (if needed)
  dataPlane:
    endpointPublishing:
      type: LoadBalancerService # Publishes Envoy's network endpoints using a k8s LB svc.

I anticipate future data-plane and control-plane specific requirements that the API will need to support. I'm beginning to think it makes sense to separate data/control planes at spec. All other spec-level fields will be applicable to both the control and data planes. Thoughts? cc: @stevesloka @skriss @Miciah

@danehans
Copy link
Contributor Author

danehans commented Dec 4, 2020

I created this sheet to get input from the community for naming the API.

@danehans danehans changed the title Adds Network Endpoint Publishing API WIP: Adds Network Endpoint Publishing API Dec 7, 2020
type EndpointPublishing struct {
// Type is the type of publishing strategy to use. Valid values are:
//
// * LoadBalancerService
Copy link
Member

Choose a reason for hiding this comment

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

nit: Should we drop Service from these names and just call them LoadBalancer, or NodePort to match Kubernetes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stevesloka as I mention in #151 (comment), future types may not use a k8s Service resource. I thought it made sense to use types that are backed by a k8s service to include "Service" in the name. Take LoadBalancerService for example, what if a future LoadBalancer type is added that creates a hardware load balancer outside the k8s cluster?

LoadBalancerServiceStrategyType EndpointPublishingType = "LoadBalancerService"

// NodePortService publishes an endpoint using a Kubernetes NodePort Service.
NodePortServiceStrategyType EndpointPublishingType = "NodePortService"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add ClusterIP for those who might need an internal ingress controller not exposed outside the cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stevesloka I agree that ClusterIP or ClusterIPService will be a supported type. I would like to keep the initial API represented in this PR as minimal as possible and add types as needed. To provide parity with Contour's rendered manifest, this initial API needs to only support LoadBalancerService and NodePortService.

@danehans
Copy link
Contributor Author

@jpeach @stevesloka although a k8s Service will back the EndpointPublishing types in the initial API, other non Service-based types may be added in the future. For example, HostNetwork would set hostNetwork: true for the Envoy DaemonSet and not create a Service. I agree that Endpoint may cause confusion, so let me see try to figure out a better name. Feel free to provide any naming suggestions in #151 (comment).

@danehans danehans changed the title WIP: Adds Network Endpoint Publishing API Adds Network Publishing API Dec 10, 2020
@danehans
Copy link
Contributor Author

@stevesloka @jpeach @Miciah commit 0652869 renames the API to avoid confusion with the k8s Endpoints API. The commit also redesigns the API to support managing Contour network publishing (if the need arises). Here are a few examples of a Contour with the proposed API changes:

A Default Contour

apiVersion: operator.projectcontour.io/v1alpha1
kind: Contour
metadata:
  name: contour-sample
spec: {} # Envoy will use container ports 80/443 and be published using a k8s LB service.

A Contour with a NodePort Service

apiVersion: operator.projectcontour.io/v1alpha1
kind: Contour
metadata:
  name: contour-sample
spec:
  networkPublishing:
    envoy:
      type: NodePortService

A Contour with Non-Standard Container Ports

apiVersion: operator.projectcontour.io/v1alpha1
kind: Contour
metadata:
  name: contour-sample
spec:
  networkPublishing:
    envoy:
      httpContainerPort: 8080
      httpsContainerPort: 8443

Copy link
Member

@youngnick youngnick left a comment

Choose a reason for hiding this comment

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

I'm in a similar boat to @jpeach on this one. I think the API itself looks great, but suggest that we reuse the Service APIs naming and go with GatewayPublishing instead.

I can certainly be talked out of that, but I think we're heading that way anyway, so let's just call it the same thing.

api/v1alpha1/contour_types.go Show resolved Hide resolved
@danehans danehans changed the title Adds Network Publishing API WIP: Adds Network Publishing API Dec 17, 2020
@danehans danehans changed the title WIP: Adds Network Publishing API Adds Network Publishing API Jan 5, 2021
@danehans danehans added this to the v1.12.0 milestone Jan 5, 2021
@danehans danehans force-pushed the eps_api branch 2 times, most recently from f856831 to 8ce6db6 Compare January 12, 2021 19:14
@danehans danehans changed the title Adds Network Publishing API WIP: Adds Network Publishing API Jan 12, 2021
@danehans danehans changed the title WIP: Adds Network Publishing API Adds Network Publishing API Jan 12, 2021
Copy link
Member

@stevesloka stevesloka left a comment

Choose a reason for hiding this comment

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

I think this looks good now pending any other comments (I know there's been a bunch of questions back & forth). =)

@danehans
Copy link
Contributor Author

Per #171, Contour will be utilized by Service APIs for gatewayclass.spec.parametersRef. Since this PR will be used for provisioning Contour using the Contour CRD or Service APIs, I would like to proceed with the NetworkPublishing API naming scheme. @youngnick @jpeach PTAL and let me know if you have any questions or concerns.

@danehans danehans changed the title Adds Network Publishing API WIP: Adds Network Publishing API Jan 21, 2021
@danehans danehans changed the title WIP: Adds Network Publishing API Adds Network Publishing API Jan 25, 2021
@danehans
Copy link
Contributor Author

Per projectcontour/contour#3263, commit 9226ee0 updates the NetworkPublishing API to support a list of container ports instead of specifying individual fields for http and https container ports. This commit also updates the default port numbers to match upstream, i.e. 8443 for secure and 8080 for insecure. cc: @youngnick @stevesloka

@danehans danehans force-pushed the eps_api branch 2 times, most recently from c93f10a to 93907f9 Compare January 26, 2021 06:27
// Possible values are "External" and "Internal".
//
// +kubebuilder:default=External
Scope LoadBalancerScope `json:"scope,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Is the operator going to take on specific implementations (e.g. https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer).

If the goal isn't to take those on then possibly a new ProviderSetting (or something) are a better spot to allow users to define those specific exceptions. We might need both to cover anyone who might need specific annotations but aren't yet supported in the operator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stevesloka yes, the operator will support provider-specific LB settings through ProviderParameters, i.e. LB connection tuning. All the major cloud providers support internal/external LB scoping, so I think it's appropriate to define scope outside ProviderParameters.

Copy link
Member

@stevesloka stevesloka left a comment

Choose a reason for hiding this comment

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

Just one small question and it looks great to me! Thanks for the work on this @danehans! 🎉

I think we should just implement it at this point and see how things shake out while we're still in alpha/beta versions.

//
LoadBalancer LoadBalancerStrategy `json:"loadBalancer,omitempty"`

// ContainerPorts is a list of container ports to expose from the Envoy container(s).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@youngnick @stevesloka @skriss do you agree that at least 2 ContainerPorts must be defined to support Envoy's insecure and secure services? I'm unsure if it's possible or if a use-case exists to run the insecure/secure services on the same container port. Do you agree that 6 container ports is an appropriate maximum?

Copy link
Member

Choose a reason for hiding this comment

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

I think those are totally acceptable numbers for now. We can change this later.

@danehans danehans force-pushed the eps_api branch 2 times, most recently from a55be73 to 7de12b9 Compare January 26, 2021 23:24
Signed-off-by: Daneyon Hansen <daneyonhansen@gmail.com>
Signed-off-by: Daneyon Hansen <daneyonhansen@gmail.com>
Signed-off-by: Daneyon Hansen <daneyonhansen@gmail.com>
Signed-off-by: Daneyon Hansen <daneyonhansen@gmail.com>
@danehans
Copy link
Contributor Author

Commit f1fa042 changes MaxItem=2 and godocs for the containerPort field based on feedback from the maintainers call.

Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

nothing to add here, LGTM

@stevesloka stevesloka merged commit d3edaf9 into projectcontour:main Jan 29, 2021
@danehans danehans deleted the eps_api branch February 23, 2021 23:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configurable Contour and Envoy Network Endpoint Publishing
5 participants