website/content/ja/docs/setup/multiple-zones.md

334 lines
15 KiB
Markdown
Raw Normal View History

First Japanese l10n work for release-1.13 (#12998) * [ja] add basic files for 1.13 (#11571) * [ja] add basic files for 1.13 * [ja] add some base files * Translate setup/independent/_index.md (#11573) * Translate content/ja/docs/home/_index.md in Japanese (#11569) * Translate content/ja/docs/setup/custom-cloud/_index.md in Japanese (#11572) * Translate content/en/docs/setup/on-premises-vm/_index.md in Japanese (#11574) * Translate content/ja/docs/setup/release/_index.md in Japanese (#11576) * ja-trans: Translate content/ja/docs/tutorials/kubernetes-basics/explore/_index.md (#11580) * Translate content/ja/docs/setup/turnkey/_index.md (#11582) * Translate content/ja/docs/tutorials/kubernetes-basics/update/_index.m… (#11579) * Translate content/ja/docs/tutorials/kubernetes-basics/update/_index.md in Japanese * Fix title * Translated Tutorials/Learn Kubenetes Basics/Deploy an App in Japanese. (#11583) * translate tutorials/kubernetes-basics/expose/_index.md (#11584) * Dev 1.13 ja.1 tutorials kubernetes basics scale (#11577) * Translate content/ja/docs/tutorials/kubernetes-basics/scale/_index.md in Japanese * Fix title * translate deprecated state description (#11578) * Fix the build doesn't pass at dev-1.13-ja.1 (#11609) * delete files not at minimum requirements to pass the build. * copy necessary file for pass build from content/en * translate content/ja/_index.html (#11585) * ja-trans: add docs/_index.md (#11721) * Remove copied docs/index.md by mistake. (#11735) * Translate stable state description (#11642) * translate stable state description * Update content/ja/docs/templates/feature-state-stable.txt Co-Authored-By: auifzysr <38824461+auifzysr@users.noreply.github.com> * apply the suggestion directly * Translate alpha state description (#11753) * [ja] add ja section (#11581) * [ja] translate case-studies (#12060) * [ja] translate case-studies * remove comment * fix /ja/docs/ content (#12062) * Translate content/ja/docs/tutorials/kubernetes-basics/create-cluster/_index.md in Japanese (#12059) * [ja] translate supported doc versions (#12068) * [ja] add ja.toml (#11595) * Remove reviewers block from front matter. (#12092) * Translate beta state description (#12023) * [ja] translate setup (#12070) * translate setup * add translation * Update _index.md * Update _index.md * 表記ゆれ * 表記ゆれ * [ja] translate what-is-kubernetes (#12065) * translate what-is-kubernetes * add more translation * finish basic translation * Update content/ja/docs/concepts/overview/what-is-kubernetes.md Co-Authored-By: d-kuro <34958495+d-kuro@users.noreply.github.com> * Update what-is-kubernetes.md * Update content/ja/docs/concepts/overview/what-is-kubernetes.md Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/concepts/overview/what-is-kubernetes.md Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/concepts/overview/what-is-kubernetes.md Co-Authored-By: inductor <kohei.ota@zozo.com> * fix new lines * fix review * Update content/ja/docs/concepts/overview/what-is-kubernetes.md Co-Authored-By: inductor <kohei.ota@zozo.com> * Update what-is-kubernetes.md * Update what-is-kubernetes.md * rephrase プラクティス to 知見 * Update content/ja/docs/concepts/overview/what-is-kubernetes.md Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/concepts/overview/what-is-kubernetes.md Co-Authored-By: inductor <kohei.ota@zozo.com> * italic * オーケストレーション * [ja] tutorials/index (#12071) * translate tutorial index * fix page link * add ja to path for kubernetes-basic because it's already in progress of translation * Update _index.md * review * remove typo * Update content/ja/docs/tutorials/_index.md Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/_index.md Co-Authored-By: inductor <kohei.ota@zozo.com> * [ja] translate cri installation (#12095) * [ja] translate cri installation * Update content/ja/docs/setup/cri.md Co-Authored-By: auifzysr <38824461+auifzysr@users.noreply.github.com> * apply comments * apply comments * [ja]translate tutorials/kubernetes-basics (#12074) * start translation * translate index * wording * wording * cluster-interactive * cluster-intro * update interactive * update some data * fix link * deploy-intro * japanize * fix path for public data * wording * start translation of expose * expose intro * けーしょん * scale-intro * update-intro * fix wrong word * fix wording * translate missing string * Update content/ja/docs/tutorials/kubernetes-basics/_index.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/_index.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/scale/scale-intro.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/expose/expose-intro.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/expose/expose-interactive.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/_index.html Co-Authored-By: inductor <kohei.ota@zozo.com> * fix wording * Update content/ja/docs/tutorials/kubernetes-basics/create-cluster/cluster-intro.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/create-cluster/cluster-intro.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/create-cluster/cluster-intro.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/scale/scale-interactive.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/expose/expose-interactive.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/explore/explore-interactive.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/deploy-app/deploy-interactive.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/create-cluster/cluster-interactive.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/deploy-app/deploy-intro.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/deploy-app/deploy-intro.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/explore/explore-intro.html Co-Authored-By: inductor <kohei.ota@zozo.com> * Update content/ja/docs/tutorials/kubernetes-basics/scale/scale-intro.html Co-Authored-By: inductor <kohei.ota@zozo.com> * lowercase for kubectl * ja-trans: tutorials/hello-minikube.md (#11648) * trns-ja: tutorials/hello-minikube.md * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update hello-minikube.md 大変、大変遅くなりました。丁寧に見ていただいて感謝です。いただいたコメントを反映しました。 * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update hello-minikube.md <修正点> ・10行目の「本チュートリアルでは」を削除 ・クラスターをクラスタに統一 * Update hello-minikube.md 10行目の実践を手を動かすに修正 * Update hello-minikube.md 10行目を「手を動かす準備はできていますか?本チュートリアルでは、Node.jsを使った簡単な"Hello World"を実行するKubernetesクラスタをビルドします。」に差し替え。 * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * Update content/ja/docs/tutorials/hello-minikube.md Co-Authored-By: lkougi <45655192+lkougi@users.noreply.github.com> * ja-trans: setup/custom-cloud/coreos/ (#12731) * ja-trans: setup/release/building-from-source/ (#12721) * translate building-from-source * improve translation * ja-trans: translate setup/certificates/ (#12722) * translate certificates.md * change translation about Paths * ja-trans: setup/custom-cloud/kubespray/ (#12733) * ja-trans: setup/node-conformance/ (#12728) * ja-trans: setup/node-conformance/ * Update content/ja/docs/setup/node-conformance.md LGTM Co-Authored-By: makocchi-git <makocchi@gmail.com> * Update content/ja/docs/setup/node-conformance.md LGTM Co-Authored-By: makocchi-git <makocchi@gmail.com> * Update content/ja/docs/setup/node-conformance.md LGTM Co-Authored-By: makocchi-git <makocchi@gmail.com> * ja-trans: setup/cluster-large/ (#12723) * ja-trans: setup/cluster-large/ * translate quota and addon * ja-trans: setup/pick-right-solution/ (#12729) * ja-trans: setup/pick-right-solution/ * revise translating solutions * ending with a noun * ja-trans: setup/custom-cloud/kops/ (#12732) * ja-trans: setup/custom-cloud/kops/ * improve translation * translate build * translate explore and add-ons * ja-trans: setup/independent/control-plane-flags/ (#12745) * ja-trans: setup/minikube/ (#12724) * ja-trans: setup/minikube/ * Update content/ja/docs/setup/minikube.md LGTM Co-Authored-By: makocchi-git <makocchi@gmail.com> * translate features and add-ons * improve translation * improve translation * fix translation style * ja-trans: setup/multiple-zones/ (#12725) * ja-trans: setup/multiple-zones/ * ja-trans: setup/multiple-zones/ (2) * ending with a noun * fix translation style * ja-trans: setup/scratch/ (#12730) * ja-trans: setup/scratch/ * revise translating connectivity * improve translation * Update content/ja/docs/setup/scratch.md LGTM Co-Authored-By: makocchi-git <makocchi@gmail.com> * Update content/ja/docs/setup/scratch.md LGTM Co-Authored-By: makocchi-git <makocchi@gmail.com> * Update content/ja/docs/setup/scratch.md LGTM Co-Authored-By: makocchi-git <makocchi@gmail.com> * Update content/ja/docs/setup/scratch.md LGTM Co-Authored-By: makocchi-git <makocchi@gmail.com> * revise translation * revert some words to English * fix translation style * fix title * ja-trans: setup/independent/create-cluster-kubeadm/ (#12750) * ja-trans: setup/independent/create-cluster-kubeadm/ * translate Instructions * fix translation style * ja-trans: setup/independent/kubelet-integration/ (#12754) * ja-trans: setup/independent/kubelet-integration/ * fix translation style * ja-trans: setup/independent/setup-ha-etcd-with-kubeadm/ (#12755) * ja-trans: setup/independent/setup-ha-etcd-with-kubeadm/ * fix translation style * ja-trans: setup/independent/troubleshooting-kubeadm/ (#12757) * ja-trans: setup/independent/troubleshooting-kubeadm/ * pod -> Pod * ja-trans: setup/on-premises-vm/cloudstack/ (#12772) * ja-trans: setup/independent/high-availability/ (#12753) * ja-trans: setup/independent/high-availability/ * fix translation style * translate Stacked and worker node * ja-trans: setup/on-premises-metal/krib/ (#12770) * ja-trans: setup/on-premises-metal/krib/ * Update content/ja/docs/setup/on-premises-metal/krib.md Co-Authored-By: makocchi-git <makocchi@gmail.com> * ja-trans: setup/on-premises-vm/ovirt/ (#12781) * ja-trans: setup/on-premises-vm/dcos/ (#12780) * ja-trans: setup/on-premises-vm/dcos/ * fix translation * Update content/ja/docs/setup/on-premises-vm/dcos.md Co-Authored-By: makocchi-git <makocchi@gmail.com> * ja-trans: setup/turnkey/alibaba-cloud/ (#12786) * ja-trans: setup/turnkey/alibaba-cloud/ * tiny fix * Update content/ja/docs/setup/turnkey/alibaba-cloud.md Co-Authored-By: makocchi-git <makocchi@gmail.com> * fix translation * ja-trans: setup/turnkey/aws/ (#12788) * ja-trans: setup/turnkey/aws/ * translate production grade * fix translation * ja-trans: setup/release/notes/ (#12791) * ja-trans: setup/independent/install-kubeadm.md (#12812) * ja-trans: setup/independent/install-kubeadm.md * ja-trans: fix internal links in setup/independent/install-kubeadm.md * ja-trans: setup/turnkey/clc/ (#12824) * ja-trans: setup/turnkey/clc/ * Update content/ja/docs/setup/turnkey/clc.md Co-Authored-By: makocchi-git <makocchi@gmail.com> * Update content/ja/docs/setup/turnkey/clc.md Co-Authored-By: makocchi-git <makocchi@gmail.com> * ja-trans: setup/turnkey/stackpoint/ (#12853) * ja-trans: concepts/ (#12820) * ja-trans: concepts/ * fix translation * ja: fix formatting in what is kubernetes (#12694) * fix formatting in what is kubernetes * Update content/ja/docs/concepts/overview/what-is-kubernetes.md Co-Authored-By: inductor <kohei.ota@zozo.com> * ? * format (#12866) * ja-trans: setup/turnkey/gce.md (#12813) * ja-trans: setup/turnkey/gce.md * Update content/ja/docs/setup/turnkey/gce.md Co-Authored-By: auifzysr <38824461+auifzysr@users.noreply.github.com> * Update content/ja/docs/setup/turnkey/gce.md Co-Authored-By: auifzysr <38824461+auifzysr@users.noreply.github.com> * ja-trans: modify a word in setup/turnkey/gce.md * Translated docs/setup/turnkey/azure.md. (#12951) * Translated docs/setup/turnkey/azure.md. * Update content/ja/docs/setup/turnkey/azure.md Applied a suggestion. Co-Authored-By: dzeyelid <dzeyelid@gmail.com> * Update content/ja/docs/setup/turnkey/azure.md Applied a suggestion. Co-Authored-By: dzeyelid <dzeyelid@gmail.com> * Update content/ja/docs/setup/turnkey/azure.md Applied suggestion. Co-Authored-By: dzeyelid <dzeyelid@gmail.com> * Applied review suggestions. * Applied review suggestions. * fix language setting order.
2019-03-07 18:17:41 +00:00
---
title: 複数のゾーンで動かす
weight: 90
---
## 始めに
Kubernetes 1.2 adds support for running a single cluster in multiple failure zones
(GCE calls them simply "zones", AWS calls them "availability zones", here we'll refer to them as "zones").
This is a lightweight version of a broader Cluster Federation feature (previously referred to by the affectionate
nickname ["Ubernetes"](https://github.com/kubernetes/community/blob/{{< param "githubbranch" >}}/contributors/design-proposals/multicluster/federation.md)).
Full Cluster Federation allows combining separate
Kubernetes clusters running in different regions or cloud providers
(or on-premises data centers). However, many
users simply want to run a more available Kubernetes cluster in multiple zones
of their single cloud provider, and this is what the multizone support in 1.2 allows
(this previously went by the nickname "Ubernetes Lite").
Multizone support is deliberately limited: a single Kubernetes cluster can run
in multiple zones, but only within the same region (and cloud provider). Only
GCE and AWS are currently supported automatically (though it is easy to
add similar support for other clouds or even bare metal, by simply arranging
for the appropriate labels to be added to nodes and volumes).
{{< toc >}}
## 機能性
When nodes are started, the kubelet automatically adds labels to them with
zone information.
Kubernetes will automatically spread the pods in a replication controller
or service across nodes in a single-zone cluster (to reduce the impact of
failures.) With multiple-zone clusters, this spreading behavior is
extended across zones (to reduce the impact of zone failures.) (This is
achieved via `SelectorSpreadPriority`). This is a best-effort
placement, and so if the zones in your cluster are heterogeneous
(e.g. different numbers of nodes, different types of nodes, or
different pod resource requirements), this might prevent perfectly
even spreading of your pods across zones. If desired, you can use
homogeneous zones (same number and types of nodes) to reduce the
probability of unequal spreading.
When persistent volumes are created, the `PersistentVolumeLabel`
admission controller automatically adds zone labels to them. The scheduler (via the
`VolumeZonePredicate` predicate) will then ensure that pods that claim a
given volume are only placed into the same zone as that volume, as volumes
cannot be attached across zones.
## 制限
There are some important limitations of the multizone support:
* We assume that the different zones are located close to each other in the
network, so we don't perform any zone-aware routing. In particular, traffic
that goes via services might cross zones (even if some pods backing that service
exist in the same zone as the client), and this may incur additional latency and cost.
* Volume zone-affinity will only work with a `PersistentVolume`, and will not
work if you directly specify an EBS volume in the pod spec (for example).
* Clusters cannot span clouds or regions (this functionality will require full
federation support).
* Although your nodes are in multiple zones, kube-up currently builds
a single master node by default. While services are highly
available and can tolerate the loss of a zone, the control plane is
located in a single zone. Users that want a highly available control
plane should follow the [high availability](/docs/admin/high-availability) instructions.
### ボリュームの制限
The following limitations are addressed with [topology-aware volume binding](/docs/concepts/storage/storage-classes/#volume-binding-mode).
* StatefulSet volume zone spreading when using dynamic provisioning is currently not compatible with
pod affinity or anti-affinity policies.
* If the name of the StatefulSet contains dashes ("-"), volume zone spreading
may not provide a uniform distribution of storage across zones.
* When specifying multiple PVCs in a Deployment or Pod spec, the StorageClass
needs to be configured for a specific single zone, or the PVs need to be
statically provisioned in a specific zone. Another workaround is to use a
StatefulSet, which will ensure that all the volumes for a replica are
provisioned in the same zone.
## 全体の流れ
We're now going to walk through setting up and using a multi-zone
cluster on both GCE & AWS. To do so, you bring up a full cluster
(specifying `MULTIZONE=true`), and then you add nodes in additional zones
by running `kube-up` again (specifying `KUBE_USE_EXISTING_MASTER=true`).
### クラスターの立ち上げ
Create the cluster as normal, but pass MULTIZONE to tell the cluster to manage multiple zones; creating nodes in us-central1-a.
GCE:
```shell
curl -sS https://get.k8s.io | MULTIZONE=true KUBERNETES_PROVIDER=gce KUBE_GCE_ZONE=us-central1-a NUM_NODES=3 bash
```
AWS:
```shell
curl -sS https://get.k8s.io | MULTIZONE=true KUBERNETES_PROVIDER=aws KUBE_AWS_ZONE=us-west-2a NUM_NODES=3 bash
```
This step brings up a cluster as normal, still running in a single zone
(but `MULTIZONE=true` has enabled multi-zone capabilities).
### ノードはラベルが付与される
View the nodes; you can see that they are labeled with zone information.
They are all in `us-central1-a` (GCE) or `us-west-2a` (AWS) so far. The
labels are `failure-domain.beta.kubernetes.io/region` for the region,
and `failure-domain.beta.kubernetes.io/zone` for the zone:
```shell
> kubectl get nodes --show-labels
NAME STATUS ROLES AGE VERSION LABELS
kubernetes-master Ready,SchedulingDisabled <none> 6m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-1,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-a,kubernetes.io/hostname=kubernetes-master
kubernetes-minion-87j9 Ready <none> 6m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-a,kubernetes.io/hostname=kubernetes-minion-87j9
kubernetes-minion-9vlv Ready <none> 6m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-a,kubernetes.io/hostname=kubernetes-minion-9vlv
kubernetes-minion-a12q Ready <none> 6m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-a,kubernetes.io/hostname=kubernetes-minion-a12q
```
### 2つ目のゾーンにさらにードを追加
Let's add another set of nodes to the existing cluster, reusing the
existing master, running in a different zone (us-central1-b or us-west-2b).
We run kube-up again, but by specifying `KUBE_USE_EXISTING_MASTER=true`
kube-up will not create a new master, but will reuse one that was previously
created instead.
GCE:
```shell
KUBE_USE_EXISTING_MASTER=true MULTIZONE=true KUBERNETES_PROVIDER=gce KUBE_GCE_ZONE=us-central1-b NUM_NODES=3 kubernetes/cluster/kube-up.sh
```
On AWS we also need to specify the network CIDR for the additional
subnet, along with the master internal IP address:
```shell
KUBE_USE_EXISTING_MASTER=true MULTIZONE=true KUBERNETES_PROVIDER=aws KUBE_AWS_ZONE=us-west-2b NUM_NODES=3 KUBE_SUBNET_CIDR=172.20.1.0/24 MASTER_INTERNAL_IP=172.20.0.9 kubernetes/cluster/kube-up.sh
```
View the nodes again; 3 more nodes should have launched and be tagged
in us-central1-b:
```shell
> kubectl get nodes --show-labels
NAME STATUS ROLES AGE VERSION LABELS
kubernetes-master Ready,SchedulingDisabled <none> 16m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-1,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-a,kubernetes.io/hostname=kubernetes-master
kubernetes-minion-281d Ready <none> 2m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-b,kubernetes.io/hostname=kubernetes-minion-281d
kubernetes-minion-87j9 Ready <none> 16m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-a,kubernetes.io/hostname=kubernetes-minion-87j9
kubernetes-minion-9vlv Ready <none> 16m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-a,kubernetes.io/hostname=kubernetes-minion-9vlv
kubernetes-minion-a12q Ready <none> 17m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-a,kubernetes.io/hostname=kubernetes-minion-a12q
kubernetes-minion-pp2f Ready <none> 2m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-b,kubernetes.io/hostname=kubernetes-minion-pp2f
kubernetes-minion-wf8i Ready <none> 2m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-b,kubernetes.io/hostname=kubernetes-minion-wf8i
```
### ボリュームのアフィニティ
Create a volume using the dynamic volume creation (only PersistentVolumes are supported for zone affinity):
```json
kubectl create -f - <<EOF
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "claim1",
"annotations": {
"volume.alpha.kubernetes.io/storage-class": "foo"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "5Gi"
}
}
}
}
EOF
```
{{< note >}}
For version 1.3+ Kubernetes will distribute dynamic PV claims across
the configured zones. For version 1.2, dynamic persistent volumes were
always created in the zone of the cluster master
(here us-central1-a / us-west-2a); that issue
([#23330](https://github.com/kubernetes/kubernetes/issues/23330))
was addressed in 1.3+.
{{< /note >}}
Now lets validate that Kubernetes automatically labeled the zone & region the PV was created in.
```shell
> kubectl get pv --show-labels
NAME CAPACITY ACCESSMODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE LABELS
pv-gce-mj4gm 5Gi RWO Retain Bound default/claim1 manual 46s failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-a
```
So now we will create a pod that uses the persistent volume claim.
Because GCE PDs / AWS EBS volumes cannot be attached across zones,
this means that this pod can only be created in the same zone as the volume:
```yaml
kubectl create -f - <<EOF
kind: Pod
apiVersion: v1
metadata:
name: mypod
spec:
containers:
- name: myfrontend
image: nginx
volumeMounts:
- mountPath: "/var/www/html"
name: mypd
volumes:
- name: mypd
persistentVolumeClaim:
claimName: claim1
EOF
```
Note that the pod was automatically created in the same zone as the volume, as
cross-zone attachments are not generally permitted by cloud providers:
```shell
> kubectl describe pod mypod | grep Node
Node: kubernetes-minion-9vlv/10.240.0.5
> kubectl get node kubernetes-minion-9vlv --show-labels
NAME STATUS AGE VERSION LABELS
kubernetes-minion-9vlv Ready 22m v1.6.0+fff5156 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-a,kubernetes.io/hostname=kubernetes-minion-9vlv
```
### Podがゾーンをまたがって配置される
Pods in a replication controller or service are automatically spread
across zones. First, let's launch more nodes in a third zone:
GCE:
```shell
KUBE_USE_EXISTING_MASTER=true MULTIZONE=true KUBERNETES_PROVIDER=gce KUBE_GCE_ZONE=us-central1-f NUM_NODES=3 kubernetes/cluster/kube-up.sh
```
AWS:
```shell
KUBE_USE_EXISTING_MASTER=true MULTIZONE=true KUBERNETES_PROVIDER=aws KUBE_AWS_ZONE=us-west-2c NUM_NODES=3 KUBE_SUBNET_CIDR=172.20.2.0/24 MASTER_INTERNAL_IP=172.20.0.9 kubernetes/cluster/kube-up.sh
```
Verify that you now have nodes in 3 zones:
```shell
kubectl get nodes --show-labels
```
Create the guestbook-go example, which includes an RC of size 3, running a simple web app:
```shell
find kubernetes/examples/guestbook-go/ -name '*.json' | xargs -I {} kubectl create -f {}
```
The pods should be spread across all 3 zones:
```shell
> kubectl describe pod -l app=guestbook | grep Node
Node: kubernetes-minion-9vlv/10.240.0.5
Node: kubernetes-minion-281d/10.240.0.8
Node: kubernetes-minion-olsh/10.240.0.11
> kubectl get node kubernetes-minion-9vlv kubernetes-minion-281d kubernetes-minion-olsh --show-labels
NAME STATUS ROLES AGE VERSION LABELS
kubernetes-minion-9vlv Ready <none> 34m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-a,kubernetes.io/hostname=kubernetes-minion-9vlv
kubernetes-minion-281d Ready <none> 20m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-b,kubernetes.io/hostname=kubernetes-minion-281d
kubernetes-minion-olsh Ready <none> 3m v1.12.0 beta.kubernetes.io/instance-type=n1-standard-2,failure-domain.beta.kubernetes.io/region=us-central1,failure-domain.beta.kubernetes.io/zone=us-central1-f,kubernetes.io/hostname=kubernetes-minion-olsh
```
Load-balancers span all zones in a cluster; the guestbook-go example
includes an example load-balanced service:
```shell
> kubectl describe service guestbook | grep LoadBalancer.Ingress
LoadBalancer Ingress: 130.211.126.21
> ip=130.211.126.21
> curl -s http://${ip}:3000/env | grep HOSTNAME
"HOSTNAME": "guestbook-44sep",
> (for i in `seq 20`; do curl -s http://${ip}:3000/env | grep HOSTNAME; done) | sort | uniq
"HOSTNAME": "guestbook-44sep",
"HOSTNAME": "guestbook-hum5n",
"HOSTNAME": "guestbook-ppm40",
```
The load balancer correctly targets all the pods, even though they are in multiple zones.
### クラスターの停止
When you're done, clean up:
GCE:
```shell
KUBERNETES_PROVIDER=gce KUBE_USE_EXISTING_MASTER=true KUBE_GCE_ZONE=us-central1-f kubernetes/cluster/kube-down.sh
KUBERNETES_PROVIDER=gce KUBE_USE_EXISTING_MASTER=true KUBE_GCE_ZONE=us-central1-b kubernetes/cluster/kube-down.sh
KUBERNETES_PROVIDER=gce KUBE_GCE_ZONE=us-central1-a kubernetes/cluster/kube-down.sh
```
AWS:
```shell
KUBERNETES_PROVIDER=aws KUBE_USE_EXISTING_MASTER=true KUBE_AWS_ZONE=us-west-2c kubernetes/cluster/kube-down.sh
KUBERNETES_PROVIDER=aws KUBE_USE_EXISTING_MASTER=true KUBE_AWS_ZONE=us-west-2b kubernetes/cluster/kube-down.sh
KUBERNETES_PROVIDER=aws KUBE_AWS_ZONE=us-west-2a kubernetes/cluster/kube-down.sh
```