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

multi-protocol in single port is not supported #2934

Closed
KimMJ opened this issue Sep 2, 2020 · 8 comments
Closed

multi-protocol in single port is not supported #2934

KimMJ opened this issue Sep 2, 2020 · 8 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@KimMJ
Copy link

KimMJ commented Sep 2, 2020

It seems kustomize does not support "same port, different protocol" service.
Here is my test:

How to Reproduce

Files

kustomize
├── kustomization.yaml
├── service-patch.yaml
└── service.yaml

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: myapp
spec:
  selector:
    app: myapp
  ports:
  - port: 1234
    name: test-tcp
    protocol: TCP
  - port: 1234
    name: test-udp
    protocol: UDP

service-patch.yaml

kind: Service
metadata:
  name: myapp
  labels:
    test: label

kustomization.yaml

resources:
  - service.yaml
patches:
  - path: service-patch.yaml
    target:
      kind: Service
      name: myapp

Command

$ kustomize version
{Version:kustomize/v3.8.2 GitCommit:e2973f6ecc9be6187cfd5ecf5e180f842249b3c6 BuildDate:2020-08-29T17:44:01Z GoOs:linux GoArch:amd64}

$ kustomize build .
apiVersion: v1
kind: Service
metadata:
  labels:
    test: label
  name: myapp
spec:
  ports:
  - name: test-tcp
    port: 1234
    protocol: TCP
  - name: test-tcp
    port: 1234
    protocol: TCP
  selector:
    app: myapp

As you can see, after kustomize build to add test=label label in Service type,
test-udp port is changed to TCP protocol and its name so that Kubernetes throw an duplicated port name error.

Kubernetes could use multiple protocol with same port like this:

$ kubectl get svc myapp 
NAME    TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)             AGE
myapp   ClusterIP   10.96.223.96   <none>        1234/TCP,1234/UDP   12m

but kustomize couldn't make it.

@KimMJ
Copy link
Author

KimMJ commented Sep 2, 2020

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 2, 2020
@Shell32-Natsu
Copy link
Contributor

dup with #2767. We are working on it but it's not a simple fix.

@KimMJ
Copy link
Author

KimMJ commented Sep 3, 2020

thanks @Shell32-Natsu . then I close this

@lackhoa
Copy link

lackhoa commented Jan 28, 2021

This git issue was closed, but has the github issue been fixed?

@natasha41575
Copy link
Contributor

@lackhoa Yes, the issue has been fixed with the introduction of #3159

The merge key for service ports has been changed from [port] to [port, protocol].

@lackhoa
Copy link

lackhoa commented Jan 29, 2021

@natasha41575 I tested this on 3.9.2 and it's not working (but the OP's case worked):

kustomization.yaml

resources:
  - resource.yaml
patches:
  - path: patch.yaml
    target:
      kind: StatefulSet
      name: myapp

resource.yaml

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: myapp
spec:
  template:
    spec:
      containers:
        - name: consul
          image: "hashicorp/consul:1.9.1"
          ports:
            - containerPort: 8500
              name: http
            - containerPort: 8501
              name: https
            - containerPort: 8301
              protocol: "TCP"
              name: serflan-tcp
            - containerPort: 8301
              protocol: "UDP"
              name: serflan-udp
            - containerPort: 8302
              name: serfwan
            - containerPort: 8300
              name: server
            - containerPort: 8600
              name: dns-tcp
              protocol: "TCP"
            - containerPort: 8600
              name: dns-udp
              protocol: "UDP"

patch.yalm

kind: StatefulSet
metadata:
  name: myapp
  labels:
    test: label

Result:

kustomize build .
apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    test: label
  name: myapp
spec:
  template:
    spec:
      containers:
      - image: hashicorp/consul:1.9.1
        name: consul
        ports:
        - containerPort: 8500
          name: http
        - containerPort: 8501
          name: https
        - containerPort: 8301
          name: serflan-udp
          protocol: UDP
        - containerPort: 8301
          name: serflan-udp
          protocol: UDP
        - containerPort: 8302
          name: serfwan
        - containerPort: 8300
          name: server
        - containerPort: 8600
          name: dns-udp
          protocol: UDP
        - containerPort: 8600
          name: dns-udp
          protocol: UDP

@natasha41575
Copy link
Contributor

@lackhoa would you mind filing a new issue for your use case and tagging me? I will start investigating this today and Monday

@yydzhou
Copy link

yydzhou commented Aug 9, 2022

@natasha41575 Here is the new issue. I have updated my binary to newest version and the problem still exists. I have tested with same set of port info for a deployment merge, it's not working neither.
#4752

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.
Projects
None yet
Development

No branches or pull requests

6 participants