1
1
---
2
- reviewers :
3
- - jsafrane
4
- title : Create static Pods
2
+ title : static Podを作成する
5
3
weight : 170
6
4
content_type : task
7
5
---
8
6
9
7
<!-- overview -->
10
8
11
9
12
- * Static Pods* are managed directly by the kubelet daemon on a specific node,
13
- without the {{< glossary_tooltip text="API server" term_id="kube-apiserver" >}}
14
- observing them.
15
- Unlike Pods that are managed by the control plane (for example, a
16
- {{< glossary_tooltip text="Deployment" term_id="deployment" >}});
17
- instead, the kubelet watches each static Pod (and restarts it if it fails).
10
+ * Static Pod* とは、{{< glossary_tooltip text="APIサーバー" term_id="kube-apiserver" >}}が監視せず、特定のノード上のkubeletデーモンによって直接管理されるPodです。コントロールプレーンに管理されるPod(たとえば{{< glossary_tooltip text="Deployment" term_id="deployment" >}}など)とは異なり、kubeletがそれぞれのstatic Podを監視(および障害時には再起動)します。
18
11
19
- Static Pods are always bound to one {{< glossary_tooltip term_id="kubelet" >}} on a specific node.
12
+ Static Podは、常に特定のノード上の1つの {{< glossary_tooltip term_id="kubelet" >}}に紐付けられます。
20
13
21
- The kubelet automatically tries to create a {{< glossary_tooltip text="mirror Pod" term_id="mirror-pod" >}}
22
- on the Kubernetes API server for each static Pod.
23
- This means that the Pods running on a node are visible on the API server,
24
- but cannot be controlled from there.
14
+ kubeletは、各static Podに対して、自動的にKubernetes APIサーバー上に{{< glossary_tooltip text="ミラーPod" term_id="mirror-pod" >}}の作成を試みます。つまり、ノード上で実行中のPodはAPIサーバーから検出されますが、APIサーバー自身から制御されることはないということです。
25
15
26
16
{{< note >}}
27
- If you are running clustered Kubernetes and are using static
28
- Pods to run a Pod on every node, you should probably be using a
29
- {{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}
30
- instead.
17
+ 複数ノードからなるKubernetesクラスターを実行していて、Podをすべてのノード上で実行するためにstatic Podを使用している場合、おそらくstatic Podの代わりに{{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}を使用するべきでしょう。
31
18
{{< /note >}}
32
19
33
-
34
-
35
20
## {{% heading "prerequisites" %}}
36
21
37
-
38
22
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
39
23
40
- This page assumes you're using {{< glossary_tooltip term_id="docker" >}} to run Pods,
41
- and that your nodes are running the Fedora operating system.
42
- Instructions for other distributions or Kubernetes installations may vary.
43
-
44
-
45
-
46
-
24
+ このページの説明では、Podを実行するために{{< glossary_tooltip term_id="docker" >}}を使用しており、ノード上のOSがFedoraであることを前提としています。他のディストリビューションやKubernetesのインストール方法によっては、操作が異なる場合があります。
47
25
48
26
<!-- steps -->
49
27
50
- ## Create a static pod {#static-pod-creation}
28
+ ## static Podを作成する {#static-pod-creation}
51
29
52
- You can configure a static Pod with either a [ file system hosted configuration file ] ( /docs/tasks/configure-pod-container/static-pod/ #configuration-files) or a [ web hosted configuration file ] ( /docs/tasks/configure-pod-container/static-pod/ #pods-created-via-http ) .
30
+ static Podは、 [ ファイルシステム上でホストされた設定ファイル ] ( #configuration-files ) または [ ウェブ上でホストされた設定ファイル ] ( /#pods-created-via-http ) を使用して設定できます。
53
31
54
- ### Filesystem-hosted static Pod manifest {#configuration-files}
32
+ ### ファイルシステム上でホストされたstatic Podマニフェスト {#configuration-files}
55
33
56
- Manifests are standard Pod definitions in JSON or YAML format in a specific directory. Use the ` staticPodPath: <the directory> ` field in the [ kubelet configuration file] ( /docs/tasks/administer-cluster/kubelet-config-file ) , which periodically scans the directory and creates/deletes static Pods as YAML/JSON files appear/disappear there.
57
- Note that the kubelet will ignore files starting with dots when scanning the specified directory.
34
+ マニフェストは、JSONまたはYAML形式の標準のPod定義で、特定のディレクトリに置きます。[ kubeletの設定ファイル] ( /docs/tasks/administer-cluster/kubelet-config-file ) の中で、` staticPodPath: <ディレクトリの場所> ` というフィールドを使用すると、kubeletがこのディレクトリを定期的にスキャンして、YAML/JSONファイルが作成/削除されるたびに、static Podの作成/削除が行われるようになります。指定したディレクトリをスキャンする際、kubeletはドットから始まる名前のファイルを無視することに注意してください。
58
35
59
- For example, this is how to start a simple web server as a static Pod:
36
+ 例として、単純なウェブサーバーをstatic Podとして実行する方法を示します。
60
37
61
- 1 . Choose a node where you want to run the static Pod. In this example, it's ` my-node1 ` .
38
+ 1 . static Podを実行したいノードを選択します。この例では、 ` my-node1 ` です。
62
39
63
40
``` shell
64
41
ssh my-node1
65
42
```
66
43
67
- 2. Choose a directory, say ` /etc/kubelet.d` and place a web server Pod definition there, for example ` /etc/kubelet.d/static-web.yaml` :
44
+ 2. ディレクトリを選び(ここでは ` /etc/kubelet.d` とします)、ここにウェブサーバーのPodの定義を置きます。たとえば、 ` /etc/kubelet.d/static-web.yaml` に置きます。
68
45
69
46
` ` ` shell
70
- # Run this command on the node where kubelet is running
47
+ # このコマンドは、kubeletが実行中のノード上で実行してください
71
48
mkdir /etc/kubelet.d/
72
49
cat << EOF >/etc/kubelet.d/static-web.yaml
73
50
apiVersion: v1
@@ -87,31 +64,28 @@ For example, this is how to start a simple web server as a static Pod:
87
64
EOF
88
65
` ` `
89
66
90
- 3. Configure your kubelet on the node to use this directory by running it with ` --pod-manifest-path=/etc/kubelet.d/` argument. On Fedora edit ` /etc/kubernetes/kubelet` to include this line:
67
+ 3. ノード上のkubeletがこのディレクトリを使用するようにするために、 ` --pod-manifest-path=/etc/kubelet.d/` 引数を付けてkubeletを実行するように設定します。Fedoraの場合、次の行が含まれるように ` /etc/kubernetes/kubelet` を編集します。
91
68
92
69
` ` `
93
70
KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --pod-manifest-path=/etc/kubelet.d/"
94
71
` ` `
95
- or add the ` staticPodPath: <the directory>` field in the [kubelet configuration file](/docs/tasks/administer-cluster/kubelet-config-file).
96
72
97
- 4. Restart the kubelet. On Fedora, you would run:
73
+ あるいは、[kubeletの設定ファイル](/docs/tasks/administer-cluster/kubelet-config-file)に、` staticPodPath: <ディレクトリの場所>` フィールドを追加することでも設定できます。
74
+
75
+ 4. kubeletを再起動します。Fedoraの場合、次のコマンドを実行します。
98
76
99
77
` ` ` shell
100
- # Run this command on the node where the kubelet is running
78
+ # このコマンドは、kubeletが実行中のノード上で実行してください
101
79
systemctl restart kubelet
102
80
` ` `
103
81
104
- # ## Web-hosted static pod manifest {#pods-created-via-http}
82
+ # ## ウェブ上でホストされたstatic Podマニフェスト {#pods-created-via-http}
105
83
106
- Kubelet periodically downloads a file specified by ` --manifest-url=<URL>` argument
107
- and interprets it as a JSON/YAML file that contains Pod definitions.
108
- Similar to how [filesystem-hosted manifests](# configuration-files) work, the kubelet
109
- refetches the manifest on a schedule. If there are changes to the list of static
110
- Pods, the kubelet applies them.
84
+ kubeletは、` --manifest-url=<URL>` 引数で指定されたファイルを定期的にダウンロードし、Podの定義が含まれたJSON/YAMLファイルとして解釈します。kubeletは、[ファイルシステム上でホストされたマニフェスト](# configuration-files)での動作方法と同じように、定期的にマニフェストを再取得します。static Podのリスト中に変更が見つかると、kubeletがその変更を適用します。
111
85
112
- To use this approach:
86
+ このアプローチを採用する場合、次のように設定します。
113
87
114
- 1. Create a YAML file and store it on a web server so that you can pass the URL of that file to the kubelet.
88
+ 1. YAMLファイルを作成し、kubeletにファイルのURLを渡せるようにするために、ウェブサーバー上に保存する。
115
89
116
90
` ` ` yaml
117
91
apiVersion: v1
@@ -130,39 +104,38 @@ To use this approach:
130
104
protocol: TCP
131
105
` ` `
132
106
133
- 2. Configure the kubelet on your selected node to use this web manifest by running it with ` --manifest-url=< manifest-url> ` . On Fedora, edit ` /etc/kubernetes/kubelet` to include this line:
107
+ 2. 選択したノード上のkubeletを ` --manifest-url=< manifest-url> ` を使用して実行することで、このウェブ上のマニフェストを使用するように設定する。Fedoraの場合、 ` /etc/kubernetes/kubelet` に次の行が含まれるように編集します。
134
108
135
109
` ` `
136
- KUBELET_ARGS=" --cluster-dns=10.254.0.10 --cluster-domain=kube.local --manifest-url=<manifest-url> "
110
+ KUBELET_ARGS=" --cluster-dns=10.254.0.10 --cluster-domain=kube.local --manifest-url=<マニフェストのURL "
137
111
` ` `
138
112
139
- 3. Restart the kubelet. On Fedora, you would run:
113
+ 3. kubeletを再起動する。Fedoraの場合、次のコマンドを実行します。
140
114
141
115
` ` ` shell
142
- # Run this command on the node where the kubelet is running
116
+ # このコマンドは、kubeletが実行中のノード上で実行してください
143
117
systemctl restart kubelet
144
118
` ` `
145
119
146
- # # Observe static pod behavior {#behavior-of-static-pods}
120
+ # # static Podの動作を観察する {#behavior-of-static-pods}
121
+
122
+ kubeletが起動すると、定義されたすべてのstatic Podを起動します。ここまででstatic Podを設定してkubeletを再起動したため、すでに新しいstatic Podが実行中になっているはずです。
147
123
148
- When the kubelet starts, it automatically starts all defined static Pods. As you have
149
- defined a static Pod and restarted the kubelet, the new static Pod should
150
- already be running.
124
+ 次のコマンドを(ノード上で)実行することで、(static Podを含む)実行中のコンテナを確認できます。
151
125
152
- You can view running containers (including static Pods) by running (on the node):
153
126
` ` ` shell
154
- # Run this command on the node where the kubelet is running
127
+ # このコマンドは、kubeletが実行中のノード上で実行してください
155
128
docker ps
156
129
` ` `
157
130
158
- The output might be something like:
131
+ 出力は次のようになります。
159
132
160
133
` ` `
161
134
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
162
135
f6d05272b57e nginx:latest " nginx" 8 minutes ago Up 8 minutes k8s_web.6f802af4_static-web-fk-node1_default_67e24ed9466ba55986d120c867395f3c_378e5f3c
163
136
` ` `
164
137
165
- You can see the mirror Pod on the API server:
138
+ APIサーバー上では、ミラーPodを確認できます。
166
139
167
140
` ` ` shell
168
141
kubectl get pods
@@ -173,25 +146,23 @@ static-web-my-node1 1/1 Running 0 2m
173
146
` ` `
174
147
175
148
{{< note > }}
176
- Make sure the kubelet has permission to create the mirror Pod in the API server. If not, the creation request is rejected by the API server. See
177
- [PodSecurityPolicy](/docs/concepts/policy/pod-security-policy/).
149
+ kubeletにAPIサーバー上のミラーPodを作成する権限があることを確認してください。もし権限がない場合、APIサーバーによって作成のリクエストが拒否されてしまいます。詳しくは、[PodSecurityPolicy](/docs/concepts/policy/pod-security-policy/)を参照してください。
178
150
{{< /note > }}
179
151
180
152
181
- {{< glossary_tooltip term_id=" label" text=" Labels" > }} from the static Pod are
182
- propagated into the mirror Pod. You can use those labels as normal via
183
- {{< glossary_tooltip term_id=" selector" text=" selectors" > }}, etc.
153
+ static Podに付けた{{< glossary_tooltip term_id=" label" text=" ラベル" > }}はミラーPodに伝搬します。ミラーPodに付けたラベルは、通常のPodと同じように{{< glossary_tooltip term_id=" selector" text=" セレクター" > }}などから利用できます。
184
154
185
- If you try to use ` kubectl` to delete the mirror Pod from the API server,
186
- the kubelet _doesn' t_ remove the static Pod:
155
+ もし` kubectl` を使用してAPIサーバーからミラーPodを削除しようとしても、kubeletはstatic Podを削除* しません* 。
187
156
188
157
` ` ` shell
189
158
kubectl delete pod static-web-my-node1
190
159
` ` `
191
160
` ` `
192
161
pod " static-web-my-node1" deleted
193
162
` ` `
194
- You can see that the Pod is still running:
163
+
164
+ Podはまだ実行中であることがわかります。
165
+
195
166
` ` ` shell
196
167
kubectl get pods
197
168
` ` `
@@ -200,14 +171,11 @@ NAME READY STATUS RESTARTS AGE
200
171
static-web-my-node1 1/1 Running 0 12s
201
172
` ` `
202
173
203
- Back on your node where the kubelet is running, you can try to stop the Docker
204
- container manually.
205
- You' ll see that, after a time, the kubelet will notice and will restart the Pod
206
- automatically:
174
+ kubeletが実行中のノードに戻り、Dockerコンテナを手動で停止してみることができます。しばらくすると、kubeletが変化に気づき、Podを自動的に再起動することがわかります。
207
175
208
176
` ` ` shell
209
- # Run these commands on the node where the kubelet is running
210
- docker stop f6d05272b57e # replace with the ID of your container
177
+ # このコマンドは、kubeletが実行中のノード上で実行してください
178
+ docker stop f6d05272b57e # 実際のコンテナIDと置き換えてください
211
179
sleep 20
212
180
docker ps
213
181
` ` `
@@ -216,13 +184,13 @@ CONTAINER ID IMAGE COMMAND CREATED ...
216
184
5b920cbaf8b1 nginx:latest " nginx -g 'daemon of 2 seconds ago ...
217
185
` ` `
218
186
219
- # # Dynamic addition and removal of static pods
187
+ # # static Podの動的な追加と削除
220
188
221
- The running kubelet periodically scans the configured directory ( ` /etc/kubelet.d` in our example) for changes and adds/removes Pods as files appear/disappear in this directory.
189
+ 実行中のkubeletは設定ディレクトリ(この例では ` /etc/kubelet.d` )の変更を定期的にスキャンし、このディレクトリ内にファイルが追加/削除されると、Podの追加/削除を行います。
222
190
223
191
` ` ` shell
224
192
# This assumes you are using filesystem-hosted static Pod configuration
225
- # Run these commands on the node where the kubelet is running
193
+ # このコマンドは、kubeletが実行中のノード上で実行してください
226
194
#
227
195
mv /etc/kubelet.d/static-web.yaml /tmp
228
196
sleep 20
@@ -236,5 +204,3 @@ docker ps
236
204
CONTAINER ID IMAGE COMMAND CREATED ...
237
205
e7a62e3427f1 nginx:latest " nginx -g ' daemon of 27 seconds ago
238
206
```
239
-
240
-
0 commit comments