该API用于创建一个Deployment资源对象。
如果要将创建的Deployment对象在CCE工作负载界面上正常显示,则必须给创建的Deployment资源对象添加labels标签。
设置请求消息体中的“metadata.labels”参数键值示例如下:
labels: app: deploymentname
POST /apis/apps/v1/namespaces/{namespace}/deployments (适用于1.15以上版本的所有集群)
POST /apis/extensions/v1beta1/namespaces/{namespace}/deployments (仅适用于1.15及以下版本的集群)
表1描述该API的参数。
请求参数:
请求参数如表2所示。
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
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. |
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. |
metadata |
Yes |
metadata object |
Standard object metadata. |
spec |
Yes |
spec object |
Specification of the desired behavior of the Deployment. |
status |
No |
status object |
Most recently observed status of the Deployment. |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
minReadySeconds |
No |
Integer |
Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready) |
paused |
No |
Boolean |
Indicates that the deployment is paused. |
progressDeadlineSeconds |
No |
Integer |
The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Once autoRollback is implemented, the deployment controller will automatically rollback failed deployments. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s. |
replicas |
No |
Integer |
Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1. |
revisionHistoryLimit |
No |
Integer |
The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 2. |
selector |
No |
selector object |
Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment. |
strategy |
No |
strategy object |
The deployment strategy to use to replace existing pods with new ones. |
template |
Yes |
template object |
Template describes the pods that will be created. |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
availableReplicas |
No |
Integer |
Total number of available pods (ready for at least minReadySeconds) targeted by this deployment. |
collisionCount |
No |
Integer |
Count of hash collisions for the Deployment. The Deployment controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ReplicaSet. |
conditions |
No |
conditions object |
Represents the latest available observations of a deployment's current state. |
observedGeneration |
No |
Integer |
The generation observed by the deployment controller |
readyReplicas |
No |
Integer |
Total number of ready pods targeted by this deployment |
replicas |
No |
Integer |
Total number of non-terminated pods targeted by this deployment (their labels match the selector). |
unavailableReplicas |
No |
Integer |
Total number of unavailable pods targeted by this deployment. |
updatedReplicas |
No |
Integer |
Total number of non-terminated pods targeted by this deployment that have the desired template spec. |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
revision |
No |
Integer |
The revision to rollback to. If set to 0, rollback to the last revision. |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
matchExpressions |
No |
matchExpressions object |
matchExpressions is a list of label selector requirements. The requirements are ANDed. |
matchLabels |
No |
Object |
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
rollingUpdate |
Yes |
RollingUpateDeployment object |
Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate. |
type |
No |
String |
Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate. |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
lastTransitionTime |
No |
String |
Last time the condition transitioned from one status to another. |
lastUpdateTime |
No |
String |
The last time this condition was updated. |
message |
No |
String |
A human readable message indicating details about the transition. |
reason |
No |
String |
The reason for the condition's last transition. |
status |
No |
String |
Status of the condition, one of True, False, Unknown. |
type |
No |
String |
Type of deployment condition. |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
key |
No |
String |
key is the label key that the selector applies to. |
operator |
No |
String |
operator represents a key's relationship to a set of values. Valid operators ard In, NotIn, Exists and DoesNotExist. |
values |
No |
Array of strings |
values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
maxSurge |
No |
Integer |
The maximum number of pods that can be scheduled above the desired number of pods. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up. Defaults to 25%. Example: when this is set to 30%, the new RC can be scaled up immediately when the rolling update starts, such that the total number of old and new pods do not exceed 130% of desired pods. Once old pods have been killed, new RC can be scaled up further, ensuring that total number of pods running at any time during the update is atmost 130% of desired pods. |
maxUnavailable |
No |
Integer |
The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. This can not be 0 if MaxSurge is 0. Defaults to 25%. Example: when this is set to 30%, the old RC can be scaled down to 70% of desired pods immediately when the rolling update starts. Once new pods are ready, old RC can be scaled down further, followed by scaling up the new RC, ensuring that the total number of pods available at all times during the update is at least 70% of desired pods. |
请求示例:
{ "apiVersion": "apps/v1beta1", "kind": "Deployment", "metadata": { "labels": { "app": "deployment-test" }, "name": "deployment-test" }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "deployment-test" } }, "template": { "metadata": { "labels": { "app": "deployment-test" } }, "spec": { "containers": [ { "image": "172.16.5.235:20202/test/nginx", "imagePullPolicy": "IfNotPresent", "name": "deployment-test" } ], "imagePullSecrets": [{ "name": "default-secret" }] } } } }
响应参数:
响应参数如表2所示。
响应示例:
{ "kind": "Deployment", "apiVersion": "apps/v1beta1", "metadata": { "name": "deployment-test", "namespace": "default", "selfLink": "/apis/apps/v1beta1/namespaces/default/deployments/deployment-test", "uid": "d079d1a0-fc1f-11e7-9c3c-fa163eb8ad1a", "resourceVersion": "485774", "generation": 1, "creationTimestamp": "2018-01-18T07:18:42Z", "labels": { "name": "deployment-test" }, "enable": true }, "spec": { "replicas": 1, "selector": { "matchLabels": { "name": "deployment-test" } }, "template": { "metadata": { "creationTimestamp": null, "labels": { "name": "deployment-test" }, "enable": true }, "spec": { "containers": [ { "name": "deployment-test", "image": "172.16.5.235:20202/test/nginx", "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent" } ], "restartPolicy": "Always", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "imagePullSecrets": [ { "name": "default-secret" } ], "schedulerName": "default-scheduler" } }, "strategy": { "type": "RollingUpdate", "rollingUpdate": { "maxUnavailable": "25%", "maxSurge": "25%" } }, "revisionHistoryLimit": 2, "progressDeadlineSeconds": 600 }, "status": {} }
往期分享RDS MySQL RDS MySQL 实例空间问题 RDS MySQL 内存使用问题 RDS MySQL ...
创业与投资的本质,都是追寻一种能够穿越时空,抵达未来的高效方式。 德勤管理咨...
除了人工智能技术得到广泛应用之外,在过去几年中,大数据也取得了更具意义的发...
关于Aishwin Vikhona: 互联网解决方案提供商Global Websoft公司创始人,知名 域...
还有几天就是新春佳节了,除了放假,这个时候不少用户朋友最期待的要数 TOP云 的...
应用定义屏幕 点亮智慧空间 阿里云全新自有品牌 “妙议方”智慧屏 8月6日震撼发...
一位小伙伴来问一道谷歌的笔试题,关于单链表操作的,问到底有多少种解决方案,...
近日,由国内最大的新顶级 域名交易 平台 TOP云 举办的“全球首次精品保留新顶级...
腾讯云边缘可用区(TencentCloud Edge Zone,TEZ)是腾讯云的本地扩展,适用于解...
点击查看更多ICBU风控算法相关内容 ICBU风控算法专题 ,【订阅专题】第一时间get...