Skip to content

Commit 9d63e2e

Browse files
committed
Add IPFamily to Ingress API
Add the IPFamliy field to Ingress API's IngressSpec that enables Day 0 configuration of the default Ingress controller with DualStack configuration. This field defaults to IPv4 when not set and is available only when the AWSDualStackInstall and AzureDualStack install featuregates are enabled. This field cannot be modified once set so the IPFamily of the default Ingress controller cannot be changed on Day-2 after set by the installer on Day-0.
1 parent 59aa3e5 commit 9d63e2e

20 files changed

Lines changed: 5872 additions & 2 deletions

config/v1/tests/ingresses.config.openshift.io/AAA_ungated.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
22
name: "Ingress"
33
crdName: ingresses.config.openshift.io
4+
featureGates:
5+
- -AWSDualStackInstall
6+
- -AzureDualStackInstall
47
tests:
58
onCreate:
69
- name: Should be able to create a minimal Ingress
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "Ingress"
3+
crdName: ingresses.config.openshift.io
4+
featureGates:
5+
- AWSDualStackInstall
6+
tests:
7+
onCreate:
8+
- name: Should be able to create an Ingress with default ipFamily
9+
initial: |
10+
apiVersion: config.openshift.io/v1
11+
kind: Ingress
12+
spec:
13+
domain: apps.example.com
14+
expected: |
15+
apiVersion: config.openshift.io/v1
16+
kind: Ingress
17+
spec:
18+
domain: apps.example.com
19+
ipFamily: IPv4
20+
- name: Should be able to create an Ingress with ipFamily set to IPv4
21+
initial: |
22+
apiVersion: config.openshift.io/v1
23+
kind: Ingress
24+
spec:
25+
domain: apps.example.com
26+
ipFamily: IPv4
27+
expected: |
28+
apiVersion: config.openshift.io/v1
29+
kind: Ingress
30+
spec:
31+
domain: apps.example.com
32+
ipFamily: IPv4
33+
- name: Should be able to create an Ingress with ipFamily set to DualStackIPv6Primary
34+
initial: |
35+
apiVersion: config.openshift.io/v1
36+
kind: Ingress
37+
spec:
38+
domain: apps.example.com
39+
ipFamily: DualStackIPv6Primary
40+
expected: |
41+
apiVersion: config.openshift.io/v1
42+
kind: Ingress
43+
spec:
44+
domain: apps.example.com
45+
ipFamily: DualStackIPv6Primary
46+
- name: Should be able to create an Ingress with ipFamily set to DualStackIPv4Primary
47+
initial: |
48+
apiVersion: config.openshift.io/v1
49+
kind: Ingress
50+
spec:
51+
domain: apps.example.com
52+
ipFamily: DualStackIPv4Primary
53+
expected: |
54+
apiVersion: config.openshift.io/v1
55+
kind: Ingress
56+
spec:
57+
domain: apps.example.com
58+
ipFamily: DualStackIPv4Primary
59+
- name: Should not be able to create an Ingress with invalid ipFamily value
60+
initial: |
61+
apiVersion: config.openshift.io/v1
62+
kind: Ingress
63+
spec:
64+
domain: apps.example.com
65+
ipFamily: InvalidValue
66+
expectedError: "spec.ipFamily: Unsupported value: \"InvalidValue\": supported values: \"IPv4\", \"DualStackIPv6Primary\", \"DualStackIPv4Primary\""
67+
onUpdate:
68+
- name: Should default ipFamily to IPv4 when not specified
69+
initial: |
70+
apiVersion: config.openshift.io/v1
71+
kind: Ingress
72+
spec:
73+
domain: apps.example.com
74+
updated: |
75+
apiVersion: config.openshift.io/v1
76+
kind: Ingress
77+
spec:
78+
domain: apps.example.com
79+
expected: |
80+
apiVersion: config.openshift.io/v1
81+
kind: Ingress
82+
spec:
83+
domain: apps.example.com
84+
ipFamily: IPv4
85+
- name: Should not allow changing ipFamily once set
86+
initial: |
87+
apiVersion: config.openshift.io/v1
88+
kind: Ingress
89+
spec:
90+
domain: apps.example.com
91+
ipFamily: IPv4
92+
updated: |
93+
apiVersion: config.openshift.io/v1
94+
kind: Ingress
95+
spec:
96+
domain: apps.example.com
97+
ipFamily: DualStackIPv6Primary
98+
expectedError: "spec.ipFamily: Invalid value: \"string\": ipFamily is immutable once set"
99+
- name: Should allow setting the same ipFamily value
100+
initial: |
101+
apiVersion: config.openshift.io/v1
102+
kind: Ingress
103+
spec:
104+
domain: apps.example.com
105+
ipFamily: DualStackIPv6Primary
106+
updated: |
107+
apiVersion: config.openshift.io/v1
108+
kind: Ingress
109+
spec:
110+
domain: apps.example.com
111+
ipFamily: DualStackIPv6Primary
112+
expected: |
113+
apiVersion: config.openshift.io/v1
114+
kind: Ingress
115+
spec:
116+
domain: apps.example.com
117+
ipFamily: DualStackIPv6Primary
118+
- name: Should not allow unsetting ipFamily once it has been set
119+
initial: |
120+
apiVersion: config.openshift.io/v1
121+
kind: Ingress
122+
spec:
123+
domain: apps.example.com
124+
ipFamily: DualStackIPv4Primary
125+
updated: |
126+
apiVersion: config.openshift.io/v1
127+
kind: Ingress
128+
spec:
129+
domain: apps.example.com
130+
expectedError: "spec.ipFamily: Invalid value: \"string\": ipFamily is immutable once set"
131+
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "Ingress"
3+
crdName: ingresses.config.openshift.io
4+
featureGates:
5+
- AzureDualStackInstall
6+
tests:
7+
onCreate:
8+
- name: Should be able to create an Ingress with default ipFamily
9+
initial: |
10+
apiVersion: config.openshift.io/v1
11+
kind: Ingress
12+
spec:
13+
domain: apps.example.com
14+
expected: |
15+
apiVersion: config.openshift.io/v1
16+
kind: Ingress
17+
spec:
18+
domain: apps.example.com
19+
ipFamily: IPv4
20+
- name: Should be able to create an Ingress with ipFamily set to IPv4
21+
initial: |
22+
apiVersion: config.openshift.io/v1
23+
kind: Ingress
24+
spec:
25+
domain: apps.example.com
26+
ipFamily: IPv4
27+
expected: |
28+
apiVersion: config.openshift.io/v1
29+
kind: Ingress
30+
spec:
31+
domain: apps.example.com
32+
ipFamily: IPv4
33+
- name: Should be able to create an Ingress with ipFamily set to DualStackIPv6Primary
34+
initial: |
35+
apiVersion: config.openshift.io/v1
36+
kind: Ingress
37+
spec:
38+
domain: apps.example.com
39+
ipFamily: DualStackIPv6Primary
40+
expected: |
41+
apiVersion: config.openshift.io/v1
42+
kind: Ingress
43+
spec:
44+
domain: apps.example.com
45+
ipFamily: DualStackIPv6Primary
46+
- name: Should be able to create an Ingress with ipFamily set to DualStackIPv4Primary
47+
initial: |
48+
apiVersion: config.openshift.io/v1
49+
kind: Ingress
50+
spec:
51+
domain: apps.example.com
52+
ipFamily: DualStackIPv4Primary
53+
expected: |
54+
apiVersion: config.openshift.io/v1
55+
kind: Ingress
56+
spec:
57+
domain: apps.example.com
58+
ipFamily: DualStackIPv4Primary
59+
- name: Should not be able to create an Ingress with invalid ipFamily value
60+
initial: |
61+
apiVersion: config.openshift.io/v1
62+
kind: Ingress
63+
spec:
64+
domain: apps.example.com
65+
ipFamily: InvalidValue
66+
expectedError: "spec.ipFamily: Unsupported value: \"InvalidValue\": supported values: \"IPv4\", \"DualStackIPv6Primary\", \"DualStackIPv4Primary\""
67+
onUpdate:
68+
- name: Should default ipFamily to IPv4 when not specified
69+
initial: |
70+
apiVersion: config.openshift.io/v1
71+
kind: Ingress
72+
spec:
73+
domain: apps.example.com
74+
updated: |
75+
apiVersion: config.openshift.io/v1
76+
kind: Ingress
77+
spec:
78+
domain: apps.example.com
79+
expected: |
80+
apiVersion: config.openshift.io/v1
81+
kind: Ingress
82+
spec:
83+
domain: apps.example.com
84+
ipFamily: IPv4
85+
- name: Should not allow changing ipFamily once set
86+
initial: |
87+
apiVersion: config.openshift.io/v1
88+
kind: Ingress
89+
spec:
90+
domain: apps.example.com
91+
ipFamily: IPv4
92+
updated: |
93+
apiVersion: config.openshift.io/v1
94+
kind: Ingress
95+
spec:
96+
domain: apps.example.com
97+
ipFamily: DualStackIPv6Primary
98+
expectedError: "spec.ipFamily: Invalid value: \"string\": ipFamily is immutable once set"
99+
- name: Should allow setting the same ipFamily value
100+
initial: |
101+
apiVersion: config.openshift.io/v1
102+
kind: Ingress
103+
spec:
104+
domain: apps.example.com
105+
ipFamily: DualStackIPv6Primary
106+
updated: |
107+
apiVersion: config.openshift.io/v1
108+
kind: Ingress
109+
spec:
110+
domain: apps.example.com
111+
ipFamily: DualStackIPv6Primary
112+
expected: |
113+
apiVersion: config.openshift.io/v1
114+
kind: Ingress
115+
spec:
116+
domain: apps.example.com
117+
ipFamily: DualStackIPv6Primary
118+
- name: Should not allow unsetting ipFamily once it has been set
119+
initial: |
120+
apiVersion: config.openshift.io/v1
121+
kind: Ingress
122+
spec:
123+
domain: apps.example.com
124+
ipFamily: DualStackIPv4Primary
125+
updated: |
126+
apiVersion: config.openshift.io/v1
127+
kind: Ingress
128+
spec:
129+
domain: apps.example.com
130+
expectedError: "spec.ipFamily: Invalid value: \"string\": ipFamily is immutable once set"
131+

config/v1/types_ingress.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,23 @@ type IngressSpec struct {
9898
// provider of the current cluster and are required for Ingress Controller to work on OpenShift.
9999
// +optional
100100
LoadBalancer LoadBalancer `json:"loadBalancer,omitempty"`
101+
102+
// ipFamily specifies the IP protocol family that should be used for the
103+
// ingress load balancer. This field determines whether the load balancer uses
104+
// IPv4-only, or dual-stack networking with IPv4 or IPv6 as the primary
105+
// protocol family.
106+
// Valid values are "IPv4", "DualStackIPv6Primary", and "DualStackIPv4Primary".
107+
// When set to IPv4, the load balancer will use IPv4 addressing only.
108+
// When set to DualStackIPv6Primary, the load balancer will use dual-stack networking with IPv6 as primary.
109+
// When set to DualStackIPv4Primary, the load balancer will use dual-stack networking with IPv4 as primary.
110+
// When omitted, the default value is IPv4.
111+
//
112+
// +default="IPv4"
113+
// +kubebuilder:validation:XValidation:rule="oldSelf == '' || self == oldSelf",message="ipFamily is immutable once set"
114+
// +openshift:enable:FeatureGate=AWSDualStackInstall
115+
// +openshift:enable:FeatureGate=AzureDualStackInstall
116+
// +optional
117+
IPFamily IPFamilyType `json:"ipFamily,omitempty"`
101118
}
102119

103120
// IngressPlatformSpec holds the desired state of Ingress specific to the underlying infrastructure provider

0 commit comments

Comments
 (0)