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

创建Deployment

分享
更新时间: 2020/06/29 GMT+08:00

功能介绍

创建一个Deployment。

创建Deployment时挂载OBS的使用限制请参见挂载OBS使用限制

URI

POST /apis/apps/v1/namespaces/{namespace}/deployments

表1 Path参数

参数

描述

namespace

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

表2 Query参数

参数

是否必选

描述

pretty

Yes

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

请求消息

请求参数

请求参数如表79所示。

请求示例:

{
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "metadata": {
        "name": "deployment-test"
    },
    "spec": {
        "replicas": 1,
        "selector": {
            "matchLabels": {
                "app": "redis"
            }
        },
        "template": {
            "metadata": {
                "labels": {
                    "app": "redis"
                }
            },
            "spec": {
                "containers": [
                    {
                        "image": "redis",
                        "name": "container-0",
                        "resources": {
                            "limits": {
                                "cpu": "500m",
                                "memory": "1024Mi"
                            },
                            "requests": {
                                "cpu": "500m",
                                "memory": "1024Mi"
                            }
                        }
                    }
                ],
                "imagePullSecrets": [
                    {
                        "name": "imagepull-secret"
                    }
                ],
               "priority": 0
            }
        }
    }
}

响应消息

响应参数

响应参数如表79所示。

响应示例:

{
    "kind": "Deployment",
    "apiVersion": "apps/v1",
    "metadata": {
        "name": "deployment-test",
        "namespace": "namespace-test",
        "selfLink": "/apis/apps/v1/namespaces/namespace-test/deployments/deployment-test",
        "uid": "777dce52-b186-11e8-8cb0-c81fbe371a17",
        "resourceVersion": "5630832",
        "generation": 1,
        "creationTimestamp": "2018-09-06T03:39:32Z",
        "labels": {
            "app": "redis"
        },
        "enable": true
    },
    "spec": {
        "replicas": 1,
        "priority": 0,
        "selector": {
            "matchLabels": {
                "app": "redis"
            }
        },
        "template": {
            "metadata": {
                "creationTimestamp": null,
                "labels": {
                    "app": "redis"
                },
                "annotations": {
                    "cri.cci.io/container-type": "secure-container"
                },
                "enable": true
            },
            "spec": {
                "containers": [
                    {
                        "name": "container-0",
                        "image": "redis",
                        "resources": {
                            "limits": {
                                "cpu": "500m",
                                "memory": "1Gi"
                            },
                            "requests": {
                                "memory": "1Gi",
                                "cpu": "500m"
                            }
                        },
                        "terminationMessagePath": "/dev/termination-log",
                        "terminationMessagePolicy": "File",
                        "imagePullPolicy": "IfNotPresent"
                    }
                ],
                "restartPolicy": "Always",
                "terminationGracePeriodSeconds": 30,
                "dnsPolicy": "ClusterFirst",
                "securityContext": {},
                "imagePullSecrets": [
                    {
                        "name": "imagepull-secret"
                    }
                ],
                "schedulerName": "default-scheduler"
            }
        },
        "strategy": {
            "type": "RollingUpdate",
            "rollingUpdate": {
                "maxUnavailable": "25%",
                "maxSurge": "25%"
            }
        },
        "revisionHistoryLimit": 10,
        "progressDeadlineSeconds": 600
    },
    "status": {}
}

状态码

表3 状态码描述API的状态码。

表3 状态码

状态码

描述

201

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

更多状态码请参见状态码

分享:

    相关文档

    相关产品

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

提交成功!

非常感谢您的反馈,我们会继续努力做到更好!

反馈提交失败,请稍后再试!

*必选

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

字符长度不能超过200

提交反馈 取消

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

智能客服提问云社区提问