Skip to content

Commit 8d3af3a

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 8d3af3a

File tree

7 files changed

+3275
-0
lines changed

7 files changed

+3275
-0
lines changed

config/v1/register.go

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

0 commit comments

Comments
 (0)