Skip to content

Explicitly define multiple ports under canary specs (portDiscovery alternative) #927

@jhuliano

Description

@jhuliano

Describe the feature

Be able to explicitly define multiple ports I want to expose for a give deployment.

Currently the only alternative for exposing more than one port is using portDiscovery: true (doc ref), but, this has a few shortcomings:

1. can't choose exactly what ports to expose
Say I have two containers, one for my app and another with a statsd sidecar for the metric collection, with portDiscovery the ports for statsd container will also be exposed on the k8s-service and I don't want that (since from my app container I will just do: localhost:{statsd_port}).

2. can't define a port different than the targetPort
Say my app container has two ports, one for gRPC and another for HTTP, but, on the service I want to "remap" those ports to some standard while allowing the deployment to choose what port they want to use, eg:

apiVersion: v1
kind: Service
spec:
  ports:
    - name: http
      port: 80
      targetPort: 8210
      protocol: TCP
    - name: grpc
      port: 81
      targetPort: 8211
      protocol: TCP

Proposed solution

Add an option to the canary spec so we can define multiple ports explicitly instead of just one, eg:

apiVersion: flagger.app/v1beta1
kind: Canary
spec:
  service:
    ports:
      - name: http
         port: 80
         targetPort: 8210
      - name: grpc
         port: 81
         targetPort: 8211

This matches the k8s service spec and solves the problem of needing port auto-discovery at all.

The only downside I can see to this is that it becomes a bit confusing to have port configurations under spec.service and under spec.service.ports, but, I think this could be useful to also deprecate the use of the port configuration both under spec.service and the spec.service.portDiscovery in favor of the new spec.service.ports.

Any alternatives you've considered?

Using portDiscovery and living with its shortcomings (both having exposed ports I don't want to expose and obligating the deployments to follow specific port standards. eg: 80 for HTTP and 81 for gRPC).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions