Translate tasks/configure-pod-container/static-pod into Japanese.
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
---
|
---
|
||||||
reviewers:
|
title: static Podを作成する
|
||||||
- jsafrane
|
|
||||||
title: Create static Pods
|
|
||||||
weight: 170
|
weight: 170
|
||||||
content_type: task
|
content_type: task
|
||||||
---
|
---
|
||||||
@@ -9,65 +7,44 @@ content_type: task
|
|||||||
<!-- overview -->
|
<!-- overview -->
|
||||||
|
|
||||||
|
|
||||||
*Static Pods* are managed directly by the kubelet daemon on a specific node,
|
*Static Pod*とは、{{< glossary_tooltip text="APIサーバー" term_id="kube-apiserver" >}}が監視せず、特定のノード上のkubeletデーモンによって直接管理されるPodです。コントロールプレーンに管理されるPod(たとえば{{< glossary_tooltip text="Deployment" term_id="deployment" >}}など)とは異なり、kubeletがそれぞれのstatic Podを監視(および障害時には再起動)します。
|
||||||
without the {{< glossary_tooltip text="API server" term_id="kube-apiserver" >}}
|
|
||||||
observing them.
|
|
||||||
Unlike Pods that are managed by the control plane (for example, a
|
|
||||||
{{< glossary_tooltip text="Deployment" term_id="deployment" >}});
|
|
||||||
instead, the kubelet watches each static Pod (and restarts it if it fails).
|
|
||||||
|
|
||||||
Static Pods are always bound to one {{< glossary_tooltip term_id="kubelet" >}} on a specific node.
|
Static Podは、常に特定のノード上の1つの{{< glossary_tooltip term_id="kubelet" >}}に紐付けられます。
|
||||||
|
|
||||||
The kubelet automatically tries to create a {{< glossary_tooltip text="mirror Pod" term_id="mirror-pod" >}}
|
kubeletは、各static Podに対して、自動的にKubernetes APIサーバー上に{{< glossary_tooltip text="ミラーPod" term_id="mirror-pod" >}}の作成を試みます。つまり、ノード上で実行中のPodはAPIサーバーから検出されますが、APIサーバー自身から制御されることはないということです。
|
||||||
on the Kubernetes API server for each static Pod.
|
|
||||||
This means that the Pods running on a node are visible on the API server,
|
|
||||||
but cannot be controlled from there.
|
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
If you are running clustered Kubernetes and are using static
|
複数ノードからなるKubernetesクラスターを実行していて、Podをすべてのノード上で実行するためにstatic Podを使用している場合、おそらくstatic Podの代わりに{{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}を使用するべきでしょう。
|
||||||
Pods to run a Pod on every node, you should probably be using a
|
|
||||||
{{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}
|
|
||||||
instead.
|
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## {{% heading "prerequisites" %}}
|
## {{% heading "prerequisites" %}}
|
||||||
|
|
||||||
|
|
||||||
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
||||||
|
|
||||||
This page assumes you're using {{< glossary_tooltip term_id="docker" >}} to run Pods,
|
このページの説明では、Podを実行するために{{< glossary_tooltip term_id="docker" >}}を使用しており、ノード上のOSがFedoraであることを前提としています。他のディストリビューションやKubernetesのインストール方法によっては、操作が異なる場合があります。
|
||||||
and that your nodes are running the Fedora operating system.
|
|
||||||
Instructions for other distributions or Kubernetes installations may vary.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- steps -->
|
<!-- steps -->
|
||||||
|
|
||||||
## Create a static pod {#static-pod-creation}
|
## static Podを作成する {#static-pod-creation}
|
||||||
|
|
||||||
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).
|
static Podは、[ファイルシステム上でホストされた設定ファイル](#configuration-files)または[ウェブ上でホストされた設定ファイル](/#pods-created-via-http)を使用して設定できます。
|
||||||
|
|
||||||
### Filesystem-hosted static Pod manifest {#configuration-files}
|
### ファイルシステム上でホストされたstatic Podマニフェスト {#configuration-files}
|
||||||
|
|
||||||
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.
|
マニフェストは、JSONまたはYAML形式の標準のPod定義で、特定のディレクトリに置きます。[kubeletの設定ファイル](/docs/tasks/administer-cluster/kubelet-config-file)の中で、`staticPodPath: <ディレクトリの場所>`というフィールドを使用すると、kubeletがこのディレクトリを定期的にスキャンして、YAML/JSONファイルが作成/削除されるたびに、static Podの作成/削除が行われるようになります。指定したディレクトリをスキャンする際、kubeletはドットから始まる名前のファイルを無視することに注意してください。
|
||||||
Note that the kubelet will ignore files starting with dots when scanning the specified directory.
|
|
||||||
|
|
||||||
For example, this is how to start a simple web server as a static Pod:
|
例として、単純なウェブサーバーをstatic Podとして実行する方法を示します。
|
||||||
|
|
||||||
1. Choose a node where you want to run the static Pod. In this example, it's `my-node1`.
|
1. static Podを実行したいノードを選択します。この例では、`my-node1`です。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
ssh my-node1
|
ssh my-node1
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Choose a directory, say `/etc/kubelet.d` and place a web server Pod definition there, for example `/etc/kubelet.d/static-web.yaml`:
|
2. ディレクトリを選び(ここでは`/etc/kubelet.d`とします)、ここにウェブサーバーのPodの定義を置きます。たとえば、`/etc/kubelet.d/static-web.yaml`に置きます。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Run this command on the node where kubelet is running
|
# このコマンドは、kubeletが実行中のノード上で実行してください
|
||||||
mkdir /etc/kubelet.d/
|
mkdir /etc/kubelet.d/
|
||||||
cat <<EOF >/etc/kubelet.d/static-web.yaml
|
cat <<EOF >/etc/kubelet.d/static-web.yaml
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -87,31 +64,28 @@ For example, this is how to start a simple web server as a static Pod:
|
|||||||
EOF
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
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:
|
3. ノード上のkubeletがこのディレクトリを使用するようにするために、`--pod-manifest-path=/etc/kubelet.d/`引数を付けてkubeletを実行するように設定します。Fedoraの場合、次の行が含まれるように`/etc/kubernetes/kubelet`を編集します。
|
||||||
|
|
||||||
```
|
```
|
||||||
KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --pod-manifest-path=/etc/kubelet.d/"
|
KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --pod-manifest-path=/etc/kubelet.d/"
|
||||||
```
|
```
|
||||||
or add the `staticPodPath: <the directory>` field in the [kubelet configuration file](/docs/tasks/administer-cluster/kubelet-config-file).
|
|
||||||
|
|
||||||
4. Restart the kubelet. On Fedora, you would run:
|
あるいは、[kubeletの設定ファイル](/docs/tasks/administer-cluster/kubelet-config-file)に、`staticPodPath: <ディレクトリの場所>`フィールドを追加することでも設定できます。
|
||||||
|
|
||||||
|
4. kubeletを再起動します。Fedoraの場合、次のコマンドを実行します。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Run this command on the node where the kubelet is running
|
# このコマンドは、kubeletが実行中のノード上で実行してください
|
||||||
systemctl restart kubelet
|
systemctl restart kubelet
|
||||||
```
|
```
|
||||||
|
|
||||||
### Web-hosted static pod manifest {#pods-created-via-http}
|
### ウェブ上でホストされたstatic Podマニフェスト {#pods-created-via-http}
|
||||||
|
|
||||||
Kubelet periodically downloads a file specified by `--manifest-url=<URL>` argument
|
kubeletは、`--manifest-url=<URL>`引数で指定されたファイルを定期的にダウンロードし、Podの定義が含まれたJSON/YAMLファイルとして解釈します。kubeletは、[ファイルシステム上でホストされたマニフェスト](#configuration-files)での動作方法と同じように、定期的にマニフェストを再取得します。static Podのリスト中に変更が見つかると、kubeletがその変更を適用します。
|
||||||
and interprets it as a JSON/YAML file that contains Pod definitions.
|
|
||||||
Similar to how [filesystem-hosted manifests](#configuration-files) work, the kubelet
|
|
||||||
refetches the manifest on a schedule. If there are changes to the list of static
|
|
||||||
Pods, the kubelet applies them.
|
|
||||||
|
|
||||||
To use this approach:
|
このアプローチを採用する場合、次のように設定します。
|
||||||
|
|
||||||
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.
|
1. YAMLファイルを作成し、kubeletにファイルのURLを渡せるようにするために、ウェブサーバー上に保存する。
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -130,39 +104,38 @@ To use this approach:
|
|||||||
protocol: TCP
|
protocol: TCP
|
||||||
```
|
```
|
||||||
|
|
||||||
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:
|
2. 選択したノード上のkubeletを`--manifest-url=<manifest-url>`を使用して実行することで、このウェブ上のマニフェストを使用するように設定する。Fedoraの場合、`/etc/kubernetes/kubelet`に次の行が含まれるように編集します。
|
||||||
|
|
||||||
```
|
```
|
||||||
KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --manifest-url=<manifest-url>"
|
KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --manifest-url=<マニフェストのURL"
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Restart the kubelet. On Fedora, you would run:
|
3. kubeletを再起動する。Fedoraの場合、次のコマンドを実行します。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Run this command on the node where the kubelet is running
|
# このコマンドは、kubeletが実行中のノード上で実行してください
|
||||||
systemctl restart kubelet
|
systemctl restart kubelet
|
||||||
```
|
```
|
||||||
|
|
||||||
## Observe static pod behavior {#behavior-of-static-pods}
|
## static Podの動作を観察する {#behavior-of-static-pods}
|
||||||
|
|
||||||
When the kubelet starts, it automatically starts all defined static Pods. As you have
|
kubeletが起動すると、定義されたすべてのstatic Podを起動します。ここまででstatic Podを設定してkubeletを再起動したため、すでに新しいstatic Podが実行中になっているはずです。
|
||||||
defined a static Pod and restarted the kubelet, the new static Pod should
|
|
||||||
already be running.
|
次のコマンドを(ノード上で)実行することで、(static Podを含む)実行中のコンテナを確認できます。
|
||||||
|
|
||||||
You can view running containers (including static Pods) by running (on the node):
|
|
||||||
```shell
|
```shell
|
||||||
# Run this command on the node where the kubelet is running
|
# このコマンドは、kubeletが実行中のノード上で実行してください
|
||||||
docker ps
|
docker ps
|
||||||
```
|
```
|
||||||
|
|
||||||
The output might be something like:
|
出力は次のようになります。
|
||||||
|
|
||||||
```
|
```
|
||||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||||
f6d05272b57e nginx:latest "nginx" 8 minutes ago Up 8 minutes k8s_web.6f802af4_static-web-fk-node1_default_67e24ed9466ba55986d120c867395f3c_378e5f3c
|
f6d05272b57e nginx:latest "nginx" 8 minutes ago Up 8 minutes k8s_web.6f802af4_static-web-fk-node1_default_67e24ed9466ba55986d120c867395f3c_378e5f3c
|
||||||
```
|
```
|
||||||
|
|
||||||
You can see the mirror Pod on the API server:
|
APIサーバー上では、ミラーPodを確認できます。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pods
|
kubectl get pods
|
||||||
@@ -173,17 +146,13 @@ static-web-my-node1 1/1 Running 0 2m
|
|||||||
```
|
```
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
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
|
kubeletにAPIサーバー上のミラーPodを作成する権限があることを確認してください。もし権限がない場合、APIサーバーによって作成のリクエストが拒否されてしまいます。詳しくは、[PodSecurityPolicy](/docs/concepts/policy/pod-security-policy/)を参照してください。
|
||||||
[PodSecurityPolicy](/docs/concepts/policy/pod-security-policy/).
|
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
|
|
||||||
{{< glossary_tooltip term_id="label" text="Labels" >}} from the static Pod are
|
static Podに付けた{{< glossary_tooltip term_id="label" text="ラベル" >}}はミラーPodに伝搬します。ミラーPodに付けたラベルは、通常のPodと同じように{{< glossary_tooltip term_id="selector" text="セレクター" >}}などから利用できます。
|
||||||
propagated into the mirror Pod. You can use those labels as normal via
|
|
||||||
{{< glossary_tooltip term_id="selector" text="selectors" >}}, etc.
|
|
||||||
|
|
||||||
If you try to use `kubectl` to delete the mirror Pod from the API server,
|
もし`kubectl`を使用してAPIサーバーからミラーPodを削除しようとしても、kubeletはstatic Podを削除*しません*。
|
||||||
the kubelet _doesn't_ remove the static Pod:
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl delete pod static-web-my-node1
|
kubectl delete pod static-web-my-node1
|
||||||
@@ -191,7 +160,9 @@ kubectl delete pod static-web-my-node1
|
|||||||
```
|
```
|
||||||
pod "static-web-my-node1" deleted
|
pod "static-web-my-node1" deleted
|
||||||
```
|
```
|
||||||
You can see that the Pod is still running:
|
|
||||||
|
Podはまだ実行中であることがわかります。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pods
|
kubectl get pods
|
||||||
```
|
```
|
||||||
@@ -200,14 +171,11 @@ NAME READY STATUS RESTARTS AGE
|
|||||||
static-web-my-node1 1/1 Running 0 12s
|
static-web-my-node1 1/1 Running 0 12s
|
||||||
```
|
```
|
||||||
|
|
||||||
Back on your node where the kubelet is running, you can try to stop the Docker
|
kubeletが実行中のノードに戻り、Dockerコンテナを手動で停止してみることができます。しばらくすると、kubeletが変化に気づき、Podを自動的に再起動することがわかります。
|
||||||
container manually.
|
|
||||||
You'll see that, after a time, the kubelet will notice and will restart the Pod
|
|
||||||
automatically:
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Run these commands on the node where the kubelet is running
|
# このコマンドは、kubeletが実行中のノード上で実行してください
|
||||||
docker stop f6d05272b57e # replace with the ID of your container
|
docker stop f6d05272b57e # 実際のコンテナIDと置き換えてください
|
||||||
sleep 20
|
sleep 20
|
||||||
docker ps
|
docker ps
|
||||||
```
|
```
|
||||||
@@ -216,13 +184,13 @@ CONTAINER ID IMAGE COMMAND CREATED ...
|
|||||||
5b920cbaf8b1 nginx:latest "nginx -g 'daemon of 2 seconds ago ...
|
5b920cbaf8b1 nginx:latest "nginx -g 'daemon of 2 seconds ago ...
|
||||||
```
|
```
|
||||||
|
|
||||||
## Dynamic addition and removal of static pods
|
## static Podの動的な追加と削除
|
||||||
|
|
||||||
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.
|
実行中のkubeletは設定ディレクトリ(この例では`/etc/kubelet.d`)の変更を定期的にスキャンし、このディレクトリ内にファイルが追加/削除されると、Podの追加/削除を行います。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# This assumes you are using filesystem-hosted static Pod configuration
|
# This assumes you are using filesystem-hosted static Pod configuration
|
||||||
# Run these commands on the node where the kubelet is running
|
# このコマンドは、kubeletが実行中のノード上で実行してください
|
||||||
#
|
#
|
||||||
mv /etc/kubelet.d/static-web.yaml /tmp
|
mv /etc/kubelet.d/static-web.yaml /tmp
|
||||||
sleep 20
|
sleep 20
|
||||||
@@ -236,5 +204,3 @@ docker ps
|
|||||||
CONTAINER ID IMAGE COMMAND CREATED ...
|
CONTAINER ID IMAGE COMMAND CREATED ...
|
||||||
e7a62e3427f1 nginx:latest "nginx -g 'daemon of 27 seconds ago
|
e7a62e3427f1 nginx:latest "nginx -g 'daemon of 27 seconds ago
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user