Merge pull request #21468 from hiyokotaisa/fix-21464

ja: Make docs/concepts/workloads/controllers/replicaset.md follow v1.17 of the original text
This commit is contained in:
Kubernetes Prow Robot
2020-06-04 01:00:44 -07:00
committed by GitHub
@@ -20,7 +20,7 @@ ReplicaSetは、ReplicaSetが対象とするPodをどう特定するかを示す
ReplicaSetがそのPod群と連携するためのリンクは、Podの[metadata.ownerReferences](/ja/docs/concepts/workloads/controllers/garbage-collection/#owners-and-dependents)というフィールド(現在のオブジェクトが所有されているリソースを指定する)を介して作成されます。ReplicaSetによって所持された全てのPodは、それらの`ownerReferences`フィールドにReplicaSetを特定する情報を保持します。このリンクを通じて、ReplicaSetは管理しているPodの状態を把握したり、その後の実行計画を立てます。 ReplicaSetがそのPod群と連携するためのリンクは、Podの[metadata.ownerReferences](/ja/docs/concepts/workloads/controllers/garbage-collection/#owners-and-dependents)というフィールド(現在のオブジェクトが所有されているリソースを指定する)を介して作成されます。ReplicaSetによって所持された全てのPodは、それらの`ownerReferences`フィールドにReplicaSetを特定する情報を保持します。このリンクを通じて、ReplicaSetは管理しているPodの状態を把握したり、その後の実行計画を立てます。
ReplicaSetは、そのセレクターを使用することにより、所有するための新しいPodを特定します。もし`ownerReference`フィールドの値を持たないPodか、`ownerReference`フィールドの値がコントローラーでないPodで、そのPodがReplicaSetのセレクターとマッチした場合に、そのPodは即座にそのReplicaSetによって所有されます。 ReplicaSetは、そのセレクターを使用することにより、所有するための新しいPodを特定します。もし`ownerReference`フィールドの値を持たないPodか、`ownerReference`フィールドの値が {{< glossary_tooltip text="コントローラー" term_id="controller" >}}でないPodで、そのPodがReplicaSetのセレクターとマッチした場合に、そのPodは即座にそのReplicaSetによって所有されます。
## ReplicaSetを使うとき ## ReplicaSetを使うとき
@@ -59,51 +59,48 @@ kubectl describe rs/frontend
```shell ```shell
Name: frontend Name: frontend
Namespace: default Namespace: default
Selector: tier=frontend,tier in (frontend) Selector: tier=frontend
Labels: app=guestbook Labels: app=guestbook
tier=frontend tier=frontend
Annotations: <none> Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"apps/v1","kind":"ReplicaSet","metadata":{"annotations":{},"labels":{"app":"guestbook","tier":"frontend"},"name":"frontend",...
Replicas: 3 current / 3 desired Replicas: 3 current / 3 desired
Pods Status: 3 Running / 0 Waiting / 0 Succeeded / 0 Failed Pods Status: 3 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template: Pod Template:
Labels: app=guestbook Labels: tier=frontend
tier=frontend
Containers: Containers:
php-redis: php-redis:
Image: gcr.io/google_samples/gb-frontend:v3 Image: gcr.io/google_samples/gb-frontend:v3
Port: 80/TCP Port: <none>
Requests: Host Port: <none>
cpu: 100m Environment: <none>
memory: 100Mi Mounts: <none>
Environment: Volumes: <none>
GET_HOSTS_FROM: dns
Mounts: <none>
Volumes: <none>
Events: Events:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message Type Reason Age From Message
--------- -------- ----- ---- ------------- -------- ------ ------- ---- ------ ---- ---- -------
1m 1m 1 {replicaset-controller } Normal SuccessfulCreate Created pod: frontend-qhloh Normal SuccessfulCreate 117s replicaset-controller Created pod: frontend-wtsmm
1m 1m 1 {replicaset-controller } Normal SuccessfulCreate Created pod: frontend-dnjpy Normal SuccessfulCreate 116s replicaset-controller Created pod: frontend-b2zdv
1m 1m 1 {replicaset-controller } Normal SuccessfulCreate Created pod: frontend-9si5l Normal SuccessfulCreate 116s replicaset-controller Created pod: frontend-vcmts
``` ```
そして最後に、ユーザーはReplicaSetによって作成されたPodもチェックできます。 そして最後に、ユーザーはReplicaSetによって作成されたPodもチェックできます。
```shell ```shell
kubectl get Pods kubectl get pods
``` ```
表示されるPodに関する情報は以下のようになります。 表示されるPodに関する情報は以下のようになります。
```shell ```shell
NAME READY STATUS RESTARTS AGE NAME READY STATUS RESTARTS AGE
frontend-9si5l 1/1 Running 0 1m frontend-b2zdv 1/1 Running 0 6m36s
frontend-dnjpy 1/1 Running 0 1m frontend-vcmts 1/1 Running 0 6m36s
frontend-qhloh 1/1 Running 0 1m frontend-wtsmm 1/1 Running 0 6m36s
``` ```
ユーザーはまた、それらのPodの`ownerReferences``frontend`ReplicaSetに設定されていることも確認できます。 ユーザーはまた、それらのPodの`ownerReferences``frontend`ReplicaSetに設定されていることも確認できます。
これを確認するためには、稼働しているPodの中のどれかのyamlファイルを取得します。 これを確認するためには、稼働しているPodの中のどれかのyamlファイルを取得します。
```shell ```shell
kubectl get pods frontend-9si5l -o yaml kubectl get pods frontend-b2zdv -o yaml
``` ```
その表示結果は、以下のようになります。その`frontend`ReplicaSetの情報が`metadata``ownerReferences`フィールドにセットされています。 その表示結果は、以下のようになります。その`frontend`ReplicaSetの情報が`metadata``ownerReferences`フィールドにセットされています。
@@ -111,19 +108,19 @@ kubectl get pods frontend-9si5l -o yaml
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
creationTimestamp: 2019-01-31T17:20:41Z creationTimestamp: "2020-02-12T07:06:16Z"
generateName: frontend- generateName: frontend-
labels: labels:
tier: frontend tier: frontend
name: frontend-9si5l name: frontend-b2zdv
namespace: default namespace: default
ownerReferences: ownerReferences:
- apiVersion: extensions/v1beta1 - apiVersion: apps/v1
blockOwnerDeletion: true blockOwnerDeletion: true
controller: true controller: true
kind: ReplicaSet kind: ReplicaSet
name: frontend name: frontend
uid: 892a2330-257c-11e9-aecd-025000000001 uid: f391f6db-bb9b-4c09-ae74-6a1f77f3d5cf
... ...
``` ```
@@ -148,16 +145,17 @@ kubectl apply -f http://k8s.io/examples/pods/pod-rs.yaml
下記のコマンドでPodを取得できます。 下記のコマンドでPodを取得できます。
```shell ```shell
kubectl get Pods kubectl get pods
``` ```
その表示結果で、新しいPodがすでに削除済みか、削除中のステータスになっているのを確認できます。 その表示結果で、新しいPodがすでに削除済みか、削除中のステータスになっているのを確認できます。
```shell ```shell
NAME READY STATUS RESTARTS AGE NAME READY STATUS RESTARTS AGE
frontend-9si5l 1/1 Running 0 1m frontend-b2zdv 1/1 Running 0 10m
frontend-dnjpy 1/1 Running 0 1m frontend-vcmts 1/1 Running 0 10m
frontend-qhloh 1/1 Running 0 1m frontend-wtsmm 1/1 Running 0 10m
pod2 0/1 Terminating 0 4s pod1 0/1 Terminating 0 1s
pod2 0/1 Terminating 0 1s
``` ```
もしユーザーがそのPodを最初に作成する場合 もしユーザーがそのPodを最初に作成する場合
@@ -173,15 +171,15 @@ kubectl apply -f http://k8s.io/examples/controllers/frontend.yaml
ユーザーはそのReplicaSetが作成したPodを所有し、さらにもともと存在していたPodと今回新たに作成されたPodの数が、理想のレプリカ数になるまでPodを作成するのを確認できます。 ユーザーはそのReplicaSetが作成したPodを所有し、さらにもともと存在していたPodと今回新たに作成されたPodの数が、理想のレプリカ数になるまでPodを作成するのを確認できます。
ここでまたPodの状態を取得します。 ここでまたPodの状態を取得します。
```shell ```shell
kubectl get Pods kubectl get pods
``` ```
取得結果は下記のようになります。 取得結果は下記のようになります。
```shell ```shell
NAME READY STATUS RESTARTS AGE NAME READY STATUS RESTARTS AGE
frontend-pxj4r 1/1 Running 0 5s frontend-hmmj2 1/1 Running 0 9s
pod1 1/1 Running 0 13s pod1 1/1 Running 0 36s
pod2 1/1 Running 0 13s pod2 1/1 Running 0 36s
``` ```
この方法で、ReplicaSetはテンプレートで指定されたもの以外のPodを所有することができます。 この方法で、ReplicaSetはテンプレートで指定されたもの以外のPodを所有することができます。
@@ -192,6 +190,9 @@ pod2 1/1 Running 0 13s
ReplicaSetでは、`kind`フィールドの値は`ReplicaSet`です。 ReplicaSetでは、`kind`フィールドの値は`ReplicaSet`です。
Kubernetes1.9において、ReplicaSetは`apps/v1`というAPIバージョンが現在のバージョンで、デフォルトで有効です。`apps/v1beta2`というAPIバージョンは廃止されています。先ほど作成した`frontend.yaml`ファイルの最初の行を参考にしてください。 Kubernetes1.9において、ReplicaSetは`apps/v1`というAPIバージョンが現在のバージョンで、デフォルトで有効です。`apps/v1beta2`というAPIバージョンは廃止されています。先ほど作成した`frontend.yaml`ファイルの最初の行を参考にしてください。
ReplicaSetオブジェクトの名前は、有効な
[DNSサブドメイン名](/ja/docs/concepts/overview/working-with-objects/names#dns-subdomain-names)である必要があります。
また、ReplicaSetは[`.spec` セクション](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status)も必須です。 また、ReplicaSetは[`.spec` セクション](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status)も必須です。
### Pod テンプレート ### Pod テンプレート
@@ -234,7 +235,7 @@ REST APIもしくは`client-go`ライブラリーを使用するとき、ユー
例えば下記のように実行します。 例えば下記のように実行します。
```shell ```shell
kubectl proxy --port=8080 kubectl proxy --port=8080
curl -X DELETE 'localhost:8080/apis/extensions/v1beta1/namespaces/default/replicasets/frontend' \ curl -X DELETE 'localhost:8080/apis/apps/v1/namespaces/default/replicasets/frontend' \
> -d '{"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Foreground"}' \ > -d '{"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Foreground"}' \
> -H "Content-Type: application/json" > -H "Content-Type: application/json"
``` ```
@@ -245,7 +246,7 @@ curl -X DELETE 'localhost:8080/apis/extensions/v1beta1/namespaces/default/repli
REST APIもしくは`client-go`ライブラリーを使用するとき、ユーザーは`-d`オプションで`propagationPolicy``Orphan`と指定しなくてはなりません。 REST APIもしくは`client-go`ライブラリーを使用するとき、ユーザーは`-d`オプションで`propagationPolicy``Orphan`と指定しなくてはなりません。
```shell ```shell
kubectl proxy --port=8080 kubectl proxy --port=8080
curl -X DELETE 'localhost:8080/apis/extensions/v1beta1/namespaces/default/replicasets/frontend' \ curl -X DELETE 'localhost:8080/apis/apps/v1/namespaces/default/replicasets/frontend' \
> -d '{"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Orphan"}' \ > -d '{"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Orphan"}' \
> -H "Content-Type: application/json" > -H "Content-Type: application/json"
``` ```