@@ -43,21 +43,39 @@ To enable the rolling update feature of a DaemonSet, you must set its
43
43
You may want to set [ ` .spec.updateStrategy.rollingUpdate.maxUnavailable ` ] ( /docs/concepts/workloads/controllers/deployment/#max-unavailable ) (default
44
44
to 1) and [ ` .spec.minReadySeconds ` ] ( /docs/concepts/workloads/controllers/deployment/#min-ready-seconds ) (default to 0) as well.
45
45
46
+ ### Creating a DaemonSet with ` RollingUpdate ` update strategy
46
47
47
- ### Step 1: Checking DaemonSet ` RollingUpdate ` update strategy
48
+ This YAML file specifies a DaemonSet with an update strategy as 'RollingUpdate'
48
49
49
- First, check the update strategy of your DaemonSet, and make sure it's set to
50
+ {{< codenew file="controllers/fluentd-daemonset.yaml" >}}
51
+
52
+ After verifying the update strategy of the DaemonSet manifest, create the DaemonSet:
53
+
54
+ ``` shell
55
+ kubectl create -f https://k8s.io/examples/controllers/fluentd-daemonset.yaml
56
+ ```
57
+
58
+ Alternatively, use ` kubectl apply ` to create the same DaemonSet if you plan to
59
+ update the DaemonSet with ` kubectl apply ` .
60
+
61
+ ``` shell
62
+ kubectl apply -f https://k8s.io/examples/controllers/fluentd-daemonset.yaml
63
+ ```
64
+
65
+ ### Checking DaemonSet ` RollingUpdate ` update strategy
66
+
67
+ Check the update strategy of your DaemonSet, and make sure it's set to
50
68
` RollingUpdate ` :
51
69
52
70
``` shell
53
- kubectl get ds/< daemonset-name > -o go-template=' {{.spec.updateStrategy.type}}{{"\n"}}'
71
+ kubectl get ds/fluentd-elasticsearch -o go-template=' {{.spec.updateStrategy.type}}{{"\n"}}' -n kube-system
54
72
```
55
73
56
74
If you haven't created the DaemonSet in the system, check your DaemonSet
57
75
manifest with the following command instead:
58
76
59
77
``` shell
60
- kubectl apply -f ds .yaml --dry-run=client -o go-template=' {{.spec.updateStrategy.type}}{{"\n"}}'
78
+ kubectl apply -f https://k8s.io/examples/controllers/fluentd-daemonset .yaml --dry-run=client -o go-template=' {{.spec.updateStrategy.type}}{{"\n"}}'
61
79
```
62
80
63
81
The output from both commands should be:
@@ -69,28 +87,13 @@ RollingUpdate
69
87
If the output isn't ` RollingUpdate ` , go back and modify the DaemonSet object or
70
88
manifest accordingly.
71
89
72
- ### Step 2: Creating a DaemonSet with ` RollingUpdate ` update strategy
73
90
74
- If you have already created the DaemonSet, you may skip this step and jump to
75
- step 3.
76
-
77
- After verifying the update strategy of the DaemonSet manifest, create the DaemonSet:
78
-
79
- ``` shell
80
- kubectl create -f ds.yaml
81
- ```
82
-
83
- Alternatively, use ` kubectl apply ` to create the same DaemonSet if you plan to
84
- update the DaemonSet with ` kubectl apply ` .
85
-
86
- ``` shell
87
- kubectl apply -f ds.yaml
88
- ```
89
-
90
- ### Step 3: Updating a DaemonSet template
91
+ ### Updating a DaemonSet template
91
92
92
93
Any updates to a ` RollingUpdate ` DaemonSet ` .spec.template ` will trigger a rolling
93
- update. This can be done with several different ` kubectl ` commands.
94
+ update. Let's update the DaemonSet by applying a new YAML file. This can be done with several different ` kubectl ` commands.
95
+
96
+ {{< codenew file="controllers/fluentd-daemonset-update.yaml" >}}
94
97
95
98
#### Declarative commands
96
99
@@ -99,21 +102,17 @@ If you update DaemonSets using
99
102
use ` kubectl apply ` :
100
103
101
104
``` shell
102
- kubectl apply -f ds-v2 .yaml
105
+ kubectl apply -f https://k8s.io/examples/application/fluentd-daemonset-update .yaml
103
106
```
104
107
105
108
#### Imperative commands
106
109
107
110
If you update DaemonSets using
108
111
[ imperative commands] ( /docs/tasks/manage-kubernetes-objects/imperative-command/ ) ,
109
- use ` kubectl edit ` or ` kubectl patch ` :
110
-
111
- ``` shell
112
- kubectl edit ds/< daemonset-name>
113
- ```
112
+ use ` kubectl edit ` :
114
113
115
114
``` shell
116
- kubectl patch ds/< daemonset-name > -p= < strategic-merge-patch >
115
+ kubectl edit ds/fluentd-elasticsearch -n kube-system
117
116
```
118
117
119
118
##### Updating only the container image
@@ -122,21 +121,21 @@ If you just need to update the container image in the DaemonSet template, i.e.
122
121
` .spec.template.spec.containers[*].image ` , use ` kubectl set image ` :
123
122
124
123
``` shell
125
- kubectl set image ds/< daemonset-name > < container-name > = < container-new-image >
124
+ kubectl set image ds/fluentd-elasticsearch fluentd-elasticsearch=quay.io/fluentd_elasticsearch/fluentd:v2.6.0 -n kube-system
126
125
```
127
126
128
- ### Step 4: Watching the rolling update status
127
+ ### Watching the rolling update status
129
128
130
129
Finally, watch the rollout status of the latest DaemonSet rolling update:
131
130
132
131
``` shell
133
- kubectl rollout status ds/< daemonset-name >
132
+ kubectl rollout status ds/fluentd-elasticsearch -n kube-system
134
133
```
135
134
136
135
When the rollout is complete, the output is similar to this:
137
136
138
137
``` shell
139
- daemonset " <daemonset-name> " successfully rolled out
138
+ daemonset " fluentd-elasticsearch " successfully rolled out
140
139
```
141
140
142
141
## Troubleshooting
@@ -156,7 +155,7 @@ When this happens, find the nodes that don't have the DaemonSet pods scheduled o
156
155
by comparing the output of ` kubectl get nodes ` and the output of:
157
156
158
157
``` shell
159
- kubectl get pods -l < daemonset-selector-key > = < daemonset-selector-value > -o wide
158
+ kubectl get pods -l name=fluentd-elasticsearch -o wide -n kube-system
160
159
```
161
160
162
161
Once you've found those nodes, delete some non-DaemonSet pods from the node to
@@ -183,6 +182,13 @@ If `.spec.minReadySeconds` is specified in the DaemonSet, clock skew between
183
182
master and nodes will make DaemonSet unable to detect the right rollout
184
183
progress.
185
184
185
+ ## Clean up
186
+
187
+ Delete DaemonSet from a namespace :
188
+
189
+ ``` shell
190
+ kubectl delete ds fluentd-elasticsearch -n kube-system
191
+ ```
186
192
187
193
{{% /capture %}}
188
194
0 commit comments