Updating a Specified Service
Function
This API is used to replace a specified service.
The following fields can be updated:
- metadata.selfLink
- metadata.resourceVersion
- metadata.labels
- metadata.clusterName
- metadata.generateName
- metadata.annotations
- spec.externalTrafficPolicy
- spec.sessionAffinity
- spec.type
The update priority of the value of spec.type is as follows: LoadBalancer > NodePort > ClusterIP. When spec.type is set to ClusterIP, it can be updated to LoadBalancer or NodePort. When spec.type is set to Nodeport, it can be updated to LoadBalancer. When spec.type is set to LoadBalancer, it cannot be updated.
- spec.port
- spec.selector
- spec.externalIPs
- spec.loadBalancerIP
- spec.loadBalancerSourceRanges
URI
PATCH /api/v1/namespaces/{namespace}/services/{name}
Table 1 describes the parameters of this API.
Request
Request parameters:
For the description about the Content-Type field, see Patch Request Method Operation Description.
For the description about request parameters, see Table 2.
Example request:
Content-Type: application/strategic-merge-patch+json
{
"spec": {
"ports": [
{
"name": "ttt1",
"protocol": "TCP",
"port": 8765,
"targetPort": 9376
},
{
"name": "ttt2",
"protocol": "TCP",
"port": 8765,
"targetPort": 9076
}
],
"selector": {
"app": "example"
}
}
}
Response
Response parameters:
For the description about response parameters, see Table 2.
Example response:
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "raoy",
"namespace": "default",
"selfLink": "/api/v1/namespaces/default/services/raoy",
"uid": "e0d681b7-5d17-11e6-aeb9-286ed488fafe",
"resourceVersion": "1602",
"creationTimestamp": "2016-08-08T03:26:21Z"
},
"spec": {
"ports": [
{
"name": "ttt1",
"protocol": "TCP",
"port": 8765,
"targetPort": 9376
},
{
"name": "ttt2",
"protocol": "TCP",
"port": 8765,
"targetPort": 9076
}
],
"selector": {
"app": "example"
},
"clusterIP": "10.0.0.193",
"type": "ClusterIP",
"sessionAffinity": "None"
},
"status": {
"loadBalancer": {}
}
}
Status Code
Table 2 describes the status code of this API.
|
Status Code |
Description |
|---|---|
|
200 |
This operation succeeds, and a Service resource object is returned. |
For the description about error status codes, see Status Code.
Last Article: Listing Services
Next Article: Ingress
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.