Skip to content

patchesStrategicMerge is not working for service of single port but multiple protocols. #4752

Description

@yydzhou

Describe the bug
base: service.yaml

apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80

overlay: service-patch.yaml

apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  ports:
  - name: rtmpk
    port: 1986
    protocol: UDP
    targetPort: 1986
  - name: rtmp
    port: 1935
    targetPort: 1935
  - name: rtmpq
    port: 1935
    protocol: UDP
    targetPort: 1935
  - name: https
    port: 443
    targetPort: 443
  - name: http3
    port: 443
    protocol: UDP
    targetPort: 443

kustomization.yaml

resources:
- ../../base
patchesStrategicMerge:
- service-patch.yaml

Files that can reproduce the issue

Expected output
expected output

apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  ports:
  - name: rtmpk
    port: 1986
    protocol: UDP
    targetPort: 1986
  - name: rtmp
    port: 1935
    targetPort: 1935
  - name: rtmpq
    port: 1935
    protocol: UDP
    targetPort: 1935
  - name: https
    port: 443
    targetPort: 443
  - name: http3
    port: 443
    protocol: UDP
    targetPort: 443
   - name: http
    port: 80
    protocol: TCP
    targetPort: 80

Actual output
Actually output:

apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  ports:
  - name: rtmpk
    port: 1986
    protocol: UDP
    targetPort: 1986
  - name: rtmpq
    port: 1935
    protocol: UDP
    targetPort: 1935
  - name: http3
    port: 443
    protocol: UDP
    targetPort: 443
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80

Kustomize version
{Version:kustomize/v4.5.7 GitCommit:56d82a8378dfc8dc3b3b1085e5a6e67b82966bd7 BuildDate:2022-08-02T16:28:01Z GoOs:darwin GoArch:amd64}

Platform

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Status
    Todo
    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions