flagger icon indicating copy to clipboard operation
flagger copied to clipboard

canary activation removes unspecified ports from the pre-existing service

Open bdols opened this issue 2 years ago • 1 comments

Describe the bug

with two ports defined in the targeted Service, after canary activation, only the port specified in the Canary object remains defined in the Service.

apiVersion: flagger.app/v1beta1
kind: Canary
metadata:
  name: es-api
  namespace: dev-es-api
spec:
  analysis:
    interval: 120s
    maxWeight: 50
    metrics:
    - interval: 1m
      name: request-success-rate
      thresholdRange:
        min: 99
    - interval: 30s
      name: request-duration
      thresholdRange:
        max: 500
    stepWeight: 5
    threshold: 5
    webhooks:
    - metadata:
        cmd: 'curl -f -X POST -H ''Content-Type: application/json'' https://<snip/> --data @/scaffolding/es-api.json'
        type: bash
      name: acceptance-test
      timeout: 30s
      type: pre-rollout
      url: http://loadtester.test/
    - metadata:
        cmd: 'hey -z 2m -q 5 -c 1 -T application/json -m POST -D /scaffolding/es-api.json <snip/>'
        type: bash
      name: load-test
      timeout: 150s
      type: rollout
      url: http://loadtester.test/
  autoscalerRef:
    apiVersion: autoscaling/v2beta2
    kind: HorizontalPodAutoscaler
    name: es-api
  progressDeadlineSeconds: 150
  service:
    port: 5000
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: es-api

flagger.log

To Reproduce

start with this Service:

apiVersion: v1
kind: Service
metadata:
  name: es-api
  namespace: dev-es-api
spec:
  ports:
  - name: http
    port: 5000
    protocol: TCP
    targetPort: http
  - name: metrics
    port: 5558
    protocol: TCP
    targetPort: metrics
  type: ClusterIP

after activating Canary, meaning primary is active and tests have passed, the service changes to this:

apiVersion: v1
kind: Service
metadata:
  name: es-api
  namespace: dev-es-api
spec:
  ports:
  - name: http
    port: 5000
    protocol: TCP
    targetPort: http
  type: ClusterIP

only the 5000 port as declared in the Canary object remains

Expected behavior

the additional port remains in the declared Service

Additional context

  • Flagger version: 1.27.0
  • Kubernetes version: 1.21
  • Service Mesh provider: linkerd
  • Ingress provider: ingress-nginx

bdols avatar Jan 13 '23 15:01 bdols

I'm having the same issue. The doc recommended to use portDiscovery: true if the service has multiple ports, but portDiscovery: true does not works for linkerd, at least for me. https://docs.flagger.app/faq#multiple-ports.

Additional context Flagger version: 1.32.0 Kubernetes version: v1.26.6-gke.1700

rye-sw avatar Oct 04 '23 22:10 rye-sw