Skip to content

Commit 329d2a6

Browse files
committed
Add IngressControllerConfig API for cluster-level ingress management
Currently, OpenShift cluster administrators lack a unified way to configure operational settings for ingress controllers across the cluster. This introduces a new config/v1/IngressControllerConfig CRD that provides cluster-wide configuration for resource management, node scheduling, operational controls, and performance tuning. Signed-off-by: Daniel Mellado <[email protected]>
1 parent 588d549 commit 329d2a6

File tree

12 files changed

+4097
-0
lines changed

12 files changed

+4097
-0
lines changed

config/v1alpha1/register.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
4040
&ImagePolicyList{},
4141
&ClusterImagePolicy{},
4242
&ClusterImagePolicyList{},
43+
&IngressControllerConfig{},
44+
&IngressControllerConfigList{},
4345
)
4446
metav1.AddToGroupVersion(scheme, GroupVersion)
4547
return nil
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: config.openshift.io/v1alpha1
2+
kind: IngressControllerConfig
3+
metadata:
4+
name: cluster
5+
spec:
6+
defaultControllerConfig:
7+
logLevel: Info
8+
nodeSelector:
9+
kubernetes.io/os: linux
10+
node-role.kubernetes.io/worker: ""
11+
resources:
12+
- name: cpu
13+
request: 100m
14+
- name: memory
15+
request: 256Mi
16+
limit: 512Mi
17+
replicas: 2
18+
tolerations:
19+
- effect: NoSchedule
20+
key: node-role.kubernetes.io/worker
21+
operator: Exists
22+
performanceTuning:
23+
connectionLimits:
24+
maxConnections: 20000
25+
maxConnectionsPerBackend: 100
26+
maxRequestsPerConnection: 10
27+
timeouts:
28+
clientTimeout:
29+
duration: "30s"
30+
serverTimeout:
31+
duration: "30s"
32+
connectTimeout:
33+
duration: "5s"
34+
bufferSizes:
35+
requestHeaderBufferSize: "8Ki"
36+
responseBufferSize: "32Ki"
37+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: config.openshift.io/v1alpha1
2+
kind: IngressControllerConfig
3+
metadata:
4+
name: cluster
5+
spec:
6+
defaultControllerConfig:
7+
logLevel: Info
8+
nodeSelector:
9+
kubernetes.io/os: linux
10+
node-role.kubernetes.io/worker: ""
11+
resources:
12+
- name: cpu
13+
request: 100m
14+
- name: memory
15+
request: 256Mi
16+
limit: 512Mi
17+
replicas: 2
18+
tolerations:
19+
- effect: NoSchedule
20+
key: node-role.kubernetes.io/worker
21+
operator: Exists
22+
performanceTuning:
23+
connectionLimits:
24+
maxConnections: 20000
25+
maxConnectionsPerBackend: 100
26+
maxRequestsPerConnection: 10
27+
timeouts:
28+
clientTimeout:
29+
duration: "30s"
30+
serverTimeout:
31+
duration: "30s"
32+
connectTimeout:
33+
duration: "5s"
34+
bufferSizes:
35+
requestHeaderBufferSize: "8Ki"
36+
responseBufferSize: "32Ki"
Lines changed: 314 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
1+
/*
2+
Copyright 2024.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
v1 "k8s.io/api/core/v1"
21+
"k8s.io/apimachinery/pkg/api/resource"
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
)
24+
25+
// +genclient
26+
// +genclient:nonNamespaced
27+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
28+
29+
// IngressControllerConfig is the Custom Resource object which holds the current configuration of Ingress Controllers.
30+
// This provides a cluster-level configuration API for managing ingress controller operational settings.
31+
//
32+
// Compatibility level 4: No compatibility is provided, the API can change at any point for any reason. These capabilities should not be used by applications needing long term support.
33+
// +openshift:compatibility-gen:level=4
34+
// +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/XXXX
35+
// +openshift:file-pattern=cvoRunLevel=0000_10,operatorName=config-operator,operatorOrdering=01
36+
// +openshift:enable:FeatureGate=IngressControllerConfig
37+
// +kubebuilder:object:root=true
38+
// +kubebuilder:resource:path=ingresscontrollerconfigs,scope=Cluster
39+
// +kubebuilder:subresource:status
40+
// +kubebuilder:metadata:annotations="description=Ingress Controller configuration API"
41+
type IngressControllerConfig struct {
42+
metav1.TypeMeta `json:",inline"`
43+
44+
// metadata is the standard object metadata.
45+
// +optional
46+
metav1.ObjectMeta `json:"metadata,omitempty"`
47+
48+
// spec holds user configuration for the Ingress Controllers
49+
// +required
50+
Spec IngressControllerConfigSpec `json:"spec,omitzero"`
51+
// status holds observed values from the cluster. They may not be overridden.
52+
// +optional
53+
Status *IngressControllerConfigStatus `json:"status,omitempty"`
54+
}
55+
56+
// IngressControllerConfigStatus defines the observed state of IngressControllerConfig
57+
type IngressControllerConfigStatus struct {
58+
// conditions represent the latest available observations of the IngressControllerConfig's current state.
59+
// +optional
60+
// +listType=map
61+
// +listMapKey=type
62+
// +kubebuilder:validation:MaxItems=32
63+
Conditions []metav1.Condition `json:"conditions,omitempty"`
64+
}
65+
66+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
67+
68+
// Compatibility level 4: No compatibility is provided, the API can change at any point for any reason. These capabilities should not be used by applications needing long term support.
69+
// +openshift:compatibility-gen:level=4
70+
type IngressControllerConfigList struct {
71+
metav1.TypeMeta `json:",inline"`
72+
73+
// metadata is the standard list metadata.
74+
// +optional
75+
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
76+
77+
// items is a list of IngressControllerConfig
78+
// +optional
79+
Items []IngressControllerConfig `json:"items"`
80+
}
81+
82+
// IngressControllerConfigSpec defines the desired state of Ingress Controller operational configuration
83+
// +kubebuilder:validation:MinProperties=1
84+
type IngressControllerConfigSpec struct {
85+
// defaultControllerConfig allows users to configure how the default ingress controller instance
86+
// should be deployed and managed.
87+
// defaultControllerConfig is optional.
88+
// When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time.
89+
// +optional
90+
DefaultControllerConfig DefaultIngressControllerConfig `json:"defaultControllerConfig,omitempty,omitzero"`
91+
92+
// performanceTuning provides configuration options for performance optimization of ingress controllers.
93+
// performanceTuning is optional.
94+
// When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time.
95+
// +optional
96+
PerformanceTuning IngressControllerPerformanceTuning `json:"performanceTuning,omitempty,omitzero"`
97+
}
98+
99+
// DefaultIngressControllerConfig represents the configuration for the default ingress controller deployment.
100+
// defaultIngressControllerConfig provides configuration options for the default ingress controller instance
101+
// that runs in the `openshift-ingress` namespace. Use this configuration to control
102+
// how the default ingress controller is deployed, how it logs, and how its pods are scheduled.
103+
// +kubebuilder:validation:MinProperties=1
104+
type DefaultIngressControllerConfig struct {
105+
// logLevel defines the verbosity of logs emitted by the ingress controller.
106+
// This field allows users to control the amount and severity of logs generated, which can be useful
107+
// for debugging issues or reducing noise in production environments.
108+
// Allowed values are Error, Warn, Info, and Debug.
109+
// When set to Error, only errors will be logged.
110+
// When set to Warn, both warnings and errors will be logged.
111+
// When set to Info, general information, warnings, and errors will all be logged.
112+
// When set to Debug, detailed debugging information will be logged.
113+
// When omitted, this means no opinion and the platform is left to choose a reasonable default, that is subject to change over time.
114+
// The current default value is `Info`.
115+
// +optional
116+
LogLevel IngressControllerLogLevel `json:"logLevel,omitempty"`
117+
118+
// nodeSelector defines the nodes on which the ingress controller Pods are scheduled
119+
// nodeSelector is optional.
120+
//
121+
// When omitted, this means the user has no opinion and the platform is left
122+
// to choose reasonable defaults. These defaults are subject to change over time.
123+
// The current default value is `kubernetes.io/os: linux`.
124+
// +optional
125+
// +kubebuilder:validation:MinProperties=1
126+
// +kubebuilder:validation:MaxProperties=10
127+
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
128+
129+
// resources defines the compute resource requests and limits for the ingress controller container.
130+
// This includes CPU, memory and HugePages constraints to help control scheduling and resource usage.
131+
// When not specified, defaults are used by the platform. Requests cannot exceed limits.
132+
// This field is optional.
133+
// More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
134+
// This is a simplified API that maps to Kubernetes ResourceRequirements.
135+
// The current default values are:
136+
// resources:
137+
// - name: cpu
138+
// request: 100m
139+
// limit: null
140+
// - name: memory
141+
// request: 256Mi
142+
// limit: null
143+
// Maximum length for this list is 10.
144+
// Minimum length for this list is 1.
145+
// +optional
146+
// +listType=map
147+
// +listMapKey=name
148+
// +kubebuilder:validation:MaxItems=10
149+
// +kubebuilder:validation:MinItems=1
150+
Resources []IngressControllerContainerResource `json:"resources,omitempty"`
151+
152+
// replicas defines the desired number of ingress controller replicas.
153+
// This field allows users to control the availability and load distribution of the ingress controller.
154+
// When not specified, defaults are used by the platform based on the cluster topology.
155+
// The current default behavior is:
156+
// - SingleReplica topology: 1 replica
157+
// - HighlyAvailable topology: 2 replicas
158+
// +optional
159+
// +kubebuilder:validation:Minimum=1
160+
// +kubebuilder:validation:Maximum=20
161+
Replicas int32 `json:"replicas,omitempty"`
162+
163+
// tolerations defines the tolerations for ingress controller pods.
164+
// This allows the ingress controller to be scheduled on nodes with matching taints.
165+
// When not specified, no tolerations are applied.
166+
// +optional
167+
// +listType=atomic
168+
// +kubebuilder:validation:MaxItems=50
169+
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
170+
171+
// affinity defines the affinity rules for ingress controller pods.
172+
// This allows users to control pod placement for high availability or performance optimization.
173+
// When not specified, no affinity rules are applied.
174+
// +optional
175+
Affinity *v1.Affinity `json:"affinity,omitempty"`
176+
}
177+
178+
// IngressControllerPerformanceTuning provides configuration options for performance optimization
179+
// of ingress controllers. Use this configuration to control connection limits, timeouts,
180+
// and other performance-related settings.
181+
// +kubebuilder:validation:MinProperties=1
182+
type IngressControllerPerformanceTuning struct {
183+
// connectionLimits defines limits on connections handled by the ingress controller.
184+
// connectionLimits is optional.
185+
// When omitted, this means no opinion and the platform is left to choose reasonable defaults.
186+
// +optional
187+
ConnectionLimits *IngressControllerConnectionLimits `json:"connectionLimits,omitempty"`
188+
189+
// timeouts defines timeout settings for the ingress controller.
190+
// timeouts is optional.
191+
// When omitted, this means no opinion and the platform is left to choose reasonable defaults.
192+
// +optional
193+
Timeouts *IngressControllerTimeouts `json:"timeouts,omitempty"`
194+
195+
// bufferSizes defines buffer size settings for the ingress controller.
196+
// bufferSizes is optional.
197+
// When omitted, this means no opinion and the platform is left to choose reasonable defaults.
198+
// +optional
199+
BufferSizes *IngressControllerBufferSizes `json:"bufferSizes,omitempty"`
200+
}
201+
202+
// IngressControllerConnectionLimits defines connection-related limits for ingress controllers.
203+
type IngressControllerConnectionLimits struct {
204+
// maxConnections defines the maximum number of concurrent connections.
205+
// This helps prevent resource exhaustion under high load.
206+
// When not specified, the platform default is used.
207+
// +optional
208+
// +kubebuilder:validation:Minimum=1
209+
// +kubebuilder:validation:Maximum=1000000
210+
MaxConnections int32 `json:"maxConnections,omitempty"`
211+
212+
// maxConnectionsPerBackend defines the maximum number of connections per backend server.
213+
// This helps distribute load evenly across backend servers.
214+
// When not specified, the platform default is used.
215+
// +optional
216+
// +kubebuilder:validation:Minimum=1
217+
// +kubebuilder:validation:Maximum=10000
218+
MaxConnectionsPerBackend int32 `json:"maxConnectionsPerBackend,omitempty"`
219+
220+
// maxRequestsPerConnection defines the maximum number of requests per connection.
221+
// This controls connection reuse behavior.
222+
// When not specified, the platform default is used.
223+
// +optional
224+
// +kubebuilder:validation:Minimum=1
225+
// +kubebuilder:validation:Maximum=1000
226+
MaxRequestsPerConnection int32 `json:"maxRequestsPerConnection,omitempty"`
227+
}
228+
229+
// IngressControllerTimeouts defines timeout settings for ingress controllers.
230+
type IngressControllerTimeouts struct {
231+
// clientTimeout defines the timeout for client connections.
232+
// This is the maximum time to wait for a client to send a request.
233+
// When not specified, the platform default is used.
234+
// +optional
235+
ClientTimeout *metav1.Duration `json:"clientTimeout,omitempty"`
236+
237+
// serverTimeout defines the timeout for backend server connections.
238+
// This is the maximum time to wait for a response from a backend server.
239+
// When not specified, the platform default is used.
240+
// +optional
241+
ServerTimeout *metav1.Duration `json:"serverTimeout,omitempty"`
242+
243+
// connectTimeout defines the timeout for establishing connections to backend servers.
244+
// This is the maximum time to wait when establishing a connection to a backend.
245+
// When not specified, the platform default is used.
246+
// +optional
247+
ConnectTimeout *metav1.Duration `json:"connectTimeout,omitempty"`
248+
}
249+
250+
// IngressControllerBufferSizes defines buffer size settings for ingress controllers.
251+
type IngressControllerBufferSizes struct {
252+
// requestHeaderBufferSize defines the size of the buffer for request headers.
253+
// This affects the maximum size of request headers that can be processed.
254+
// When not specified, the platform default is used.
255+
// +optional
256+
RequestHeaderBufferSize *resource.Quantity `json:"requestHeaderBufferSize,omitempty"`
257+
258+
// responseBufferSize defines the size of the buffer for responses.
259+
// This affects buffering behavior for responses from backend servers.
260+
// When not specified, the platform default is used.
261+
// +optional
262+
ResponseBufferSize *resource.Quantity `json:"responseBufferSize,omitempty"`
263+
}
264+
265+
// IngressControllerContainerResource defines a single resource requirement for an ingress controller container.
266+
// +kubebuilder:validation:XValidation:rule="has(self.request) || has(self.limit)",message="at least one of request or limit must be set"
267+
// +kubebuilder:validation:XValidation:rule="!(has(self.request) && has(self.limit)) || quantity(self.limit).compareTo(quantity(self.request)) >= 0",message="limit must be greater than or equal to request"
268+
type IngressControllerContainerResource struct {
269+
// name of the resource (e.g. "cpu", "memory", "hugepages-2Mi").
270+
// This field is required.
271+
// name must consist only of alphanumeric characters, `-`, `_` and `.` and must start and end with an alphanumeric character.
272+
// +required
273+
// +kubebuilder:validation:MinLength=1
274+
// +kubebuilder:validation:MaxLength=253
275+
// +kubebuilder:validation:XValidation:rule="!format.qualifiedName().validate(self).hasValue()",message="name must consist only of alphanumeric characters, `-`, `_` and `.` and must start and end with an alphanumeric character"
276+
Name string `json:"name,omitempty"`
277+
278+
// request is the minimum amount of the resource required (e.g. "2Mi", "1Gi").
279+
// This field is optional.
280+
// When limit is specified, request cannot be greater than limit.
281+
// +optional
282+
// +kubebuilder:validation:XIntOrString
283+
// +kubebuilder:validation:MaxLength=20
284+
// +kubebuilder:validation:MinLength=1
285+
// +kubebuilder:validation:XValidation:rule="isQuantity(self) && quantity(self).isGreaterThan(quantity('0'))",message="request must be a positive, non-zero quantity"
286+
Request resource.Quantity `json:"request,omitempty"`
287+
288+
// limit is the maximum amount of the resource allowed (e.g. "2Mi", "1Gi").
289+
// This field is optional.
290+
// When request is specified, limit cannot be less than request.
291+
// The value must be greater than 0 when specified.
292+
// +optional
293+
// +kubebuilder:validation:XIntOrString
294+
// +kubebuilder:validation:MaxLength=20
295+
// +kubebuilder:validation:MinLength=1
296+
// +kubebuilder:validation:XValidation:rule="isQuantity(self) && quantity(self).isGreaterThan(quantity('0'))",message="limit must be a positive, non-zero quantity"
297+
Limit resource.Quantity `json:"limit,omitempty"`
298+
}
299+
300+
// IngressControllerLogLevel defines the log level for ingress controllers
301+
// +kubebuilder:validation:Enum="Error";"Warn";"Info";"Debug"
302+
type IngressControllerLogLevel string
303+
304+
const (
305+
// IngressControllerLogLevelError only errors will be logged.
306+
IngressControllerLogLevelError IngressControllerLogLevel = "Error"
307+
// IngressControllerLogLevelWarn, both warnings and errors will be logged.
308+
IngressControllerLogLevelWarn IngressControllerLogLevel = "Warn"
309+
// IngressControllerLogLevelInfo, general information, warnings, and errors will all be logged.
310+
IngressControllerLogLevelInfo IngressControllerLogLevel = "Info"
311+
// IngressControllerLogLevelDebug, detailed debugging information will be logged.
312+
IngressControllerLogLevelDebug IngressControllerLogLevel = "Debug"
313+
)
314+

0 commit comments

Comments
 (0)