@@ -244,6 +244,12 @@ func renderOVNKubernetes(conf *operv1.NetworkSpec, bootstrapResult *bootstrap.Bo
244244 data .Data ["CAConfigMapKey" ] = bootstrapResult .OVN .OVNKubernetesConfig .HyperShiftConfig .CAConfigMapKey
245245 data .Data ["RunAsUser" ] = bootstrapResult .OVN .OVNKubernetesConfig .HyperShiftConfig .RunAsUser
246246 data .Data ["PriorityClass" ] = bootstrapResult .OVN .OVNKubernetesConfig .HyperShiftConfig .PriorityClass
247+ data .Data ["TokenMinterResourceRequestCPU" ] = bootstrapResult .OVN .OVNKubernetesConfig .HyperShiftConfig .TokenMinterResourceRequestCPU
248+ data .Data ["TokenMinterResourceRequestMemory" ] = bootstrapResult .OVN .OVNKubernetesConfig .HyperShiftConfig .TokenMinterResourceRequestMemory
249+ data .Data ["OVNControlPlaneResourceRequestCPU" ] = bootstrapResult .OVN .OVNKubernetesConfig .HyperShiftConfig .OVNControlPlaneResourceRequestCPU
250+ data .Data ["OVNControlPlaneResourceRequestMemory" ] = bootstrapResult .OVN .OVNKubernetesConfig .HyperShiftConfig .OVNControlPlaneResourceRequestMemory
251+ data .Data ["Socks5ProxyResourceRequestCPU" ] = bootstrapResult .OVN .OVNKubernetesConfig .HyperShiftConfig .Socks5ProxyResourceRequestCPU
252+ data .Data ["Socks5ProxyResourceRequestMemory" ] = bootstrapResult .OVN .OVNKubernetesConfig .HyperShiftConfig .Socks5ProxyResourceRequestMemory
247253 data .Data ["OVN_NB_INACTIVITY_PROBE" ] = nb_inactivity_probe
248254 data .Data ["OVN_CERT_CN" ] = OVN_CERT_CN
249255 data .Data ["OVN_NORTHD_PROBE_INTERVAL" ] = os .Getenv ("OVN_NORTHD_PROBE_INTERVAL" )
@@ -749,9 +755,67 @@ func bootstrapOVNHyperShiftConfig(hc *hypershift.HyperShiftConfig, kubeClient cn
749755 default :
750756 ovnHypershiftResult .ControlPlaneReplicas = 1
751757 }
758+
759+ // Preserve any customizations to the resource requests on the three containers in the ovn-control-plane pod
760+ controlPlaneClient := kubeClient .ClientFor (names .ManagementClusterName )
761+ tokenMinterCPURequest , tokenMinterMemoryRequest := getResourceRequestsForDeployment (controlPlaneClient .CRClient (), hc .Namespace , util .OVN_CONTROL_PLANE , "token-minter" )
762+ if tokenMinterCPURequest > 0 {
763+ ovnHypershiftResult .TokenMinterResourceRequestCPU = strconv .FormatInt (tokenMinterCPURequest , 10 )
764+ }
765+ if tokenMinterMemoryRequest > 0 {
766+ ovnHypershiftResult .TokenMinterResourceRequestMemory = strconv .FormatInt (tokenMinterMemoryRequest , 10 )
767+ }
768+
769+ ovnControlPlaneCPURequest , ovnControlPlaneMemoryRequest := getResourceRequestsForDeployment (controlPlaneClient .CRClient (), hc .Namespace , util .OVN_CONTROL_PLANE , "ovnkube-control-plane" )
770+ if ovnControlPlaneCPURequest > 0 {
771+ ovnHypershiftResult .OVNControlPlaneResourceRequestCPU = strconv .FormatInt (ovnControlPlaneCPURequest , 10 )
772+ }
773+ if ovnControlPlaneMemoryRequest > 0 {
774+ ovnHypershiftResult .OVNControlPlaneResourceRequestMemory = strconv .FormatInt (ovnControlPlaneMemoryRequest , 10 )
775+ }
776+
777+ socksProxyCPURequest , socksProxyMemoryRequest := getResourceRequestsForDeployment (controlPlaneClient .CRClient (), hc .Namespace , util .OVN_CONTROL_PLANE , "socks-proxy" )
778+ if socksProxyCPURequest > 0 {
779+ ovnHypershiftResult .Socks5ProxyResourceRequestCPU = strconv .FormatInt (socksProxyCPURequest , 10 )
780+ }
781+ if socksProxyMemoryRequest > 0 {
782+ ovnHypershiftResult .Socks5ProxyResourceRequestMemory = strconv .FormatInt (socksProxyMemoryRequest , 10 )
783+ }
784+
752785 return ovnHypershiftResult , nil
753786}
754787
788+ // getResourceRequestsForDeployment gets the cpu and memory resource requests for the specified deployment
789+ // If the deployment or container is not found, or if the container doesn't have a cpu or memory resource request, then 0 is returned
790+ func getResourceRequestsForDeployment (cl crclient.Reader , namespace string , deploymentName string , containerName string ) (cpu int64 , memory int64 ) {
791+ deployment := & appsv1.Deployment {}
792+ if err := cl .Get (context .TODO (), types.NamespacedName {
793+ Namespace : namespace ,
794+ Name : deploymentName ,
795+ }, deployment ); err != nil {
796+ if ! apierrors .IsNotFound (err ) {
797+ klog .Warningf ("Error fetching %s deployment: %v" , deploymentName , err )
798+ }
799+ return cpu , memory
800+ }
801+
802+ for _ , container := range deployment .Spec .Template .Spec .Containers {
803+ if container .Name == containerName {
804+ if container .Resources .Requests != nil {
805+ if ! container .Resources .Requests .Cpu ().IsZero () {
806+ cpu = container .Resources .Requests .Cpu ().MilliValue ()
807+ }
808+ if ! container .Resources .Requests .Memory ().IsZero () {
809+ memory = container .Resources .Requests .Memory ().Value () / bytesInMiB
810+ }
811+ }
812+ break
813+ }
814+ }
815+
816+ return cpu , memory
817+ }
818+
755819func getDisableUDPAggregation (cl crclient.Reader ) bool {
756820 disable := false
757821
0 commit comments