Skip to content

apiserver allows duplicate service port #59119

Closed
@shin-nien

Description

@shin-nien

Is this a BUG REPORT or FEATURE REQUEST?:
/kind bug

What happened:
I was able to add a conflicting service port to an existing service. Attempting to remove the port by modifying the yml and applying fails with The Service "atest" is invalid: spec.ports: Required value

Note: Kubernetes 1.8 will not accept a service.yml with conflicting ports if creating for the first time

What you expected to happen:
The server should reject the request and (in this case) kubectl should error.

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

  • Created service.yml with a single port definition and successfully applied it
apiVersion: v1
kind: Service
metadata:
  name: atest
spec:
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP
    name: http
  • Updated service.yml with an additional identical port definition and successfully applied it
apiVersion: v1
kind: Service
metadata:
  name: atest
spec:
  ports:
  - port: 8080
    targetPort: 80
    protocol: TCP
    name: http
  - port: 8080
    targetPort: 80
    protocol: TCP
    name: dummy
  • Updated service.yml by removing the additional port but applying it failed

Anything else we need to know?:
On adding the additional port, the service definition (on the server) still only has the original port but kubectl.kubernetes.io/last-applied-configuration is now in an inconsistent state making kubectl attempt to remove the port when it calculates its diff for the patch request.

Environment:

  • Kubernetes version (use kubectl version): 1.8
  • Cloud provider or hardware configuration: AWS
  • OS (e.g. from /etc/os-release): Ubuntu 16.04
  • Kernel (e.g. uname -a): 4.4
  • Install tools:
  • Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.priority/important-longtermImportant over the long term, but may not be staffed and/or may need multiple releases to complete.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.sig/networkCategorizes an issue or PR as relevant to SIG Network.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions