-
Notifications
You must be signed in to change notification settings - Fork 3.3k
How can I make request like this by k8s python client, the below request is made by "kubectl edit", and it works! #641
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
Comments
Have you tried patch_namespaced_service? |
Yes, I have tried, but I do not know what should I set to patch_namespaced_service's body parameter. I can set service's "target_port" a new value and it works. |
It's intended behavior.
You could try enable debugging log but passing
The result appears to be spec.ports[0].port getting updated. |
OK, I see your point, thanks very much! So I wonder how can I make a request by python client to delete the port[0] of service? |
Any update on this as how to make a request by python client to delete the port[0] or any spec in service ? |
You can use json-patch which is supported by k8s and this library: api_instance = client.CoreV1Api()
body = [{"op": "replace", "path": "/spec/ports/0/port", "value": 8080}]
api_response = api_instance.patch_namespaced_service("my-service", "my-namespace", body) More information: |
Hey thanks for the response @tomplus |
Uh oh!
There was an error while loading. Please reload this page.
"spec":{"$setElementOrder/ports":[{"port":3315}],"ports":[{"nodePort":30005,"port":3315,"protocol":"TCP","targetPort":3321},{"$patch":"delete","port":3310}]}}
PATCH https://61.164.142.194:6443/api/v1/namespaces/default/services/mysql
The text was updated successfully, but these errors were encountered: