diff --git a/api/v1alpha1/nginxingresscontroller_types.go b/api/v1alpha1/nginxingresscontroller_types.go index af125e04..c306feb2 100644 --- a/api/v1alpha1/nginxingresscontroller_types.go +++ b/api/v1alpha1/nginxingresscontroller_types.go @@ -73,6 +73,19 @@ type NginxIngressControllerSpec struct { // HTTPDisabled is a flag that disables HTTP traffic to the NginxIngressController // +optional HTTPDisabled bool `json:"httpDisabled,omitempty"` + + // CPURequest is the CPU request for the NGINX Ingress Controller. This is used to set the CPU request for the NGINX Ingress Controller deployment. + // +kubebuilder:validation:Pattern=`^[0-9]+(m|M|[a-zA-Z]{1})$` + // +kubebuilder:default:=500m + // +kubebuilder:validation:Required + CPURequest string `json:"cpuRequest,omitempty"` + + // MemoryRequest is the memory request for the NGINX Ingress Controller. This is used to set the memory request for the NGINX Ingress Controller deployment. + // +kubebuilder:validation:Pattern=`^[0-9]+(Mi|Gi|[a-zA-Z]{1})$` + // +kubebuilder:default:=127Mi + // +kubebuilder:validation:Required + + MemoryRequest string `json:"memoryRequest,omitempty"` } // DefaultSSLCertificate holds a secret in the form of a secret struct with name and namespace properties or a key vault uri diff --git a/pkg/controller/nginxingress/nginx_ingress_controller.go b/pkg/controller/nginxingress/nginx_ingress_controller.go index 75b87641..2dda1b71 100644 --- a/pkg/controller/nginxingress/nginx_ingress_controller.go +++ b/pkg/controller/nginxingress/nginx_ingress_controller.go @@ -570,6 +570,8 @@ func ToNginxIngressConfig(nic *approutingv1alpha1.NginxIngressController, defaul MinReplicas: minReplicas, MaxReplicas: maxReplicas, TargetCPUUtilizationPercentage: getTargetCPUUtilizationPercentage(nic), + CPURequest: nic.Spec.CPURequest, + MemoryRequest: nic.Spec.MemoryRequest, } if cert := nic.Spec.DefaultSSLCertificate; cert != nil { diff --git a/pkg/manifests/nginx.go b/pkg/manifests/nginx.go index 67932c55..f04349a5 100644 --- a/pkg/manifests/nginx.go +++ b/pkg/manifests/nginx.go @@ -478,8 +478,8 @@ func newNginxIngressControllerDeployment(conf *config.Config, ingressConfig *Ngi }, Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("500m"), - corev1.ResourceMemory: resource.MustParse("127Mi"), + corev1.ResourceCPU: resource.MustParse(ingressConfig.CPURequest), + corev1.ResourceMemory: resource.MustParse(ingressConfig.MemoryRequest), }, }, }), 6))}, diff --git a/pkg/manifests/types.go b/pkg/manifests/types.go index e7fbe387..404def31 100644 --- a/pkg/manifests/types.go +++ b/pkg/manifests/types.go @@ -65,6 +65,8 @@ type NginxIngressConfig struct { CustomHTTPErrors string // error codes passed to the configmap to configure nginx to send traffic with the specified headers to its defaultbackend service in case of error MinReplicas int32 MaxReplicas int32 + CPURequest string // CPU request for the Ingress Controller + MemoryRequest string // Memory request for the Ingress Controller // TargetCPUUtilizationPercentage is the target average CPU utilization of the Ingress Controller TargetCPUUtilizationPercentage int32 }