Creating a DaemonSet
Function
This API is used to create a DaemonSet resource object.
URI
POST /apis/apps/v1/namespaces/{namespace}/daemonsets (for clusters of v1.9 and later)
POST /apis/extensions/v1beta1/namespaces/{namespace}/daemonsets (for clusters of v1.15 and earlier)
Table 1 describes the parameters of this API.
Request
Request parameters:
For the description about request parameters, see Table 2.
|
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 |
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. |
|
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 |
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. |
|
Parameter |
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 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
metadata |
Yes |
metadata object |
Standard object's metadata. |
|
spec |
Yes |
Object |
Specification of the desired behavior of the pod. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
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. |
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 Table 2.
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.
|
Status Code |
Description |
|---|---|
|
201 |
The request has been fulfilled, resulting in the creation of a new resource. |
For the description about error status codes, see Status Code.
Last Article: DaemonSet
Next Article: Deleting a Specified DaemonSet
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.