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/publishing-strategies-api #302

Merged
merged 27 commits into from
Jul 29, 2024
Merged

Conversation

roivaz
Copy link
Member

@roivaz roivaz commented Jul 8, 2024

Adds new PublishingStrategies API to unify how workloads are exposed.

Design

Any workload that exposes an endpoint that can be consumed by clients (either in-cluster or out-of-cluster clients) exposes the api field publishingStrategies, which allows a user to configure how the endpoint/s is/are exposed. This is called a "publishing strategy". All workload endpoints have a default publishing strategy, which right now can be one of two types: "Simple" or "Marin3rSidecar".
Other design decisions:

  • All workload endpoints are identified by a name (i.e.: HTTP, Proxy, etc).
  • When a user specifies configuration through the workload's custom resource, the user defined configuration is merged with the defaults. This is the default mode of operation for the API, but there is also a 'replace' mode.
  • By default, specifying configuration for a non-defined service is an error unless the option create: true is set to declare the intent of creating a new endpoint.
  • The 'replace' mode can be used to avoid merging with the default configuration. In the replace mode, the user must specify all fields. Replace mode still requires create: true when adding a new endpoint.
  • Replace mode can be used to duplicate an endpoint's strategy, declaring for example both a Simple and a Marin3rStrategy for the same endpoint, effectively causing the endpoint to be exposed by two different strategies at the same time. The user can then control the dns to decide how to route traffic to each strategy.

Simple strategy

The service is exposed through a k8s Service resource, which can be a ClusterIP Service or a LoadBalancer Service (either NLB or ELB).

publishingStrategies:
  mode: Merge
  endpoints:
    - name: HTTP
      # strategy to use
      strategy: Simple
      simple:
        # overrides the default service name
        serviceName: service-name
        # the type of service: ClusterIP/ELB/NLB
        serviceType: NLB
        # configures the external-dns annotation in the Service resource
        externalDnsHostnames:
          - example.com
        # AWS network load balancer configuration in the form of Service annotations
        # Check API definition for a comprehensive list of options
        networkLoadBalancerConfig:
          proxyProtocol: true
        # overrides the default list of ports for the Service resource
        servicePorts:
          - name: http
            protocol: TCP
            port: 80
            targetPort: echo-api-http
          - name: https
            protocol: TCP
            port: 443
            targetPort: echo-api-https

Marin3rStrategy

publishingStrategies:
  endpoints:
    - name: HTTP
      # strategy to use
      strategy: Marin3rSidecar
      # configuration options for the Marin3rSidecar strategy
      marin3rSidecar:
        # envoy dynamic configurations
        dynamicConfigs:
          http:
            generatorVersion: v1
            listenerHttp:
              allowHeadersWithUnderscores: true
              enableHttp2: false
              port: 38080
              proxyProtocol: true
              routeConfigName: router_external
        # override envoy image
        envoyImage: "envoyproxy/envoy:v1.22.11"
        # configures the external-dns annotation in the Service resource
        externalDnsHostnames:
          - example.com
        # AWS network load balancer configuration in the form of Service annotations
        # Check API definition for a comprehensive list of options
        networkLoadBalancerConfig:
          proxyProtocol: true
        # envoy node-id. If not specified the workload name is used
        nodeID: backend-listener
        # envoy sidecar port definitions
        ports:
          - name: http
            port: 15080
          - name: http-internal
            port: 15081
          - name: https
            port: 15443
          - name: metrics
            port: 15000
        # envoy sidecar resource requirements
        resources: {}
        # overrides the default Service name
        serviceName: service-name
        # overrides the default list of ports for the Service resource
        servicePorts:
          - name: http
            port: 80
            protocol: TCP
            targetPort: http
          - name: https
            port: 443
            protocol: TCP
            targetPort: https
        # the type of service: ClusterIP/ELB/NLB
        serviceType: NLB
        # configures Marin3r's shutdown manager lifecycle hooks
        shtdnmgrExtraLifecycleHooks:
          - backend-listener

Upgrade

Each controller will upgrade it's the custom resources to migrate from the old API fields to the new publishingStrategies field. As default Service names have changed, the controllers will check if the Services already exists and keep the old names to avoid recreation of Service, which most certainly would lead to loss of Service during the upgrade. This has been tested in dev but still requires thorough testing in the staging environment.

roivaz added 18 commits June 13, 2024 16:22
Each workload will define its endpoint/s publishing default so a
mechanism is required to override the default with the options passed by
the user in the external API.
To unlock the possibility of deploying 2 different publishing strategies
for the same endpoint, the whole list of strategies needs to be
replaces, because with Merge only one strategy can exists per endpoint,
otherwise it wouldn't know how to do the merge.
Replace allows exposing the same endpoint through several different
strategies in parallel, which unlocks the possiblity of DNS based migrations without
downtime.
@3scale-robot 3scale-robot added needs-kind Indicates a PR or issue lacks a `kind/foo` label and requires one. needs-priority Indicates a PR or issue lacks a `priority/foo` label and requires one. needs-size Indicates a PR or issue lacks a `size/foo` label and requires one. size/XL Requires about a week to complete the PR or the issue. and removed needs-size Indicates a PR or issue lacks a `size/foo` label and requires one. labels Jul 8, 2024
@roivaz
Copy link
Member Author

roivaz commented Jul 9, 2024

/kind feature
/priority important-longterm
/assign

@3scale-robot 3scale-robot added kind/feature Categorizes issue or PR as related to a new feature. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple sprints to complete. and removed needs-kind Indicates a PR or issue lacks a `kind/foo` label and requires one. labels Jul 9, 2024
@3scale-robot 3scale-robot removed the needs-priority Indicates a PR or issue lacks a `priority/foo` label and requires one. label Jul 9, 2024
@roivaz roivaz force-pushed the feat/publishing_strategies_api branch 2 times, most recently from 27b9378 to 64ab328 Compare July 12, 2024 10:37
@roivaz roivaz force-pushed the feat/publishing_strategies_api branch from 675e62e to 47a9e81 Compare July 17, 2024 09:40
@roivaz roivaz force-pushed the feat/publishing_strategies_api branch from 1b547ca to 7ce0e0b Compare July 17, 2024 14:08
@raelga
Copy link
Contributor

raelga commented Jul 29, 2024

/lgtm

Outstanding work, congrats @roivaz

@3scale-robot 3scale-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 29, 2024
@3scale-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: be46faffb136d92ea398c0812ac2f0204a4f14c4

@roivaz
Copy link
Member Author

roivaz commented Jul 29, 2024

/approve

@3scale-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: roivaz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@3scale-robot 3scale-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2024
@3scale-robot 3scale-robot merged commit efc7788 into main Jul 29, 2024
4 checks passed
@3scale-robot 3scale-robot deleted the feat/publishing_strategies_api branch July 29, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple sprints to complete. size/XL Requires about a week to complete the PR or the issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants