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

创建DaemonSet

分享
更新时间:2020/09/18 GMT+08:00

功能介绍

This API is used to create a DaemonSet resource object.

URI

POST /apis/apps/v1/namespaces/{namespace}/daemonsets (Supports 1.9 and 1.9+)

POST /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets (Supports 1.15 and 1.15-)

表1描述该API的参数。

表1 参数描述

参数

是否必选

描述

namespace

Yes

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

pretty

No

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

请求消息

请求参数:

请求参数如表2所示。

表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's metadata.

spec

Yes

spec object

The desired behavior of this daemon set.

status

No

status object

The current status of this daemon set. This data may be out of date by some window of time. Populated by the system. Read-only.

表3 spec字段数据结构说明

参数

是否必选

参数类型

描述

minReadySeconds

No

Integer

The minimum number of seconds for which a newly created DaemonSet 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).

revisionHistoryLimit

No

Integer

The number of old history to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 10.

selector

No

selector object

A label query over pods that are managed by the daemon set. Must match in order to be controlled. If empty, defaulted to labels on Pod template.

template

Yes

template object

An object that describes the pod that will be created. The DaemonSet will create exactly one copy of this pod on every node that matches the template's node selector (or on every node if no node selector is specified).

templateGeneration

No

Integer

DEPRECATED. A sequence number representing a specific generation of the template. Populated by the system. It can be set only during the creation.

updateStrategy

No

updateStrategy object

An update strategy to replace existing DaemonSet pods with new pods.

表4 status字段数据结构说明

参数

是否必选

参数类型

描述

collisionCount

No

Integer

Count of hash collisions for the DaemonSet. The DaemonSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.

currentNumberScheduled

No

Integer

The number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod.

desiredNumberScheduled

No

Integer

The total number of nodes that should be running the daemon pod (including nodes correctly running the daemon pod).

numberAvailable

No

Integer

The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and available (ready for at least spec.minReadySeconds)

numberMisscheduled

No

Integer

The number of nodes that are running the daemon pod, but are not supposed to run the daemon pod.

numberReady

No

Integer

The number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready.

numberUnavailable

No

Integer

The number of nodes that should be running the daemon pod and have none of the daemon pod running and available (ready for at least spec.minReadySeconds)

observedGeneration

No

Integer

The most recent generation observed by the daemon set controller.

updatedNumberScheduled

No

Integer

The total number of nodes that are running updated daemon pod

表5 template字段数据结构说明

参数

是否必选

参数类型

描述

metadata

Yes

metadata object

Standard object's metadata.

spec

Yes

Object

Specification of the desired behavior of the pod.

表6 updateStrategy字段数据结构说明

参数

是否必选

参数类型

描述

rollingUpdate

Yes

Object

Rolling update config params. Present only if type = "RollingUpdate".

type

No

String

Type of daemon set update. Can be "RollingUpdate" or "OnDelete". Default is OnDelete.

请求示例:

{
    "kind": "DaemonSet",
    "apiVersion": "extensions/v1beta1",
    "metadata": {
        "name": "daemonset-test",
        "labels": {
            "name": "daemonset-test"
        },
        "enable": true
    },
    "spec": {
        "selector": {
            "matchLabels": {
                "name": "daemonset-test"
            }
        },
        "template": {
            "metadata": {
                "labels": {
                    "name": "daemonset-test"
                },
                "enable": true
            },
            "spec": {
                "containers": [
                    {
                        "name": "daemonset-test",
                        "image": "172.16.5.235:20202/test/nginx",
                        "imagePullPolicy": "IfNotPresent"
                    }
                ],
                "imagePullSecrets": [{
                    "name": "default-secret"
                }]            
            }
        }
    }
}

响应消息

响应参数:

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

响应示例:

{
    "kind": "DaemonSet",
    "apiVersion": "extensions/v1beta1",
    "metadata": {
        "name": "daemonset-test",
        "namespace": "default",
        "selfLink": "/apis/extensions/v1beta1/namespaces/default/daemonsets/daemonset-test",
        "uid": "f9808766-fc23-11e7-9c3c-fa163eb8ad1a",
        "resourceVersion": "487764",
        "generation": 1,
        "creationTimestamp": "2018-01-18T07:48:29Z",
        "labels": {
            "name": "daemonset-test"
        },
        "enable": true
    },
    "spec": {
        "selector": {
            "matchLabels": {
                "name": "daemonset-test"
            }
        },
        "template": {
            "metadata": {
                "creationTimestamp": null,
                "labels": {
                    "name": "daemonset-test"
                },
                "enable": true
            },
            "spec": {
                "containers": [
                    {
                        "name": "daemonset-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"
            }
        },
        "updateStrategy": {
            "type": "OnDelete"
        },
        "templateGeneration": 1,
        "revisionHistoryLimit": 10
    },
    "status": {
        "currentNumberScheduled": 0,
        "numberMisscheduled": 0,
        "desiredNumberScheduled": 0,
        "numberReady": 0
    }
}

状态码

表7描述API的状态码。

表7 状态码

状态码

描述

201

The request has been fulfilled, resulting in the creation of a new resource.

异常状态码请参见状态码

分享:

    相关文档

    相关产品

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

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

*必选

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

字符长度不能超过200

提交反馈 取消

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

智能客服提问云社区提问