Skip to content

Commit 71a20e6

Browse files
authored
Merge pull request #27712 from shuuji3/shuuji3/translate-tasks-network-27706
Translate tasks/network/validate-dual-stack/ into Japanese
2 parents 498ad04 + 66d8561 commit 71a20e6

File tree

7 files changed

+299
-1
lines changed

7 files changed

+299
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: "ネットワーク"
3+
description: クラスターのネットワークの設定方法を学びます。
4+
weight: 160
5+
---
6+
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
---
2+
min-kubernetes-server-version: v1.20
3+
title: IPv4/IPv6デュアルスタックの検証
4+
content_type: task
5+
---
6+
7+
<!-- overview -->
8+
このドキュメントでは、IPv4/IPv6デュアルスタックが有効化されたKubernetesクラスターを検証する方法について共有します。
9+
10+
11+
## {{% heading "prerequisites" %}}
12+
13+
14+
* プロバイダーがデュアルスタックのネットワークをサポートしていること (クラウドプロバイダーか、ルーティングできるIPv4/IPv6ネットワークインターフェイスを持つKubernetesノードが提供できること)
15+
* (KubenetやCalicoなど)デュアルスタックをサポートする[ネットワークプラグイン](/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/)
16+
* [デュアルスタックを有効化](/ja/docs/concepts/services-networking/dual-stack/)したクラスター
17+
18+
{{< version-check >}}
19+
20+
21+
22+
<!-- steps -->
23+
24+
## アドレスの検証
25+
26+
### ノードアドレスの検証
27+
28+
各デュアルスタックのノードは、1つのIPv4ブロックと1つのIPv6ブロックを割り当てる必要があります。IPv4/IPv6のPodアドレスの範囲が設定されていることを検証するには、次のコマンドを実行します。例の中のノード名は、自分のクラスターの有効なデュアルスタックのノードの名前に置換してください。この例では、ノードの名前は`k8s-linuxpool1-34450317-0`になっています。
29+
30+
```shell
31+
kubectl get nodes k8s-linuxpool1-34450317-0 -o go-template --template='{{range .spec.podCIDRs}}{{printf "%s\n" .}}{{end}}'
32+
```
33+
```
34+
10.244.1.0/24
35+
a00:100::/24
36+
```
37+
38+
IPv4ブロックとIPv6ブロックがそれぞれ1つずつ割り当てられているはずです。
39+
40+
ノードが検出されたIPv4とIPv6のインターフェイスを持っていることを検証します。ノード名は自分のクラスター内の有効なノード名に置換してください。この例では、ノード名は`k8s-linuxpool1-34450317-0`になっています。
41+
42+
```shell
43+
kubectl get nodes k8s-linuxpool1-34450317-0 -o go-template --template='{{range .status.addresses}}{{printf "%s: %s\n" .type .address}}{{end}}'
44+
```
45+
```
46+
Hostname: k8s-linuxpool1-34450317-0
47+
InternalIP: 10.240.0.5
48+
InternalIP: 2001:1234:5678:9abc::5
49+
```
50+
51+
### Podアドレスの検証
52+
53+
PodにIPv4とIPv6のアドレスが割り当てられていることを検証します。Podの名前は自分のクラスター内の有効なPodの名前と置換してください。この例では、Podの名前は`pod01`になっています。
54+
55+
```shell
56+
kubectl get pods pod01 -o go-template --template='{{range .status.podIPs}}{{printf "%s\n" .ip}}{{end}}'
57+
```
58+
```
59+
10.244.1.4
60+
a00:100::4
61+
```
62+
63+
Downward APIを使用して、`status.podIPs`のfieldPath経由でPod IPを検証することもできます。次のスニペットは、Pod IPを`MY_POD_IPS`という名前の環境変数経由でコンテナ内に公開する方法を示しています。
64+
65+
```
66+
env:
67+
- name: MY_POD_IPS
68+
valueFrom:
69+
fieldRef:
70+
fieldPath: status.podIPs
71+
```
72+
73+
次のコマンドを実行すると、`MY_POD_IPS`環境変数の値をコンテナ内から表示できます。値はカンマ区切りのリストであり、PodのIPv4とIPv6のアドレスに対応しています。
74+
75+
```shell
76+
kubectl exec -it pod01 -- set | grep MY_POD_IPS
77+
```
78+
```
79+
MY_POD_IPS=10.244.1.4,a00:100::4
80+
```
81+
82+
PodのIPアドレスは、コンテナ内の`/etc/hosts`にも書き込まれます。次のコマンドは、デュアルスタックのPod上で`/etc/hosts`に対してcatコマンドを実行します。出力を見ると、Pod用のIPv4およびIPv6のIPアドレスの両方が確認できます。
83+
84+
```shell
85+
kubectl exec -it pod01 -- cat /etc/hosts
86+
```
87+
```
88+
# Kubernetes-managed hosts file.
89+
127.0.0.1 localhost
90+
::1 localhost ip6-localhost ip6-loopback
91+
fe00::0 ip6-localnet
92+
fe00::0 ip6-mcastprefix
93+
fe00::1 ip6-allnodes
94+
fe00::2 ip6-allrouters
95+
10.244.1.4 pod01
96+
a00:100::4 pod01
97+
```
98+
99+
## Serviceの検証
100+
101+
`.spec.isFamilyPolicy`を明示的に定義していない、以下のようなServiceを作成してみます。Kubernetesは最初に設定した`service-cluster-ip-range`の範囲からServiceにcluster IPを割り当てて、`.spec.ipFamilyPolicy``SingleStack`に設定します。
102+
103+
{{< codenew file="service/networking/dual-stack-default-svc.yaml" >}}
104+
105+
`kubectl`を使ってServiceのYAMLを表示します。
106+
107+
```shell
108+
kubectl get svc my-service -o yaml
109+
```
110+
111+
Serviceの`.spec.ipFamilyPolicy``SingleStack`に設定され、`.spec.clusterIP`にはkube-controller-manager上の`--service-cluster-ip-range`フラグで最初に設定した範囲から1つのIPv4アドレスが設定されているのがわかります。
112+
113+
```yaml
114+
apiVersion: v1
115+
kind: Service
116+
metadata:
117+
name: my-service
118+
namespace: default
119+
spec:
120+
clusterIP: 10.0.217.164
121+
clusterIPs:
122+
- 10.0.217.164
123+
ipFamilies:
124+
- IPv4
125+
ipFamilyPolicy: SingleStack
126+
ports:
127+
- port: 80
128+
protocol: TCP
129+
targetPort: 9376
130+
selector:
131+
app: MyApp
132+
sessionAffinity: None
133+
type: ClusterIP
134+
status:
135+
loadBalancer: {}
136+
```
137+
138+
`.spec.ipFamilies`内の配列の1番目の要素に`IPv6`を明示的に指定した、次のようなServiceを作成してみます。Kubernetesは`service-cluster-ip-range`で設定したIPv6の範囲からcluster IPを割り当てて、`.spec.ipFamilyPolicy`を`SingleStack`に設定します。
139+
140+
{{< codenew file="service/networking/dual-stack-ipfamilies-ipv6.yaml" >}}
141+
142+
`kubectl`を使ってServiceのYAMLを表示します。
143+
144+
```shell
145+
kubectl get svc my-service -o yaml
146+
```
147+
148+
Serviceの`.spec.ipFamilyPolicy`は`SingleStack`に設定され、`.spec.clusterIP`には、kube-controller-manager上の`--service-cluster-ip-range`フラグで指定された最初の設定範囲から1つのIPv6アドレスが設定されているのがわかります。
149+
150+
```yaml
151+
apiVersion: v1
152+
kind: Service
153+
metadata:
154+
labels:
155+
app: MyApp
156+
name: my-service
157+
spec:
158+
clusterIP: fd00::5118
159+
clusterIPs:
160+
- fd00::5118
161+
ipFamilies:
162+
- IPv6
163+
ipFamilyPolicy: SingleStack
164+
ports:
165+
- port: 80
166+
protocol: TCP
167+
targetPort: 80
168+
selector:
169+
app: MyApp
170+
sessionAffinity: None
171+
type: ClusterIP
172+
status:
173+
loadBalancer: {}
174+
```
175+
176+
`.spec.ipFamiliePolicy`に`PreferDualStack`を明示的に指定した、次のようなServiceを作成してみます。Kubernetesは(クラスターでデュアルスタックを有効化しているため)IPv4およびIPv6のアドレスの両方を割り当て、`.spec.ClusterIPs`のリストから、`.spec.ipFamilies`配列の最初の要素のアドレスファミリーに基づいた`.spec.ClusterIP`を設定します。
177+
178+
{{< codenew file="service/networking/dual-stack-preferred-svc.yaml" >}}
179+
180+
{{< note >}}
181+
`kubectl get svc`コマンドは、`CLUSTER-IP`フィールドにプライマリーのIPだけしか表示しません。
182+
183+
```shell
184+
kubectl get svc -l app=MyApp
185+
186+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
187+
my-service ClusterIP 10.0.216.242 <none> 80/TCP 5s
188+
```
189+
{{< /note >}}
190+
191+
`kubectl describe`を使用して、ServiceがIPv4およびIPv6アドレスのブロックからcluster IPを割り当てられていることを検証します。その後、ServiceにIPアドレスとポートを使用してアクセスできることを検証することもできます。
192+
193+
```shell
194+
kubectl describe svc -l app=MyApp
195+
```
196+
197+
```
198+
Name: my-service
199+
Namespace: default
200+
Labels: app=MyApp
201+
Annotations: <none>
202+
Selector: app=MyApp
203+
Type: ClusterIP
204+
IP Family Policy: PreferDualStack
205+
IP Families: IPv4,IPv6
206+
IP: 10.0.216.242
207+
IPs: 10.0.216.242,fd00::af55
208+
Port: <unset> 80/TCP
209+
TargetPort: 9376/TCP
210+
Endpoints: <none>
211+
Session Affinity: None
212+
Events: <none>
213+
```
214+
215+
### デュアルスタックのLoadBalancer Serviceを作成する
216+
217+
クラウドプロバイダーがIPv6を有効化した外部ロードバランサーのプロビジョニングをサポートする場合、`.spec.ipFamilyPolicy`に`PreferDualStack`を指定し、`.spec.ipFamilies`の最初の要素を`IPv6`にして、`type`フィールドに`LoadBalancer`を指定したServiceを作成できます。
218+
219+
{{< codenew file="service/networking/dual-stack-prefer-ipv6-lb-svc.yaml" >}}
220+
221+
Serviceを確認します。
222+
223+
```shell
224+
kubectl get svc -l app=MyApp
225+
```
226+
227+
ServiceがIPv6アドレスブロックから`CLUSTER-IP`のアドレスと`EXTERNAL-IP`を割り当てられていることを検証します。その後、IPとポートを用いたServiceへのアクセスを検証することもできます。
228+
229+
```shell
230+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
231+
my-service LoadBalancer fd00::7ebc 2603:1030:805::5 80:30790/TCP 35s
232+
```

content/ja/examples/service/networking/dual-stack-default-svc.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: my-service
5+
labels:
6+
app: MyApp
57
spec:
68
selector:
79
app: MyApp
810
ports:
911
- protocol: TCP
1012
port: 80
11-
targetPort: 9376
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: my-service
5+
labels:
6+
app: MyApp
7+
spec:
8+
ipFamilies:
9+
- IPv6
10+
selector:
11+
app: MyApp
12+
ports:
13+
- protocol: TCP
14+
port: 80
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: my-service
5+
labels:
6+
app: MyApp
7+
spec:
8+
ipFamilyPolicy: PreferDualStack
9+
ipFamilies:
10+
- IPv6
11+
type: LoadBalancer
12+
selector:
13+
app: MyApp
14+
ports:
15+
- protocol: TCP
16+
port: 80
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: my-service
5+
labels:
6+
app: MyApp
7+
spec:
8+
ipFamilyPolicy: PreferDualStack
9+
ipFamilies:
10+
- IPv6
11+
- IPv4
12+
selector:
13+
app: MyApp
14+
ports:
15+
- protocol: TCP
16+
port: 80
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: my-service
5+
labels:
6+
app: MyApp
7+
spec:
8+
ipFamilyPolicy: PreferDualStack
9+
selector:
10+
app: MyApp
11+
ports:
12+
- protocol: TCP
13+
port: 80

0 commit comments

Comments
 (0)