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

PATCH merges Services with same port, different protocol #47249

Closed
thockin opened this issue Jun 9, 2017 · 14 comments
Closed

PATCH merges Services with same port, different protocol #47249

thockin opened this issue Jun 9, 2017 · 14 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. sig/network Categorizes an issue or PR as relevant to SIG Network.

Comments

@thockin
Copy link
Member

thockin commented Jun 9, 2017

xref: #47221 (comment)

Specifically, DNS uses the same port number in TCP and UDP. This is valid when the object is created, but any PATCH operation related to Service ports will merge those together, which is wrong.

@mengqiy This is the gift that keeps on giving. I am so sorry.

@k8s-github-robot
Copy link

@thockin There are no sig labels on this issue. Please add a sig label by:
(1) mentioning a sig: @kubernetes/sig-<team-name>-misc
(2) specifying the label manually: /sig <label>

Note: method (1) will trigger a notification to the team. You can find the team list here and label list here

@k8s-github-robot k8s-github-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jun 9, 2017
@xiangpengzhao
Copy link
Contributor

/sig network

@k8s-ci-robot k8s-ci-robot added the sig/network Categorizes an issue or PR as relevant to SIG Network. label Jun 9, 2017
@k8s-github-robot k8s-github-robot removed the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jun 9, 2017
@mengqiy
Copy link
Member

mengqiy commented Jun 9, 2017

/assign

@mengqiy
Copy link
Member

mengqiy commented Jun 12, 2017

cc: @pwittrock

@xiangpengzhao
Copy link
Contributor

Any updates here?

xref: #49295

@mengqiy
Copy link
Member

mengqiy commented Aug 28, 2017

@xiangpengzhao #46161 and kubernetes/community#476 are trying to solve this issue. But they will not get in in 1.8 :(

@xiangpengzhao
Copy link
Contributor

Thanks @mengqiy! I will wait for it at the next milestone:)

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or @fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 3, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 8, 2018
@mengqiy
Copy link
Member

mengqiy commented Feb 9, 2018

/remove-lifecycle rotten
/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Feb 9, 2018
@thockin thockin added the triage/unresolved Indicates an issue that can not or will not be resolved. label Mar 8, 2019
@athenabot
Copy link

@mengqiy
If this issue has been triaged, please comment /remove-triage unresolved.

If you aren't able to handle this issue, consider unassigning yourself and/or adding the help-wanted label.

🤖 I am a bot run by vllry. 👩‍🔬

@freehan freehan added kind/bug Categorizes issue or PR as related to a bug. and removed triage/unresolved Indicates an issue that can not or will not be resolved. labels May 16, 2019
@Ewocker
Copy link

Ewocker commented Feb 18, 2020

Trying to create a bug and found this existing issue. Will put some content here for those who are interested in reproduce.

What happened:
On patching targetPorts of service that contains "ports" with duplicate port number, only the first port is updated with the change.

What you expected to happen:
Both port should get updated with correct targetPort.

How to reproduce it (as minimally and precisely as possible):

$ kubectl create ns test

$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
  name: test
  namespace: test
  labels:
    app: "test"
spec:
  selector:
    k8s-app: kube-dns
  ports:
  - name: dns
    port: 53
    protocol: UDP
  - name: dns-tcp
    port: 53
    protocol: TCP
EOF

# Note the targetPort values change here
$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
  name: test
  namespace: test
  labels:
    app: "test"
spec:
  selector:
    k8s-app: kube-dns
  ports:
  - name: dns
    port: 53
    protocol: UDP
    targetPort: 5678
  - name: dns-tcp
    port: 53
    protocol: TCP
    targetPort: 1234
EOF

# Notice the targetPort value for port "dns" has the value 5678
# which is configured for port "dns-tcp"
$ kubectl get svc test -n test -o yaml

Anything else we need to know?:
The fundamental problem is patchMergeKey for service is "port" whereas the uniqueness of a port comes from "port+protocol" (Ex. you cannot have duplicate port with same port number and protocol). Similar issue also happens for "ContainerPort".
Sample usage can be found in coredns and kubedns deploy spec.

Note that below is the patch spec for above example:

{
  "spec": {
    "$setElementOrder/ports": [
      {
        "port": 53
      },
      {
        "port": 53
      }
    ],
    "ports": [
      {
        "port": 53,
        "targetPort": "1234"
      },
      {
        "port": 53,
        "targetPort": "5678"
      }
    ]
  }
}

@khenidak
Copy link
Contributor

#104486

@thockin
Copy link
Member Author

thockin commented Jan 16, 2023

Dup of #103544 which has more information

@thockin thockin closed this as completed Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. sig/network Categorizes an issue or PR as relevant to SIG Network.
Projects
None yet
Development

No branches or pull requests

10 participants