Skip to content

Commit b594976

Browse files
Merge pull request kubernetes#2 from lachie83/dual-stack-1-20
Update dual-stack validation for 1.20
2 parents d2700ad + 807581e commit b594976

9 files changed

+116
-31
lines changed

content/en/docs/tasks/network/validate-dual-stack.md

+86-22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
reviewers:
33
- lachie83
44
- khenidak
5+
- bridgetkromhout
56
min-kubernetes-server-version: v1.16
67
title: Validate IPv4/IPv6 dual-stack
78
content_type: task
@@ -97,31 +98,33 @@ a00:100::4 pod01
9798

9899
## Validate Services
99100

100-
Create the following Service without the `ipFamily` field set. When this field is not set, the Service gets an IP from the first configured range via `--service-cluster-ip-range` flag on the kube-controller-manager.
101+
Create the following Service that does not explicitly define `.spec.ipFamilyPolicy`. Kubernetes will assign a cluster IP for the Service from the first configured `service-cluster-ip-range` and set the `.spec.ipFamilyPolicy` to `SingleStack`.
101102

102103
{{< codenew file="service/networking/dual-stack-default-svc.yaml" >}}
103104

104-
By viewing the YAML for the Service you can observe that the Service has the `ipFamily` field has set to reflect the address family of the first configured range set via `--service-cluster-ip-range` flag on kube-controller-manager.
105+
By viewing the YAML for the Service, observe that the Service has the `.spec.ipFamilyPolicy` field has set to `SingleStack` and the `.spec.clusterIP` set to an IPv4 address from the first configured range set via `--service-cluster-ip-range` flag on kube-controller-manager.
105106

106107
```shell
107108
kubectl get svc my-service -o yaml
108109
```
109110

110111
```yaml
112+
kubectl get svc my-service -o yaml
111113
apiVersion: v1
112114
kind: Service
113115
metadata:
114-
creationTimestamp: "2019-09-03T20:45:13Z"
115-
labels:
116-
app: MyApp
116+
creationTimestamp: "2020-11-02T19:29:52Z"
117117
name: my-service
118118
namespace: default
119-
resourceVersion: "485836"
120-
selfLink: /api/v1/namespaces/default/services/my-service
121-
uid: b6fa83ef-fe7e-47a3-96a1-ac212fa5b030
119+
resourceVersion: "615853"
120+
uid: 4677a424-a354-41cf-82fc-bf8aeba510a4
122121
spec:
123-
clusterIP: 10.0.29.179
124-
ipFamily: IPv4
122+
clusterIP: 10.0.217.164
123+
clusterIPs:
124+
- 10.0.217.164
125+
ipFamilies:
126+
- IPv4
127+
ipFamilyPolicy: SingleStack
125128
ports:
126129
- port: 80
127130
protocol: TCP
@@ -134,28 +137,89 @@ status:
134137
loadBalancer: {}
135138
```
136139
137-
Create the following Service with the `ipFamily` field set to `IPv6`.
140+
Create the following Service that explicitly defines `IPv6` as the first array element in `.spec.ipFamilies`. Kubernetes will assign a cluster IP for the Service from the IPv6 range configured `service-cluster-ip-range` and set the `.spec.ipFamilyPolicy` to `SingleStack`.
138141

139-
{{< codenew file="service/networking/dual-stack-ipv6-svc.yaml" >}}
142+
{{< codenew file="service/networking/dual-stack-ipfamilies-ipv6.yaml" >}}
140143

141-
Validate that the Service gets a cluster IP address from the IPv6 address block. You may then validate access to the service via the IP and port.
144+
By viewing the YAML for the Service, observe that the Service has the `.spec.ipFamilyPolicy` field has set to `SingleStack` and the `.spec.clusterIP` set to an IPv6 address from the IPv6 range set via `--service-cluster-ip-range` flag on kube-controller-manager.
145+
146+
```shell
147+
kubectl get svc my-service -o yaml
142148
```
143-
kubectl get svc -l app=MyApp
144-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
145-
my-service ClusterIP fe80:20d::d06b <none> 80/TCP 9s
149+
150+
```yaml
151+
kubectl get svc my-service -o yaml
152+
apiVersion: v1
153+
kind: Service
154+
metadata:
155+
labels:
156+
app: MyApp
157+
name: my-service
158+
spec:
159+
clusterIP: fd00::5118
160+
clusterIPs:
161+
- fd00::5118
162+
ipFamilies:
163+
- IPv6
164+
ipFamilyPolicy: SingleStack
165+
ports:
166+
- port: 80
167+
protocol: TCP
168+
targetPort: 80
169+
selector:
170+
app: MyApp
171+
sessionAffinity: None
172+
type: ClusterIP
173+
status:
174+
loadBalancer: {}
175+
```
176+
177+
Create the following Service that explicitly defines `PreferDualStack` in `.spec.ipFamilyPolicy`. Kubernetes will assign both IPv4 and IPv6 addresses (as this cluster has dual-stack enabled) and select the `.spec.ClusterIP` from the list of `.spec.ClusterIPs` based on the address family of the first element in the `.spec.ipFamilies` array.
178+
179+
{{< codenew file="service/networking/dual-stack-preferred-svc.yaml" >}}
180+
181+
Validate that the Service gets cluster IPs from the IPv4 and IPv6 address blocks using `kubectl describe`. You may then validate access to the service via the IPs and ports.
182+
183+
{{< note >}}
184+
The `kubectl get svc` command will only show the primary IP in the `CLUSTER-IP` field.
185+
186+
```shell
187+
$ kubectl get svc -l app=MyApp
188+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
189+
my-service ClusterIP 10.0.216.242 <none> 80/TCP 5s
190+
```
191+
{{< /note >}}
192+
193+
```shell
194+
kubectl describe svc -l app=MyApp
195+
Name: my-service
196+
Namespace: default
197+
Labels: app=MyApp
198+
Annotations: <none>
199+
Selector: app=MyApp
200+
Type: ClusterIP
201+
IP Family Policy: PreferDualStack
202+
IP Families: IPv4,IPv6
203+
IP: 10.0.216.242
204+
IPs: 10.0.216.242,fd00::af55
205+
Port: <unset> 80/TCP
206+
TargetPort: 9376/TCP
207+
Endpoints: <none>
208+
Session Affinity: None
209+
Events: <none>
146210
```
147211

148212
### Create a dual-stack load balanced Service
149213

150-
If the cloud provider supports the provisioning of IPv6 enabled external load balancer, create the following Service with both the `ipFamily` field set to `IPv6` and the `type` field set to `LoadBalancer`
214+
If the cloud provider supports the provisioning of IPv6 enabled external load balancers, create the following Service with `PreferDualStack` in `.spec.ipFamilyPolicy`, `IPv6` as the first element of the `.spec.ipFamilies` array and the `type` field set to `LoadBalancer`.
151215

152-
{{< codenew file="service/networking/dual-stack-ipv6-lb-svc.yaml" >}}
216+
{{< codenew file="service/networking/dual-stack-prefer-ipv6-lb-svc.yaml" >}}
153217

154218
Validate that the Service receives a `CLUSTER-IP` address from the IPv6 address block along with an `EXTERNAL-IP`. You may then validate access to the service via the IP and port.
155-
```
156-
kubectl get svc -l app=MyApp
157-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
158-
my-service ClusterIP fe80:20d::d06b 2001:db8:f100:4002::9d37:c0d7 80:31868/TCP 30s
219+
```shell
220+
kubectl get svc -l app=MyApp
221+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
222+
my-service LoadBalancer fd00::7ebc 2603:1030:805::5 80:30790/TCP 35s
159223
```
160224

161225

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

+2-1
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

content/id/examples/service/networking/dual-stack-ipv6-svc.yaml renamed to content/en/examples/service/networking/dual-stack-ipfamilies-ipv6.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: my-service
5+
labels:
6+
app: MyApp
57
spec:
6-
ipFamily: IPv6
8+
ipFamilies:
9+
- IPv6
710
selector:
811
app: MyApp
912
ports:
1013
- protocol: TCP
1114
port: 80
12-
targetPort: 9376

content/en/examples/service/networking/dual-stack-ipv6-lb-svc.yaml renamed to content/en/examples/service/networking/dual-stack-prefer-ipv6-lb-svc.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ metadata:
55
labels:
66
app: MyApp
77
spec:
8-
ipFamily: IPv6
8+
ipFamilyPolicy: PreferDualStack
9+
ipFamilies:
10+
- IPv6
911
type: LoadBalancer
1012
selector:
1113
app: MyApp
1214
ports:
1315
- protocol: TCP
1416
port: 80
15-
targetPort: 9376

content/en/examples/service/networking/dual-stack-preferred-ipfamilies-svc.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: my-service
5+
labels:
6+
app: MyApp
57
spec:
68
ipFamilyPolicy: PreferDualStack
79
ipFamilies:
@@ -12,4 +14,3 @@ spec:
1214
ports:
1315
- protocol: TCP
1416
port: 80
15-
targetPort: 9376

content/en/examples/service/networking/dual-stack-preferred-svc.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: my-service
5+
labels:
6+
app: MyApp
57
spec:
68
ipFamilyPolicy: PreferDualStack
79
selector:
810
app: MyApp
911
ports:
1012
- protocol: TCP
1113
port: 80
12-
targetPort: 9376

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

+2-1
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

content/id/examples/service/networking/dual-stack-ipv4-svc.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: my-service
5+
labels:
6+
app: MyApp
57
spec:
68
ipFamily: IPv4
79
selector:
810
app: MyApp
911
ports:
1012
- protocol: TCP
1113
port: 80
12-
targetPort: 9376
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)