Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate docs/tutorials/stateless-application/expose-external-ip-address.md in Japanese #15672

Merged
merged 13 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions content/ja/docs/tutorials/stateless-application/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: "ステートレスアプリケーション"
weight: 40
---

Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
title: クラスター内のアプリケーションにアクセスするために外部IPアドレスを公開する
content_template: templates/tutorial
weight: 10
---

{{% capture overview %}}

このページでは、外部IPアドレスを公開するKubernetesのServiceオブジェクトを作成する方法を示します。

{{% /capture %}}


{{% capture prerequisites %}}

* [kubectl](/docs/tasks/tools/install-kubectl/)をインストールしてください。

* Kubernetesクラスターを作成する際に、Google Kubernetes EngineやAmazon Web Servicesのようなクラウドプロバイダーを使用します。このチュートリアルでは、クラウドプロバイダーを必要とする[外部ロードバランサー](/docs/tasks/access-application-cluster/create-external-load-balancer/)を作成します。

* Kubernetes APIサーバーと通信するために、`kubectl`を設定してください。手順については、各クラウドプロバイダーのドキュメントを参照してください。

{{% /capture %}}


{{% capture objectives %}}

* 5つのインスタンスで実際のアプリケーションを起動します。
* 外部IPアドレスを公開するServiceオブジェクトを作成します。
* 起動中のアプリケーションにアクセスするためにServiceオブジェクトを使用します。

{{% /capture %}}


{{% capture lessoncontent %}}

## 5つのPodで起動しているアプリケーションへのServiceの作成

1. クラスターにてHello Worldアプリケーションを実行してください。

{{< codenew file="service/load-balancer-example.yaml" >}}

```shell
kubectl apply -f https://k8s.io/examples/service/load-balancer-example.yaml
```


上記のコマンドにより、[Deployment](/docs/concepts/workloads/controllers/deployment/)オブジェクトを作成し、[ReplicaSet](/docs/concepts/workloads/controllers/replicaset/)オブジェクトを関連づけます。ReplicaSetには5つの[Pod](/docs/concepts/workloads/pods/pod/)があり、それぞれHello Worldアプリケーションが起動しています。

1. Deploymentに関する情報を表示します:

kubectl get deployments hello-world
kubectl describe deployments hello-world

1. ReplicaSetオブジェクトに関する情報を表示します:

kubectl get replicasets
kubectl describe replicasets

1. Deploymentを公開するServiceオブジェクトを作成します。

kubectl expose deployment hello-world --type=LoadBalancer --name=my-service

1. Serviceに関する情報を表示します:

kubectl get services my-service

出力は次のようになります:

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-service LoadBalancer 10.3.245.137 104.198.205.71 8080/TCP 54s

注意: 外部IPアドレスが\<pending\>と表示されている場合は、しばらく待ってから同じコマンドを実行してください。

1. Serviceに関する詳細な情報を表示します:

kubectl describe services my-service

出力は次のようになります:

Name: my-service
Namespace: default
Labels: app.kubernetes.io/name=load-balancer-example
Annotations: <none>
Selector: app.kubernetes.io/name=load-balancer-example
Type: LoadBalancer
IP: 10.3.245.137
LoadBalancer Ingress: 104.198.205.71
Port: <unset> 8080/TCP
NodePort: <unset> 32377/TCP
Endpoints: 10.0.0.6:8080,10.0.1.6:8080,10.0.1.7:8080 + 2 more...
Session Affinity: None
Events: <none>

Serviceによって公開された外部IPアドレス(`LoadBalancer Ingress`)を記録しておいてください。
この例では、外部IPアドレスは104.198.205.71です。
また、`Port`および`NodePort`の値も控えてください。
この例では、`Port`は8080、`NodePort`は32377です。

1. 先ほどの出力にて、Serviceにはいくつかのエンドポイントがあることを確認できます: 10.0.0.6:8080、
10.0.1.6:8080、10.0.1.7:8080、その他2つです。
これらはHello Worldアプリケーションが動作しているPodの内部IPアドレスです。
これらのPodのアドレスを確認するには、次のコマンドを実行します:

kubectl get pods --output=wide

出力は次のようになります:

NAME ... IP NODE
hello-world-2895499144-1jaz9 ... 10.0.1.6 gke-cluster-1-default-pool-e0b8d269-1afc
hello-world-2895499144-2e5uh ... 10.0.1.8 gke-cluster-1-default-pool-e0b8d269-1afc
hello-world-2895499144-9m4h1 ... 10.0.0.6 gke-cluster-1-default-pool-e0b8d269-5v7a
hello-world-2895499144-o4z13 ... 10.0.1.7 gke-cluster-1-default-pool-e0b8d269-1afc
hello-world-2895499144-segjf ... 10.0.2.5 gke-cluster-1-default-pool-e0b8d269-cpuc

1. Hello Worldアプリケーションにアクセスするために、外部IPアドレス(`LoadBalancer Ingress`)を使用します:

curl http://<external-ip>:<port>

ここで、`<external-ip>`はServiceの外部IPアドレス(`LoadBalancer Ingress`)で、
`<port>`はServiceの詳細出力における`Port`です。minikubeを使用している場合、`minikube service my-service`を実行することでHello Worldアプリケーションをブラウザで自動的に
開かれます。

正常なリクエストに対するレスポンスは、helloメッセージです:

Hello Kubernetes!

{{% /capture %}}


{{% capture cleanup %}}

Serviceを削除する場合、次のコマンドを実行します:

kubectl delete services my-service

Deployment、ReplicaSet、およびHello Worldアプリケーションが動作しているPodを削除する場合、次のコマンドを実行します:

kubectl delete deployment hello-world

{{% /capture %}}


{{% capture whatsnext %}}

[connecting applications with services](/docs/concepts/services-networking/connect-applications-service/)にて詳細を学ぶことができます。
{{% /capture %}}
21 changes: 21 additions & 0 deletions content/ja/examples/service/load-balancer-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: load-balancer-example
name: hello-world
spec:
replicas: 5
selector:
matchLabels:
app.kubernetes.io/name: load-balancer-example
template:
metadata:
labels:
app.kubernetes.io/name: load-balancer-example
spec:
containers:
- image: gcr.io/google-samples/node-hello:1.0
name: hello-world
ports:
- containerPort: 8080