kubernetes-sigs / kustomize

Customization of kubernetes YAML configurations
Apache License 2.0
10.98k stars 2.25k forks source link

Defining same port twice with multiple names gets reduced to one port #5786

Open Mangal-Nidhi opened 1 week ago

Mangal-Nidhi commented 1 week ago

What happened?

We want to define container port twice as below, with different names, so that same port can be referred by different names depending on the context.

containers:
     ports:
             - name: app
               containerPort: 9090
               protocol: TCP
            -  name: metrics
               containerPort: 9090
               protocol: TCP

This works with plain kubernetes. But after doing kustomize build output gets reduced to

containers:
     ports:
            - name: metrics
               containerPort: 9090
               protocol: TCP

Is this a bug or why there is a limitation to define the port only once?

Thanks, Nidhi

What did you expect to happen?

Expected both port names to be available in output.

How can we reproduce it (as minimally and precisely as possible)?

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- resources.yaml
# resources.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: test-object
data:
  placeholder: data

Expected output

containers:
     ports:
             - name: app
               containerPort: 9090
               protocol: TCP
            -  name: metrics
               containerPort: 9090
               protocol: TCP

Actual output

containers:
     ports:
            -  name: metrics
               containerPort: 9090
               protocol: TCP

Kustomize version

5.4.3

Operating system

Windows

k8s-ci-robot commented 1 week ago

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.