• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference 2.0
  4. Kubernetes API
  5. DaemonSet
  6. Creating a DaemonSet

Creating a DaemonSet

Function

This API is used to create a DaemonSet resource object.

URI

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

POST /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Mandatory

Description

namespace

Yes

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

pretty

No

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

Request

Request parameters:

Table 2 Request parameter

Parameter

Mandatory

Type

Description

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

3.1 Table11 Data structure of the metadata field

Standard object's metadata.

spec

Yes

Table3 Data structure of the spec field

The desired behavior of this daemon set.

status

No

Table 4

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.

Table 3 Data structure of the spec field

Parameter

Mandatory

Type

Description

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

Table 6

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

Table 5

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

Table 6

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

Table 4 Data structure of the status field

Parameters

Mandatory

Type

Description

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

Table 5 Data structure of the template field

Parameters

Mandatory

Type

Description

metadata

Yes

Table 11

Standard object's metadata.

spec

Yes

PodSpec

Specification of the desired behavior of the pod.

Table 6 Data structure of the updateStrategy field

Parameters

Mandatory

Type

Description

rollingUpdate

Yes

RollingUpateDaemonSet

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.

Example request:

{
    "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"
                }]            
            }
        }
    }
}

Response

Response parameters:

For the description about response parameters, see Table2 Request parameter.

Example response:

{
    "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
    }
}

Status Code

Table 7 describes the status code of this API.

Table 7 Status code

Status Code

Description

201

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

For the description about status codes, see Status Codes.