Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions api/v1alpha1/nginxingresscontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/nginxingress/nginx_ingress_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/manifests/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))},
Expand Down
2 changes: 2 additions & 0 deletions pkg/manifests/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down