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