文档首页 > > API参考> Kubernetes API> Endpoints> 创建Endpoints

创建Endpoints

分享
更新时间:2020/07/14 GMT+08:00

功能介绍

该API用于创建一个Endpoints资源对象。

URI

POST /api/v1/namespaces/{namespace}/endpoints

表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.

请求消息

请求参数:

请求参数如表2所示。

表2 参数描述

参数

是否必选

参数类型

描述

kind

Yes

String

Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase.

The value of this parameter is Endpoints.

apiVersion

Yes

String

APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values.

The value of this parameter is v1.

metadata

Yes

metadata object

-

subsets

Yes

subsets object

The set of all endpoints is the union of all subsets. Addresses are placed into subsets according to the IPs they share. A single address with multiple ports, some of which are ready and some of which are not (because they come from different containers) will result in the address being displayed in different subsets for the different ports. No address will appear in both Addresses and NotReadyAddresses in the same subset. Sets of addresses and ports that comprise a service.

表3 subsets字段数据结构说明

参数

是否必选

参数类型

描述

addresses

Yes

addresses object

IP addresses which offer the related ports that are marked as ready. These endpoints should be considered safe for load balancers and clients to utilize.

notReadyAddresses

No

addresses object

IP addresses which offer the related ports but are not currently marked as ready because they have not yet finished starting, have recently failed a readiness check, or have recently failed a liveness check.

ports

Yes

ports object

Port numbers available on the related IP addresses.

表4 addresses字段数据结构说明

参数

是否必选

参数类型

描述

ip

Yes

String

The IP of this endpoint.

targetRef

No

targetRef object

-

hostname

No

String

Hostname of this endpoint.eant to be used by DNS servers etc.

nodeName

No

String

Optional: Node hosting this endpoint. This can be used to determine endpoints local to a node.

表5 ports字段数据结构说明

参数

是否必选

参数类型

描述

name

No

String

The name of this port (corresponds to ServicePort.Name). Must be a DNS_LABEL. Optional only if one port is defined.

Value length: 0 character < String length ≤ 63 characters.

The string must comply with regular expression [a-z0-9]([-a-z0-9]*[a-z0-9])?.

port

Yes

Integer

The port number of the endpoint.

Value range: (0, 65535].

protocol

No

String

The IP protocol for this port.

This parameter can be set to:

  • TCP
  • UDP

    Default: TCP.

表6 targetRef字段数据结构说明

参数

是否必选

参数类型

描述

kind

No

String

Phase is the current lifecycle phase of the namespace.

namespace

No

String

Namespace of the referent.

name

No

String

Name of the referent.

uid

No

String

UID of the referent.

apiVersion

No

String

API version of the referent.

resourceVersion

No

String

Specific resourceVersion to which this reference is made, if any.

说明:

This parameter is automatically generated. Do not assign values to this parameter. Otherwise, the API fails to be called.

fieldPath

No

String

If referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. For example, if the object reference is to a container within a pod, this would take on a value like: "spec.containers{name}" (where "name" refers to the name of the container that triggered the event) or if no container name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object.

请求示例:

{ 
   "kind": "Endpoints", 
   "apiVersion": "v1", 
   "metadata": { 
     "name": "cluster-test" 
   }, 
   "subsets": [ 
     { 
       "addresses": [ 
         { 
           "ip": "172.16.106.152" 
         } 
       ], 
       "ports": [ 
         { 
           "port": 1 
         } 
       ] 
     }, 
     { 
       "addresses": [ 
         { 
           "ip": "172.16.79.157" 
         } 
       ], 
       "ports": [ 
         { 
           "port": 1 
         } 
       ] 
     } 
   ] 
 }

响应消息

响应参数:

响应参数的详细描述请参见请求消息

响应示例:

{ 
   "kind": "Endpoints", 
   "apiVersion": "v1", 
   "metadata": { 
     "name": "cluster-test", 
     "namespace": "default", 
     "selfLink": "/api/v1/namespaces/default/endpoints/cluster-test", 
     "uid": "81b1503d-5960-11e6-b444-286ed488fafe", 
     "resourceVersion": "18186", 
     "creationTimestamp": "2016-08-03T09:56:10Z" 
   }, 
   "subsets": [ 
     { 
       "addresses": [ 
         { 
           "ip": "172.16.106.152" 
         }, 
         { 
           "ip": "172.16.79.157" 
         } 
       ], 
       "ports": [ 
         { 
           "port": 1, 
           "protocol": "TCP" 
         } 
       ] 
     } 
   ] 
 }

状态码

表7描述API的状态码。

表7 状态码

状态码

描述

201

This operation succeeds, and an Endpoint resource object is returned.

异常状态码请参见状态码

分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!非常感谢您的反馈,我们会继续努力做到更好!
反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

智能客服提问云社区提问