Skip to content

Commit b3d7f7c

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 when the LB Type is "Classic", IPFamily can only have the value "IPv4". Only LB Type of "NLB" is allowed for IPFamily values of "DualStackIPv4Primary" and "DualStackIPv6Primary".
1 parent 59aa3e5 commit b3d7f7c

6 files changed

Lines changed: 188 additions & 4 deletions

File tree

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

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,120 @@ tests:
1212
apiVersion: config.openshift.io/v1
1313
kind: Ingress
1414
spec: {}
15+
- name: Should be able to create an Ingress with Classic load balancer type and IPv4 ipFamily
16+
initial: |
17+
apiVersion: config.openshift.io/v1
18+
kind: Ingress
19+
spec:
20+
domain: apps.example.com
21+
loadBalancer:
22+
platform:
23+
type: AWS
24+
aws:
25+
type: Classic
26+
ipFamily: IPv4
27+
expected: |
28+
apiVersion: config.openshift.io/v1
29+
kind: Ingress
30+
spec:
31+
domain: apps.example.com
32+
loadBalancer:
33+
platform:
34+
type: AWS
35+
aws:
36+
type: Classic
37+
ipFamily: IPv4
38+
- name: Should be able to create an Ingress with Classic load balancer type and omitted ipFamily
39+
initial: |
40+
apiVersion: config.openshift.io/v1
41+
kind: Ingress
42+
spec:
43+
domain: apps.example.com
44+
loadBalancer:
45+
platform:
46+
type: AWS
47+
aws:
48+
type: Classic
49+
expected: |
50+
apiVersion: config.openshift.io/v1
51+
kind: Ingress
52+
spec:
53+
domain: apps.example.com
54+
loadBalancer:
55+
platform:
56+
type: AWS
57+
aws:
58+
type: Classic
59+
ipFamily: IPv4
60+
- name: Should not be able to create an Ingress with Classic load balancer type and DualStackIPv4Primary ipFamily
61+
initial: |
62+
apiVersion: config.openshift.io/v1
63+
kind: Ingress
64+
spec:
65+
domain: apps.example.com
66+
loadBalancer:
67+
platform:
68+
type: AWS
69+
aws:
70+
type: Classic
71+
ipFamily: DualStackIPv4Primary
72+
expectedError: "spec.loadBalancer.platform.aws: Invalid value: \"object\": when type is Classic, ipFamily must be IPv4 or omitted (defaults to IPv4)"
73+
- name: Should not be able to create an Ingress with Classic load balancer type and DualStackIPv6Primary ipFamily
74+
initial: |
75+
apiVersion: config.openshift.io/v1
76+
kind: Ingress
77+
spec:
78+
domain: apps.example.com
79+
loadBalancer:
80+
platform:
81+
type: AWS
82+
aws:
83+
type: Classic
84+
ipFamily: DualStackIPv6Primary
85+
expectedError: "spec.loadBalancer.platform.aws: Invalid value: \"object\": when type is Classic, ipFamily must be IPv4 or omitted (defaults to IPv4)"
86+
- name: Should be able to create an Ingress with NLB load balancer type and DualStackIPv4Primary ipFamily
87+
initial: |
88+
apiVersion: config.openshift.io/v1
89+
kind: Ingress
90+
spec:
91+
domain: apps.example.com
92+
loadBalancer:
93+
platform:
94+
type: AWS
95+
aws:
96+
type: NLB
97+
ipFamily: DualStackIPv4Primary
98+
expected: |
99+
apiVersion: config.openshift.io/v1
100+
kind: Ingress
101+
spec:
102+
domain: apps.example.com
103+
loadBalancer:
104+
platform:
105+
type: AWS
106+
aws:
107+
type: NLB
108+
ipFamily: DualStackIPv4Primary
109+
- name: Should be able to create an Ingress with NLB load balancer type and DualStackIPv6Primary ipFamily
110+
initial: |
111+
apiVersion: config.openshift.io/v1
112+
kind: Ingress
113+
spec:
114+
domain: apps.example.com
115+
loadBalancer:
116+
platform:
117+
type: AWS
118+
aws:
119+
type: NLB
120+
ipFamily: DualStackIPv6Primary
121+
expected: |
122+
apiVersion: config.openshift.io/v1
123+
kind: Ingress
124+
spec:
125+
domain: apps.example.com
126+
loadBalancer:
127+
platform:
128+
type: AWS
129+
aws:
130+
type: NLB
131+
ipFamily: DualStackIPv6Primary

config/v1/types_ingress.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ type LoadBalancer struct {
131131
// AWSIngressSpec holds the desired state of the Ingress for Amazon Web Services infrastructure provider.
132132
// This only includes fields that can be modified in the cluster.
133133
// +union
134+
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'Classic' ? (!has(self.ipFamily) || self.ipFamily == 'IPv4') : true",message="when type is Classic, ipFamily must be IPv4 or omitted (defaults to IPv4)"
134135
type AWSIngressSpec struct {
135136
// type allows user to set a load balancer type.
136137
// When this field is set the default ingresscontroller will get created using the specified LBType.
@@ -151,6 +152,20 @@ type AWSIngressSpec struct {
151152
// +kubebuilder:validation:Enum:=NLB;Classic
152153
// +required
153154
Type AWSLBType `json:"type"`
155+
156+
// ipFamily allows users to specify the IP protocol Families that the Load Balancer service supports.
157+
// The default ingress controller uses this information to configure its Load Balancer.
158+
// Valid values are:
159+
//
160+
// * "IPv4": Only value supported with a "Classic" Load Balancer. When type is "Classic",
161+
// this field must be set to "IPv4" or omitted (which defaults to "IPv4").
162+
// * "DualStackIPv4Primary": supported with only with Network Load Balancer.
163+
// * "DualStackIPv6Primary": supported with only with Network Load Balancer.
164+
// +kubebuilder:default:="IPv4"
165+
// +kubebuilder:validation:Enum="IPv4";"DualStackIPv4Primary";"DualStackIPv6Primary"
166+
// +optional
167+
// +unionMember,optional
168+
IPFamily IPFamilyType `json:"ipFamily,omitempty"`
154169
}
155170

156171
type AWSLBType string

config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_ingresses.crd.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,22 @@ spec:
145145
description: aws contains settings specific to the Amazon
146146
Web Services infrastructure provider.
147147
properties:
148+
ipFamily:
149+
default: IPv4
150+
description: |-
151+
ipFamily allows users to specify the IP protocol Families that the Load Balancer service supports.
152+
The default ingress controller uses this information to configure its Load Balancer.
153+
Valid values are:
154+
155+
* "IPv4": Only value supported with a "Classic" Load Balancer. When type is "Classic",
156+
this field must be set to "IPv4" or omitted (which defaults to "IPv4").
157+
* "DualStackIPv4Primary": supported with only with Network Load Balancer.
158+
* "DualStackIPv6Primary": supported with only with Network Load Balancer.
159+
enum:
160+
- IPv4
161+
- DualStackIPv4Primary
162+
- DualStackIPv6Primary
163+
type: string
148164
type:
149165
description: |-
150166
type allows user to set a load balancer type.
@@ -169,6 +185,11 @@ spec:
169185
required:
170186
- type
171187
type: object
188+
x-kubernetes-validations:
189+
- message: when type is Classic, ipFamily must be IPv4 or
190+
omitted (defaults to IPv4)
191+
rule: 'has(self.type) && self.type == ''Classic'' ? (!has(self.ipFamily)
192+
|| self.ipFamily == ''IPv4'') : true'
172193
type:
173194
description: |-
174195
type is the underlying infrastructure provider for the cluster.

config/v1/zz_generated.featuregated-crd-manifests/ingresses.config.openshift.io/AAA_ungated.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,22 @@ spec:
146146
description: aws contains settings specific to the Amazon
147147
Web Services infrastructure provider.
148148
properties:
149+
ipFamily:
150+
default: IPv4
151+
description: |-
152+
ipFamily allows users to specify the IP protocol Families that the Load Balancer service supports.
153+
The default ingress controller uses this information to configure its Load Balancer.
154+
Valid values are:
155+
156+
* "IPv4": Only value supported with a "Classic" Load Balancer. When type is "Classic",
157+
this field must be set to "IPv4" or omitted (which defaults to "IPv4").
158+
* "DualStackIPv4Primary": supported with only with Network Load Balancer.
159+
* "DualStackIPv6Primary": supported with only with Network Load Balancer.
160+
enum:
161+
- IPv4
162+
- DualStackIPv4Primary
163+
- DualStackIPv6Primary
164+
type: string
149165
type:
150166
description: |-
151167
type allows user to set a load balancer type.
@@ -170,6 +186,11 @@ spec:
170186
required:
171187
- type
172188
type: object
189+
x-kubernetes-validations:
190+
- message: when type is Classic, ipFamily must be IPv4 or
191+
omitted (defaults to IPv4)
192+
rule: 'has(self.type) && self.type == ''Classic'' ? (!has(self.ipFamily)
193+
|| self.ipFamily == ''IPv4'') : true'
173194
type:
174195
description: |-
175196
type is the underlying infrastructure provider for the cluster.

config/v1/zz_generated.swagger_doc_generated.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi/generated_openapi/zz_generated.openapi.go

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)