kubernetes-sigs / kubernetes-sigs/kustomize
patchesStrategicMerge is not working for service of single port but multiple protocols.
- Dominant language
- Go
- Stars
- 12.2k
- Forks
- 2.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 25
Description
**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**
Contributor guide
Research direction
Run the reproduction using service.yaml, service-patch.yaml, and kustomization.yaml, then compare the rendered Service with the expected output. Trace the strategic-merge handling for Kubernetes Service ports, especially entries sharing a port with different protocols. Done means the missing TCP and non-UDP entries are retained and the reproduction is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100