Description
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: