Skip to content

Commit 6adb59b

Browse files
authored
[ja] Translate content/en/docs/tasks/manage-daemon/update-daemon-set.md (kubernetes#50177)
* translate update-daemon-set.md into Japanese * Apply review feedback
1 parent 5cd0e54 commit 6adb59b

File tree

3 files changed

+264
-0
lines changed

3 files changed

+264
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
---
2+
title: DaemonSet上でローリングアップデートを実施する
3+
content_type: task
4+
weight: 10
5+
---
6+
7+
<!-- overview -->
8+
このページでは、DaemonSet上でローリングアップデートを行う方法について説明します。
9+
10+
## {{% heading "prerequisites" %}}
11+
12+
{{< include "task-tutorial-prereqs.md" >}}
13+
14+
<!-- steps -->
15+
16+
## DaemonSetのアップデート戦略
17+
18+
DaemonSetには2種類のアップデート戦略があります:
19+
20+
* `OnDelete`: `OnDelete`アップデート戦略では、DaemonSetのテンプレートを更新した後、古いDaemonSetのPodを手動で削除した時*のみ*、新しいDaemonSetのPodが作成されます。
21+
これはKubernetesのバージョン1.5またはそれ以前のDaemonSetと同じ挙動です。
22+
* `RollingUpdate`: これは既定のアップデート戦略です。
23+
`RollingUpdate`アップデート戦略では、DaemonSetのテンプレートを更新した後、古いDaemonSetのPodが削除され、制御された方法で自動的に新しいDaemonSetのPodが作成されます。
24+
アップデートのプロセス全体を通して、各ノード上で稼働するDaemonSetのPodは最大で1つだけです。
25+
26+
## ローリングアップデートの実施
27+
28+
DaemonSetに対してローリングアップデートの機能を有効にするには、`.spec.updateStrategy.type``RollingUpdate`に設定する必要があります。
29+
30+
[`.spec.updateStrategy.rollingUpdate.maxUnavailable`](/docs/reference/kubernetes-api/workload-resources/daemon-set-v1/#DaemonSetSpec)(既定値は1)、[`.spec.minReadySeconds`](/docs/reference/kubernetes-api/workload-resources/daemon-set-v1/#DaemonSetSpec)(既定値は0)、そして[`.spec.updateStrategy.rollingUpdate.maxSurge`](/docs/reference/kubernetes-api/workload-resources/daemon-set-v1/#DaemonSetSpec)(既定値は0)についても設定したほうがよいでしょう。
31+
32+
### `RollingUpdate`アップデート戦略によるDaemonSetの作成
33+
34+
このYAMLファイルでは、アップデート戦略として`RollingUpdate`が指定されたDaemonSetを定義しています。
35+
36+
{{% code_sample file="controllers/fluentd-daemonset.yaml" %}}
37+
38+
DaemonSetのマニフェストのアップデート戦略を検証した後、DaemonSetを作成します:
39+
40+
```shell
41+
kubectl create -f https://k8s.io/examples/controllers/fluentd-daemonset.yaml
42+
```
43+
44+
あるいは、`kubectl apply`を使用してDaemonSetを更新する予定がある場合は、`kubectl apply`を使用して同じDaemonSetを作成してください。
45+
46+
```shell
47+
kubectl apply -f https://k8s.io/examples/controllers/fluentd-daemonset.yaml
48+
```
49+
50+
### DaemonSetの`RollingUpdate`アップデート戦略の確認
51+
52+
DaemonSetのアップデート戦略を確認し、`RollingUpdate`が設定されているようにします:
53+
54+
```shell
55+
kubectl get ds/fluentd-elasticsearch -o go-template='{{.spec.updateStrategy.type}}{{"\n"}}' -n kube-system
56+
```
57+
58+
システムにDaemonSetが作成されていない場合は、代わりに次のコマンドによってDaemonSetのマニフェストを確認します:
59+
60+
```shell
61+
kubectl apply -f https://k8s.io/examples/controllers/fluentd-daemonset.yaml --dry-run=client -o go-template='{{.spec.updateStrategy.type}}{{"\n"}}'
62+
```
63+
64+
どちらのコマンドも、出力は次のようになります:
65+
66+
```
67+
RollingUpdate
68+
```
69+
70+
出力が`RollingUpdate`以外の場合は、DaemonSetオブジェクトまたはマニフェストを見直して、修正してください。
71+
72+
73+
### DaemonSetテンプレートの更新
74+
75+
`RollingUpdate`のDaemonSetの`.spec.template`に対して任意の更新が行われると、ローリングアップデートがトリガーされます。
76+
新しいYAMLファイルを適用してDaemonSetを更新しましょう。
77+
これにはいくつかの異なる`kubectl`コマンドを使用することができます。
78+
79+
{{% code_sample file="controllers/fluentd-daemonset-update.yaml" %}}
80+
81+
#### 宣言型コマンド
82+
83+
[設定ファイル](/docs/tasks/manage-kubernetes-objects/declarative-config/)を使用してDaemonSetを更新する場合は、`kubectl apply`を使用します:
84+
85+
```shell
86+
kubectl apply -f https://k8s.io/examples/controllers/fluentd-daemonset-update.yaml
87+
```
88+
89+
#### 命令型コマンド
90+
91+
[命令型コマンド](/docs/tasks/manage-kubernetes-objects/imperative-command/)を使用してDaemonSetを更新する場合は、`kubectl edit`を使用します:
92+
93+
```shell
94+
kubectl edit ds/fluentd-elasticsearch -n kube-system
95+
```
96+
97+
##### コンテナイメージのみのアップデート
98+
99+
DaemonSetのテンプレート内のコンテナイメージ、つまり`.spec.template.spec.containers[*].image`のみを更新したい場合、`kubectl set image`を使用します:
100+
101+
```shell
102+
kubectl set image ds/fluentd-elasticsearch fluentd-elasticsearch=quay.io/fluentd_elasticsearch/fluentd:v2.6.0 -n kube-system
103+
```
104+
105+
### ローリングアップデートのステータスの監視
106+
107+
最後に、最新のDaemonSetの、ローリングアップデートのロールアウトステータスを監視します:
108+
109+
```shell
110+
kubectl rollout status ds/fluentd-elasticsearch -n kube-system
111+
```
112+
113+
ロールアウトが完了すると、次のような出力となります:
114+
115+
```shell
116+
daemonset "fluentd-elasticsearch" successfully rolled out
117+
```
118+
119+
## トラブルシューティング
120+
121+
### DaemonSetのローリングアップデートがスタックする
122+
123+
時々、DaemonSetのローリングアップデートがスタックする場合があります。
124+
これにはいくつかの原因が考えられます:
125+
126+
#### いくつかのノードのリソース不足
127+
128+
1つ以上のノードで新しいDaemonSetのPodをスケジュールすることができず、ロールアウトがスタックしています。
129+
これはノードの[リソース不足](/ja/docs/concepts/scheduling-eviction/node-pressure-eviction/)の可能性があります。
130+
131+
この事象が起きた場合は、`kubectl get nodes`の出力と次の出力を比較して、DaemonSetのPodがスケジュールされていないノードを見つけます:
132+
133+
```shell
134+
kubectl get pods -l name=fluentd-elasticsearch -o wide -n kube-system
135+
```
136+
137+
そのようなノードを見つけたら、新しいDaemonSetのPodのための空きを作るために、ノードからDaemonSet以外のいくつかのPodを削除します。
138+
139+
{{< note >}}
140+
コントローラーによって制御されていないPodや、レプリケートされていないPodを削除すると、これはサービスの中断が発生する原因となります。
141+
これはまた、[PodDisruptionBudget](/ja/docs/tasks/run-application/configure-pdb/)についても考慮しません。
142+
{{< /note >}}
143+
144+
#### 壊れたロールアウト
145+
146+
例えばコンテナがクラッシュを繰り返したり、(しばしばtypoによって)コンテナイメージが存在しないといった理由で最新のDaemonSetのテンプレートの更新が壊れた場合、DaemonSetのロールアウトは進みません。
147+
148+
これを修正するためには、DaemonSetのテンプレートを再度更新します。
149+
新しいロールアウトは、前の不健全なロールアウトによってブロックされません。
150+
151+
#### クロックスキュー
152+
153+
DaemonSet内で`.spec.minReadySeconds`が指定されると、マスターとノードの間のクロックスキューによって、DaemonSetがロールアウトの進捗を正しく認識できなくなる場合があります。
154+
155+
## クリーンアップ
156+
157+
NamespaceからDaemonSetを削除します:
158+
159+
```shell
160+
kubectl delete ds fluentd-elasticsearch -n kube-system
161+
```
162+
163+
## {{% heading "whatsnext" %}}
164+
165+
* [DaemonSet上でロールバックを実施する](/docs/tasks/manage-daemon/rollback-daemon-set/)を参照
166+
* [既存のDaemonSetのPodを再利用するためにDaemonSetを作成する](/ja/docs/concepts/workloads/controllers/daemonset/)を参照
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: fluentd-elasticsearch
5+
namespace: kube-system
6+
labels:
7+
k8s-app: fluentd-logging
8+
spec:
9+
selector:
10+
matchLabels:
11+
name: fluentd-elasticsearch
12+
updateStrategy:
13+
type: RollingUpdate
14+
rollingUpdate:
15+
maxUnavailable: 1
16+
template:
17+
metadata:
18+
labels:
19+
name: fluentd-elasticsearch
20+
spec:
21+
tolerations:
22+
# これらのTolerationはコントロールプレーンノード上でDaemonSetを実行できるようにするためのものです
23+
# コントロールプレーンノードでPodを実行すべきではない場合は、これらを削除してください
24+
- key: node-role.kubernetes.io/control-plane
25+
operator: Exists
26+
effect: NoSchedule
27+
- key: node-role.kubernetes.io/master
28+
operator: Exists
29+
effect: NoSchedule
30+
containers:
31+
- name: fluentd-elasticsearch
32+
image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
33+
resources:
34+
limits:
35+
memory: 200Mi
36+
requests:
37+
cpu: 100m
38+
memory: 200Mi
39+
volumeMounts:
40+
- name: varlog
41+
mountPath: /var/log
42+
- name: varlibdockercontainers
43+
mountPath: /var/lib/docker/containers
44+
readOnly: true
45+
terminationGracePeriodSeconds: 30
46+
volumes:
47+
- name: varlog
48+
hostPath:
49+
path: /var/log
50+
- name: varlibdockercontainers
51+
hostPath:
52+
path: /var/lib/docker/containers
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: fluentd-elasticsearch
5+
namespace: kube-system
6+
labels:
7+
k8s-app: fluentd-logging
8+
spec:
9+
selector:
10+
matchLabels:
11+
name: fluentd-elasticsearch
12+
updateStrategy:
13+
type: RollingUpdate
14+
rollingUpdate:
15+
maxUnavailable: 1
16+
template:
17+
metadata:
18+
labels:
19+
name: fluentd-elasticsearch
20+
spec:
21+
tolerations:
22+
# これらのTolerationはコントロールプレーンノード上でDaemonSetを実行できるようにするためのものです
23+
# コントロールプレーンノードでPodを実行すべきではない場合は、これらを削除してください
24+
- key: node-role.kubernetes.io/control-plane
25+
operator: Exists
26+
effect: NoSchedule
27+
- key: node-role.kubernetes.io/master
28+
operator: Exists
29+
effect: NoSchedule
30+
containers:
31+
- name: fluentd-elasticsearch
32+
image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
33+
volumeMounts:
34+
- name: varlog
35+
mountPath: /var/log
36+
- name: varlibdockercontainers
37+
mountPath: /var/lib/docker/containers
38+
readOnly: true
39+
terminationGracePeriodSeconds: 30
40+
volumes:
41+
- name: varlog
42+
hostPath:
43+
path: /var/log
44+
- name: varlibdockercontainers
45+
hostPath:
46+
path: /var/lib/docker/containers

0 commit comments

Comments
 (0)