@@ -43,21 +43,43 @@ 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
+ <<< <<< < HEAD
79
+ kubectl apply -f https://k8s.io/examples/controllers/fluentd-daemonset.yaml --dry-run=client -o go-template=' {{.spec.updateStrategy.type}}{{"\n"}}'
80
+ =======
81
+ kubectl apply -f https://k8s.io/examples/controllers/fluentd-daemonset.yaml --dry-run -o go-template=' {{.spec.updateStrategy.type}}{{"\n"}}'
82
+ >>>>>>> Adding example for DaemonSet Rolling Update task
61
83
```
62
84
63
85
The output from both commands should be:
@@ -69,28 +91,13 @@ RollingUpdate
69
91
If the output isn't ` RollingUpdate ` , go back and modify the DaemonSet object or
70
92
manifest accordingly.
71
93
72
- ### Step 2: Creating a DaemonSet with ` RollingUpdate ` update strategy
73
94
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
95
+ ### Updating a DaemonSet template
91
96
92
97
Any updates to a ` RollingUpdate ` DaemonSet ` .spec.template ` will trigger a rolling
93
- update. This can be done with several different ` kubectl ` commands.
98
+ update. Let's update the DaemonSet by applying a new YAML file. This can be done with several different ` kubectl ` commands.
99
+
100
+ {{< codenew file="controllers/fluentd-daemonset-update.yaml" >}}
94
101
95
102
#### Declarative commands
96
103
@@ -99,21 +106,17 @@ If you update DaemonSets using
99
106
use ` kubectl apply ` :
100
107
101
108
``` shell
102
- kubectl apply -f ds-v2 .yaml
109
+ kubectl apply -f https://k8s.io/examples/application/fluentd-daemonset-update .yaml
103
110
```
104
111
105
112
#### Imperative commands
106
113
107
114
If you update DaemonSets using
108
115
[ 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
- ```
116
+ use ` kubectl edit ` :
114
117
115
118
``` shell
116
- kubectl patch ds/< daemonset-name > -p= < strategic-merge-patch >
119
+ kubectl edit ds/fluentd-elasticsearch -n kube-system
117
120
```
118
121
119
122
##### Updating only the container image
@@ -122,21 +125,21 @@ If you just need to update the container image in the DaemonSet template, i.e.
122
125
` .spec.template.spec.containers[*].image ` , use ` kubectl set image ` :
123
126
124
127
``` shell
125
- kubectl set image ds/< daemonset-name > < container-name > = < container-new-image >
128
+ kubectl set image ds/fluentd-elasticsearch fluentd-elasticsearch=quay.io/fluentd_elasticsearch/fluentd:v2.6.0 -n kube-system
126
129
```
127
130
128
- ### Step 4: Watching the rolling update status
131
+ ### Watching the rolling update status
129
132
130
133
Finally, watch the rollout status of the latest DaemonSet rolling update:
131
134
132
135
``` shell
133
- kubectl rollout status ds/< daemonset-name >
136
+ kubectl rollout status ds/fluentd-elasticsearch -n kube-system
134
137
```
135
138
136
139
When the rollout is complete, the output is similar to this:
137
140
138
141
``` shell
139
- daemonset " <daemonset-name> " successfully rolled out
142
+ daemonset " fluentd-elasticsearch " successfully rolled out
140
143
```
141
144
142
145
## Troubleshooting
@@ -156,7 +159,7 @@ When this happens, find the nodes that don't have the DaemonSet pods scheduled o
156
159
by comparing the output of ` kubectl get nodes ` and the output of:
157
160
158
161
``` shell
159
- kubectl get pods -l < daemonset-selector-key > = < daemonset-selector-value > -o wide
162
+ kubectl get pods -l name=fluentd-elasticsearch -o wide -n kube-system
160
163
```
161
164
162
165
Once you've found those nodes, delete some non-DaemonSet pods from the node to
@@ -183,6 +186,13 @@ If `.spec.minReadySeconds` is specified in the DaemonSet, clock skew between
183
186
master and nodes will make DaemonSet unable to detect the right rollout
184
187
progress.
185
188
189
+ ## Clean up
190
+
191
+ Delete DaemonSet from a namespace :
192
+
193
+ ``` shell
194
+ kubectl delete ds fluentd-elasticsearch -n kube-system
195
+ ```
186
196
187
197
{{% /capture %}}
188
198
0 commit comments