云容器引擎 CCE云容器引擎 CCE

更新时间:2021/08/27 GMT+08:00
分享

更新指定的Service

功能介绍

该API用于替换指定的Service对象。

其中以下字段支持更新:

  • metadata.name
  • metadata.namespace
  • metadata.selfLink
  • metadata.resourceVersion
  • metadata.uid
  • metadata.labels
  • metadata.clusterName
  • metadata.generateName
  • metadata.annotations
  • spec.externalTrafficPolicy
  • spec.sessionAffinity
  • spec.type

    spec.type的值,可更新的优先级为LoadBalancer>NodePort>ClusterIP,即当spec.type的值为ClusterIP时,可更新为LoadBalancer或NodePort;当spec.type的值为NodePort时,只能更新为LoadBalancer;当spec.type的值为LoadBalancer时,spec.type不可更新。

  • spec.port
  • spec.selector
  • spec.externalIPs
  • spec.loadBalancerIP
  • spec.loadBalancerSourceRanges
  • metadata.deletionGracePeriodSeconds
  • service.spec.clusterIP

URI

PATCH /api/v1/namespaces/{namespace}/services/{name}

表1 描述该API的参数。

表1 参数描述

参数

是否必选

描述

pretty

No

If 'true', then the output is pretty printed.

namespace

Yes

Object name and auth scope, such as for teams and projects.

name

Yes

Name of the Service.

请求消息

响应参数:

“Content-Type”的详细描述请参见 PATCH请求方法操作说明

请求参数的详细描述请参见表2

请求示例:

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" 
         } 
     } 
 }

响应消息

响应参数:

响应参数的详细描述请参见表2

响应示例:

{ 
   "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": {} 
   } 
 }

状态码

表2描述API的状态码。

表2 状态码

状态码

描述

200

This operation succeeds, and a Service resource object is returned.

异常状态码请参见状态码

分享:

    相关文档

    相关产品