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

update existing Services fails #28

Open
bborbe opened this issue Apr 27, 2018 · 3 comments
Open

update existing Services fails #28

bborbe opened this issue Apr 27, 2018 · 3 comments
Labels
bug Something isn't working

Comments

@bborbe
Copy link
Member

bborbe commented Apr 27, 2018

Used Version 1.1.4

W0427 23:09:36.091059       1 change_applier.go:57] apply Service change failed: update object failed: Service "ip" is invalid: [metadata.resourceVersion: Invalid value: "": must be specified for an update, spec.clusterIP: Invalid value: "": field is immutable]
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: ip
  name: ip
  namespace: ip
spec:
  ports:
  - name: web
    port: 80
    protocol: TCP
    targetPort: http
  selector:
    app: ip
status:
  loadBalancer: {}
@bborbe
Copy link
Member Author

bborbe commented Apr 30, 2018

@bborbe
Copy link
Member Author

bborbe commented May 3, 2018

Reproduce

Sample service:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: kickstart
  name: kickstart
  namespace: kickstart
spec:
  ports:
  - name: web
    port: 80
    protocol: TCP
    targetPort: http
  selector:
    app: kickstart

Apply service multiple times works

kubectl apply -f kickstart.yaml
kubectl apply -f kickstart.yaml

Read the service and apply again.

kubectl get svc kickstart -n kickstart -o yaml | kubectl apply -f -
kubectl apply -f kickstart.yaml

Now apply does not work any more.

The Service "kickstart" is invalid:
* metadata.resourceVersion: Invalid value: "": must be specified for an update
* spec.clusterIP: Invalid value: "": field is immutable

Remove the last-applied-configuration annotation for fix.

kubectl annotate svc kickstart -n kickstart kubectl.kubernetes.io/last-applied-configuration-

Now apply works again.

kubectl apply -f kickstart.yaml

@bborbe bborbe assigned bborbe and unassigned bborbe May 14, 2018
@bborbe bborbe added the bug Something isn't working label May 14, 2018
@bborbe bborbe modified the milestone: 1.0 May 14, 2018
@kwiesmueller
Copy link
Contributor

Using patch would work but our NEW object is broken and lacking values:

ORIG:  {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"creationTimestamp\":null,\"labels\":{\"app\":\"http-dump\"},\"name\":\"http-dump\",\"namespace\":\"http-dump\"},\"spec\":{\"ports\":[{\"name\":\"http\",\"port\":80,\"protocol\":\"TCP\",\"targetPort\":8080}],\"selector\":{\"app\":\"http-dump\"},\"type\":\"NodePort\"}}\n"},"creationTimestamp":"2018-05-14T19:41:13Z","labels":{"app":"http-dump"},"name":"http-dump","namespace":"http-dump","resourceVersion":"66799671","selfLink":"/api/v1/namespaces/http-dump/services/http-dump","uid":"c2cd756c-57ae-11e8-96a0-42010a84009c"},"spec":{"clusterIP":"10.15.57.176","externalTrafficPolicy":"Cluster","ports":[{"name":"http","nodePort":32721,"port":80,"protocol":"TCP","targetPort":8080}],"selector":{"app":"http-dump"},"sessionAffinity":"None","type":"NodePort"},"status":{"loadBalancer":{}}}
NEW:  {"apiVersion":"v1","kind":"Service","metadata":{"creationTimestamp":null,"labels":{"app":"http-dump"},"name":"http-dump","namespace":"http-dump"},"spec":{"ports":[{"name":"http","port":80,"protocol":"TCP","targetPort":8080}],"selector":{"app":"http-dump"},"type":"NodePort"},"status":{"loadBalancer":{}}}
PATCH:  {"metadata":{"annotations":null,"creationTimestamp":null,"resourceVersion":null,"selfLink":null,"uid":null},"spec":{"clusterIP":null,"externalTrafficPolicy":null,"ports":[{"name":"http","port":80,"protocol":"TCP","targetPort":8080}],"sessionAffinity":null}}

one suggestion is "start with orig, mutate it to become new, then create a patch?"

kwiesmueller pushed a commit that referenced this issue May 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants