Skip to content

Commit 35356d0

Browse files
Kei-Tat-inu
andauthored
[ja] Translate content/en/docs/concepts/services-networking/cluster-ip-allocation.md into Japanese (#47605)
* [ja] Translate content/en/docs/concepts/services-networking/cluster-ip-allocation.md into Japanese * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> * Update content/ja/docs/concepts/services-networking/cluster-ip-allocation.md Co-authored-by: inukai <[email protected]> --------- Co-authored-by: inukai <[email protected]>
1 parent 6e0f940 commit 35356d0

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
title: ServiceのClusterIPの割り当て
3+
content_type: concept
4+
weight: 120
5+
---
6+
7+
8+
<!-- overview -->
9+
10+
Kubernetesでは、[Service](/ja/docs/concepts/services-networking/service/)はPodの集合上で実行しているアプリケーションを抽象的に公開する方法です。Serviceはクラスター内で仮想IPアドレス(type: ClusterIPのServiceを使用)を持つことができます。クライアントはその仮想IPアドレスを使用してServiceに接続することができます。そしてKubernetesは、そのServiceへのトラフィックを異なる背後のPod間で負荷分散します。
11+
12+
<!-- body -->
13+
14+
## どのようにServiceのClusterIPが割り当てられるのか?
15+
16+
KubernetesがServiceに仮想IPアドレスを割り当てる必要がある場合、2つの方法の内どちらかの方法で行われます:
17+
18+
_動的割り当て_
19+
: クラスターのコントロールプレーンは自動的に`type: ClusterIP`のServiceのために設定されたIP範囲の中から未割り当てのIPアドレスを選びます。
20+
21+
_静的割り当て_
22+
: Serviceのために設定されたIP範囲の中から自身でIPアドレスを選びます。
23+
24+
クラスター全体を通して、Serviceの`ClusterIP`はユニークでなければいけません。割り当て済みの`ClusterIP`を使用してServiceを作成しようとするとエラーが返ってきます。
25+
26+
## なぜServiceのClusterIPを予約する必要があるのか?
27+
28+
時には、クラスター内の他のコンポーネントやユーザーが利用できるように、Serviceをよく知られたIPアドレスで実行したい場合があります。
29+
30+
その最たる例がクラスターのDNS Serviceです。慣習として、一部のKubernetesインストーラーはServiceのIP範囲の10番目のIPアドレスをDNS Serviceに割り当てます。ServiceのIP範囲を10.96.0.0/16とするクラスターを構成し、DNS ServiceのIPを10.96.0.10にするとします。この場合、下記のようなServiceを作成する必要があります。
31+
32+
```yaml
33+
apiVersion: v1
34+
kind: Service
35+
metadata:
36+
labels:
37+
k8s-app: kube-dns
38+
kubernetes.io/cluster-service: "true"
39+
kubernetes.io/name: CoreDNS
40+
name: kube-dns
41+
namespace: kube-system
42+
spec:
43+
clusterIP: 10.96.0.10
44+
ports:
45+
- name: dns
46+
port: 53
47+
protocol: UDP
48+
targetPort: 53
49+
- name: dns-tcp
50+
port: 53
51+
protocol: TCP
52+
targetPort: 53
53+
selector:
54+
k8s-app: kube-dns
55+
type: ClusterIP
56+
```
57+
58+
しかし、前述したように10.96.0.10のIPアドレスは予約されていません。他のServiceが動的割り当てよりも前に、または同時に作成された場合、このIPアドレスがそのServiceに割り当てられる可能性があります。その場合、競合エラーで失敗しDNS Serviceを作成することができません。
59+
60+
## どのようにServiceのClusterIPの競合を回避するのか? {#avoid-ClusterIP-conflict}
61+
62+
Kubernetesで実装されているServiceへのClusterIPの割り当て戦略は、衝突リスクを軽減します。
63+
64+
`ClusterIP`の範囲は、`min(max(16, cidrSize / 16), 256)`という式に基づいて分割されます。_最小で16、最大でも256で、その範囲内で段階的に変化する_ ように表されます。
65+
66+
動的IP割り当てはデフォルトで上位の帯域を使用し、それが使い切られると下位の範囲を使用します。これにより、ユーザーは下位の帯域を使用して静的な割り当てを行うことができ、衝突のリスクを抑えることができます。
67+
68+
69+
## 例 {#allocation-examples}
70+
71+
### 例1 {#allocation-example-1}
72+
73+
この例ではServiceのIPアドレスとして、10.96.0.0/24(CIDR表記法)のIPアドレスの範囲を使用します。
74+
75+
範囲の大きさ: 2<sup>8</sup> - 2 = 254
76+
帯域のオフセット(開始位置): `min(max(16, 256/16), 256)` = `min(16, 256)` = 16
77+
静的割り当ての帯域の開始: 10.96.0.1
78+
静的割り当ての帯域の終了: 10.96.0.16
79+
範囲の終了: 10.96.0.254
80+
81+
{{< mermaid >}}
82+
pie showData
83+
title 10.96.0.0/24
84+
"静的割り当て" : 16
85+
"動的割り当て" : 238
86+
{{< /mermaid >}}
87+
88+
### 例2 {#allocation-example-2}
89+
90+
この例では、ServiceのIPアドレスとして、10.96.0.0/20(CIDR表記法)のIPアドレスの範囲を使用します。
91+
92+
範囲の大きさ: 2<sup>12</sup> - 2 = 4094
93+
帯域のオフセット(開始位置): `min(max(16, 4096/16), 256)` = `min(256, 256)` = 256
94+
静的割り当ての帯域の開始: 10.96.0.1
95+
静的割り当ての帯域の終了: 10.96.1.0
96+
範囲の終了: 10.96.15.254
97+
98+
{{< mermaid >}}
99+
pie showData
100+
title 10.96.0.0/20
101+
"静的割り当て" : 256
102+
"動的割り当て" : 3838
103+
{{< /mermaid >}}
104+
105+
### 例3 {#allocation-example-3}
106+
107+
この例ではServiceのIPアドレスとして、10.96.0.0/16(CIDR表記法)のIPアドレスの範囲を使用します。
108+
109+
範囲の大きさ: 2<sup>16</sup> - 2 = 65534
110+
帯域のオフセット(開始位置): `min(max(16, 65536/16), 256)` = `min(4096, 256)` = 256
111+
静的割り当ての帯域の開始: 10.96.0.1
112+
静的割り当ての帯域の終了: 10.96.1.0
113+
範囲の終了: 10.96.255.254
114+
115+
{{< mermaid >}}
116+
pie showData
117+
title 10.96.0.0/16
118+
"静的割り当て" : 256
119+
"動的割り当て" : 65278
120+
{{< /mermaid >}}
121+
122+
## {{% heading "whatsnext" %}}
123+
124+
* [Serviceの外部トラフィックのポリシー](/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip)を参照してください。
125+
* [アプリケーションをServiceに接続する](/ja/docs/tutorials/services/connect-applications-service/)を参照してください。
126+
* [Service](/ja/docs/concepts/services-networking/service/)を参照してください。

0 commit comments

Comments
 (0)