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

upgrading to 1.8 broke Service backwards compatibility by not allowing the same target port multiple times #53526

Closed
jhorwit2 opened this issue Oct 6, 2017 · 10 comments · Fixed by #53576
Assignees
Labels
area/api Indicates an issue on api area. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. sig/network Categorizes an issue or PR as relevant to SIG Network.

Comments

@jhorwit2
Copy link
Contributor

jhorwit2 commented Oct 6, 2017

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug
/sig api
/sig network

What happened:

Prior to 1.8 it was possible to specify the same targetPort in the service definition multiple times. In 1.8, validation was added that prohibited this.

What you expected to happen:
I expect backwards compatibility for GA resources, so having the same targetPort multiple times should be allowed. This is a valid use case IMO for target ports. If you take the example below, the load balancer terminates SSL, so that manifest allows the nginx pods to receive http on port 80 while the load balancer serves traffic on 80 & 443.

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

kubectl apply -f - <<EOF 
kind: Service
apiVersion: v1
metadata:
  name: nginx-service
  annotations:
    service.beta.kubernetes.io/oci-load-balancer-ssl-ports: "443"
    service.beta.kubernetes.io/oci-load-balancer-tls-secret: ssl-certificate-secret
spec:
  selector:
    app: nginx
  type: LoadBalancer
  ports:
  - name: http
    port: 80
    targetPort: 80
  - name: https
    port: 443
    targetPort: 80
EOF

Anything else we need to know?:

Original ticket for validation: #47222

@k8s-ci-robot k8s-ci-robot added the sig/network Categorizes an issue or PR as relevant to SIG Network. label Oct 6, 2017
@jhorwit2
Copy link
Contributor Author

jhorwit2 commented Oct 6, 2017

cc @thockin @xiangpengzhao

@jhorwit2
Copy link
Contributor Author

jhorwit2 commented Oct 6, 2017

/kind bug

/area api

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. area/api Indicates an issue on api area. labels Oct 6, 2017
@xiangpengzhao
Copy link
Contributor

Sounds reasonable. @thockin WDYT?

@cmluciano
Copy link

@kubernetes/sig-network-api-reviews

@k8s-ci-robot k8s-ci-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Oct 17, 2017
@fwynyk
Copy link

fwynyk commented Oct 26, 2017

Hi, same problem here. Trying to create a service with helm, both 80 and 443 ports using same targetPort, and got this error:

Error: UPGRADE FAILED: failed to create resource: Service "#####" is invalid: spec.ports[1].targetPort: Duplicate value: intstr.IntOrString{Type:0, IntVal:8000, StrVal:""}

$ kubectl version
Server Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.2", GitCommit:"bdaeafa71f6c7c04636251031f93464384d54963", GitTreeState:"clean", BuildDate:"2017-10-24T19:38:10Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

@caseydavenport
Copy link
Member

Feels reasonable, and it seems this is impacting enough people to warrant reverting the original change.

@thockin WDYT?

@tamalsaha
Copy link
Member

tamalsaha commented Oct 27, 2017

Given Service objects are v1, how a breaking change like this was accepted?

@caseydavenport
Copy link
Member

/assign

@etiennetremel
Copy link

For the one looking for a temporary way to fix it you have to mix named port with value, see below:

kind: Service
apiVersion: v1
metadata:
  name: nginx
spec:
  selector:
    app: nginx
  type: LoadBalancer
  ports:
  - name: http
    port: 80
    targetPort: http
  - name: https
    port: 443
    targetPort: 80

@cchildress
Copy link

This seems to be the PR that shipped this.

Why would we want to validate that there are no duplicate target ports anyway? There should be plenty of IP addresses free inside the cluster IP ranges on most clusters (or you have a different problem on your hands) and there are plenty of high-range ports free for the NodePort type. The NAT path through the node should be safe.

I'm not sure why this validation is needed. It seems perfectly safe and sane to me. Plus this is a pretty severe breaking change for the ingress-nginx sidecar for pods.

k8s-github-robot pushed a commit that referenced this issue Nov 13, 2017
Automatic merge from submit-queue (batch tested with PRs 54826, 53576, 55591, 54946, 54825). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Revert "Validate if service has duplicate targetPort"

**What this PR does / why we need it**:
Services allow duplicate targetPort. This reverts commit ce54d90.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #53526

**Special notes for your reviewer**:
/cc @thockin @jhorwit2 

**Release note**:

```release-note
NONE
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Indicates an issue on api area. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. sig/network Categorizes an issue or PR as relevant to SIG Network.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants