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

计算
弹性云服务器 ECS
云耀云服务器 HECS
裸金属服务器 BMS
弹性伸缩 AS
镜像服务 IMS
专属主机 DeH
函数工作流 FunctionGraph
云手机 CPH
VR云渲游平台 CVR
特惠算力专区
存储
对象存储服务 OBS
云硬盘 EVS
云备份 CBR
内容分发网络 CDN
存储容灾服务 SDRS
弹性文件服务 SFS
云服务器备份 CSBS
云硬盘备份 VBS
数据快递服务 DES
专属企业存储服务
智能边缘
智能边缘云 IEC
EI 企业智能
EI安视服务
AI开发平台ModelArts
数据湖治理中心 DGC
数据仓库服务 GaussDB(DWS)
企业级AI应用开发专业套件 ModelArts Pro
数据湖探索 DLI
华为HiLens
云搜索服务 CSS
数据接入服务 DIS
表格存储服务 CloudTable
数据湖工厂 DLF
图引擎服务 GES
推荐系统 RES
文字识别 OCR
内容审核 Moderation
图像识别 Image
图像搜索 ImageSearch
人脸识别服务 FRS
对话机器人服务 CBS
视频分析服务 VAS
数据可视化 DLV
视频接入服务 VIS
自然语言处理 NLP
语音交互服务 SIS
知识图谱 KG
医疗智能体 EIHealth
可信智能计算服务 TICS
园区智能体 CampusGo
实时流计算服务 CS
人证核身服务 IVS
IoT物联网
设备接入 IoTDA
IoT物联网
全球SIM联接 GSL
设备发放 IoTDP
IoT开发者服务
IoT边缘 IoTEdge
IoT数据分析
路网数字化服务 DRIS
开发与运维
项目管理 ProjectMan
代码托管 CodeHub
流水线 CloudPipeline
代码检查 CodeCheck
编译构建 CloudBuild
部署 CloudDeploy
云测 CloudTest
发布 CloudRelease
移动应用测试 MobileAPPTest
CloudIDE
Classroom
软件开发平台 DevCloud
开源镜像站 Mirrors
视频
媒体处理 MPC
视频点播 VOD
视频直播 Live
实时音视频 SparkRTC
管理与部署
统一身份认证服务 IAM
云监控服务 CES
应用运维管理 AOM
应用性能管理 APM
云审计服务 CTS
云日志服务 LTS
标签管理服务 TMS
资源管理服务 RMS
应用身份管理服务 OneAccess
专属云
专属计算集群 DCC
专属分布式存储服务 DSS
域名与网站
域名注册服务 Domains
云速建站 CloudSite
企业协同
华为云WeLink
会议
ISDP
解决方案
全栈专属服务
高性能计算 HPC
SAP
游戏云
混合云灾备
快视频
华为工业云平台 IMC
价格
价格原则
成本优化最佳实践
昇腾
昇腾MindX SDK (20.3)
其他
管理控制台
消息中心
产品价格详情
系统权限
我的凭证
客户关联华为云合作伙伴须知
公共问题
宽限期保留期
奖励推广计划
活动
容器
云容器引擎 CCE
云容器实例 CCI
容器镜像服务 SWR
应用编排服务 AOS
容器交付流水线 ContainerOps
应用服务网格 ASM
多云容器平台 MCP
基因容器 GCS
容器洞察引擎 CIE
容器批量计算 BCE
云原生服务中心 OSC
网络
虚拟私有云 VPC
弹性公网IP EIP
弹性负载均衡 ELB
NAT网关 NAT
云专线 DC
虚拟专用网络 VPN
云连接 CC
VPC终端节点 VPCEP
数据库
云数据库 RDS
文档数据库服务 DDS
分布式数据库中间件 DDM
数据复制服务 DRS
数据管理服务 DAS
云数据库 GaussDB(for MySQL)
云数据库 GaussDB NoSQL
云数据库 GaussDB (for openGauss)
数据库和应用迁移 UGO
大数据
MapReduce服务 MRS
应用中间件
应用管理与运维平台 ServiceStage
分布式缓存服务 DCS
分布式消息服务Kafka版
分布式消息服务RabbitMQ版
消息通知服务 SMN
微服务引擎 CSE
云性能测试服务 CPTS
区块链服务 BCS
API网关 APIG
应用魔方 AppCube
分布式消息服务RocketMQ版
多云高可用服务 MAS
可信跨链数据链接服务 TCDAS
企业应用
云桌面 Workspace
云解析服务 DNS
应用与数据集成平台 ROMA Connect
ROMA资产中心 ROMAExchange
ROMA API
鸿源云道
华为乾坤
安全与合规
Web应用防火墙 WAF
漏洞扫描服务 VSS
企业主机安全 HSS
容器安全服务 CGS
数据加密服务 DEW
数据库安全服务 DBSS
态势感知 SA
云堡垒机 CBH
SSL证书管理 SCM
云证书管理服务 CCM
管理检测与响应 MDR
数据安全中心 DSC
威胁检测服务 MTD
DDoS防护 ADS
云防火墙 CFW
应用信任中心 ATC
安全技术与应用
迁移
主机迁移服务 SMS
对象存储迁移服务 OMS
云数据迁移 CDM
智能协作
IdeaHub
企业网络
云管理网络
SD-WAN 云服务
边缘数据中心管理 EDCM
废弃-华为乾坤安全云服务
云通信
语音通话 VoiceCall
消息&短信 MSGSMS
隐私保护通话 PrivateNumber
开发者工具
SDK开发指南
API签名指南
DevStar
HCloud CLI
Terraform
Ansible
云生态
云市场
鲲鹏
昇腾
合作伙伴中心
华为云培训中心
用户服务
帐号中心
费用中心
成本中心
资源中心
企业管理
工单管理
客户运营能力
国际站常见问题
网站备案
支持计划
专业服务
合作伙伴支持计划
更新时间:2021/03/18 GMT+08:00
分享

获取指定的Service

功能介绍

该API用于获取指定的Service对象。

URI

GET /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.

exact

No

Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'.

export

No

Should this value be exported. Export strips fields that a user can not specify.

请求消息

N/A

响应消息

响应参数:

响应参数如表2所示。

表2 参数描述

参数

参数类型

描述

kind

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.

apiVersion

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.

metadata

metadata object

-

spec

spec object

-

status

status object

-

表3 metadata字段数据结构说明

参数

参数类型

描述

name

String

Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated.

clusterName

String

The name of the cluster which the object belongs to. This is used to distinguish resources with same name and namespace in different clusters. This field is not set anywhere right now and apiserver is going to ignore it if set in create or update request.

initializers

initializers object

An initializer is a controller which enforces some system invariant at object creation time. This field is a list of initializers that have not yet acted on this object. If nil or empty, this object has been completely initialized. Otherwise, the object is considered uninitialized and is hidden (in list/watch and get calls) from clients that haven't explicitly asked to observe uninitialized objects. When an object is created, the system will populate this list with the current set of initializers. Only privileged users may set or modify this list. Once it is empty, it may not be modified further by any user.

generateName

String

GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server.

If this field is specified and the generated name exists, the server will NOT return a 409 - instead, it will either return 201 Created or 500 with Reason ServerTimeout indicating a unique name could not be found in the time allotted, and the client should retry (optionally after the time indicated in the Retry-After header).

Applied only if Name is not specified.

namespace

String

Namespace defines the space within each name must be unique. An empty namespace is equivalent to the "default" namespace, but "default" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. Must be a DNS_LABEL. Cannot be updated.

selfLink

String

SelfLink is a URL representing this object. Populated by the system. Read-only.

uid

String

UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations. Populated by the system. Read-only.

resourceVersion

String

An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources. Populated by the system. Read-only. Value must be treated as opaque by clients.

generation

Integer

A sequence number representing a specific generation of the desired state. Currently only implemented by replication controllers. Populated by the system. Read-only.

creationTimestamp

String

CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC. Populated by the system. Read-only. Null for lists.

deletionTimestamp

String

DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource will be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field. Once set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. Once the resource is deleted in the API, the Kubelet will send a hard termination signal to the container. If not set, graceful deletion of the object has not been requested. Populated by the system when a graceful deletion is requested. Read-only.

deletionGracePeriodSeconds

Integer

Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only.

labels

Object

Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services.

Annotations

Object

Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects.

ownerReferences

ownerReferences object

List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.

finalizers

Array of strings

Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed.

表4 spec字段数据结构说明

参数

参数类型

描述

ports

ports object

The list of ports that are exposed by this service.

selector

No

This service will route traffic to pods having labels matching this selector. Label keys and values that must match in order to receive traffic for this service. If empty, all pods are selected, if not specified, endpoints must be manually specified.

clusterIP

String

ClusterIP is usually assigned by the master and is the IP address of the service. If specified, it will be allocated to the service if it is unused or else creation of the service will fail. Valid values are None, empty string (""), or a valid IP address. 'None' can be specified for a headless service when proxying is not required. Cannot be updated.

type

String

Type of exposed service. Must be ClusterIP, NodePort, or LoadBalancer. Defaults to ClusterIP.

externalIPs

Array of strings

externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service. These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system. A previous form of this functionality exists as the deprecatedPublicIPs field. When using this field, callers should also clear the deprecatedPublicIPs field.

healthCheckNodePort

Integer

healthCheckNodePort specifies the healthcheck nodePort for the service. If not specified, HealthCheckNodePort is created by the service api backend with the allocated nodePort. Will use user-specified nodePort value if specified by the client. Only effects when Type is set to LoadBalancer and ExternalTrafficPolicy is set to Local.

loadBalancerSourceRanges

Array of strings

If specified and supported by the platform, this will restrict traffic through the cloud-provider load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support the feature.

externalName

String

externalName is the external reference that kubedns or equivalent will return as a CNAME record for this service. No proxying will be involved. Must be a valid DNS name and requires Type to be ExternalName.

deprecatedPublicIPs

Array of strings

deprecatedPublicIPs is deprecated and replaced by the externalIPs field with almost the exact same semantics. This field is retained in the v1 API for compatibility until at least 8/20/2016. It will be removed from any new API revisions. If both deprecatedPublicIPs and externalIPs are set, deprecatedPublicIPs is used.

sessionAffinity

String

Supports "ClientIP" and "None". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None.

loadBalancerIP

String

Only applies to Service Type: LoadBalancer LoadBalancer will get created with the IP specified in this field. This feature depends on whether the underlying cloud-provider supports specifying the loadBalancerIP when a load balancer is created. This field will be ignored if the cloud-provider does not support the feature.

表5 status字段数据结构说明

参数

参数类型

描述

loadBalancer

loadBalancer object

-

表6 ownerReferences字段数据结构说明

参数

参数类型

描述

apiVersion

String

API version of the referent.

kind

String

Kind of the referent.

name

String

Name of the referent.

uid

String

UID of the referent.

controller

Boolean

If true, this reference points to the managing controller.

blockOwnerDeletion

Boolean

If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs "delete" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned.

表7 ports字段数据结构说明

参数

参数类型

描述

name

String

The name of this port within the service. This must be a DNS_LABEL. All ports within a ServiceSpec must have unique names. This maps to the 'Name' field in EndpointPort objects. Optional if only one ServicePort is defined on this service.

protocol

String

The IP protocol for this port. Supports "TCP" and "UDP". Default is TCP.

port

Integer

The port that will be exposed by this service.

targetPort

String

Number or name of the port to access on the pods targeted by the service. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. If this is a string, it will be looked up as a named port in the target Pod's container ports. If this is not specified, the value of Port is used (an identity map). Defaults to the service port.

nodePort

Integer

The port on each node on which this service is exposed when type=NodePort or LoadBalancer. Usually assigned by the system. If specified, it will be allocated to the service if unused or else creation of the service will fail. Default is to auto-allocate a port if the ServiceType of this Service requires one.

表8 loadBalancer字段数据结构说明

参数

参数类型

描述

ingress

ingress object

Ingress is a list containing ingress points for the load-balancer. Traffic intended for the service should be sent to these ingress points.

表9 ingress字段数据结构说明

参数

参数类型

描述

ip

String

IP is set for load-balancer ingress points that are IP based

hostname

String

Hostname is set for load-balancer ingress points that are DNS based

响应示例:

{ 
   "kind": "Service", 
   "apiVersion": "v1", 
   "metadata": { 
     "name": "myapp", 
     "namespace": "default", 
     "selfLink": "/api/v1/namespaces/default/services/myapp", 
     "uid": "58b5ca7c-5d12-11e6-aeb9-286ed488fafe", 
     "resourceVersion": "683", 
     "creationTimestamp": "2016-08-08T02:46:46Z" 
   }, 
   "spec": { 
     "ports": [ 
       { 
         "protocol": "TCP", 
         "port": 8765, 
         "targetPort": 9376 
       } 
     ], 
     "selector": { 
       "app": "example" 
     }, 
     "clusterIP": "10.0.0.139", 
     "type": "ClusterIP", 
     "sessionAffinity": "None" 
   }, 
   "status": { 
     "loadBalancer": {} 
   } 
 }

状态码

表10描述API的状态码。

表10 状态码

状态码

描述

200

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

异常状态码请参见状态码

分享:

    相关文档

    相关产品