@@ -13,6 +13,7 @@ import (
1313 "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
1414
1515 clusterv1alpha1 "github.com/redhat-et/ipfs-operator/api/v1alpha1"
16+ "github.com/redhat-et/ipfs-operator/controllers/utils"
1617)
1718
1819// These declare constants for timeouts.
@@ -65,38 +66,7 @@ func (r *IpfsClusterReconciler) statefulSet(m *clusterv1alpha1.IpfsCluster,
6566) controllerutil.MutateFn {
6667 ssName := "ipfs-cluster-" + m .Name
6768
68- // Determine resource constraints from how much we are storing.
69- // for every TB of storage, Request 1GB of memory and limit if we exceed 2x this amount.
70- // memory floor is 2G.
71- // The CPU requirement starts at 4 cores and increases by 500m for every TB of storage
72- // many block storage providers have a maximum block storage of 16TB, so in this case, the
73- // biggest node we would allocate would request a minimum allocation of 16G of RAM and 12 cores
74- // and would permit usage up to twice this size
75-
76- ipfsStoragei64 , _ := m .Spec .IpfsStorage .AsInt64 ()
77- ipfsStorageTB := ipfsStoragei64 / 1024 / 1024 / 1024 / 1024
78- ipfsMilliCoresMin := 250 + (500 * ipfsStorageTB )
79- ipfsRAMGBMin := ipfsStorageTB
80- if ipfsRAMGBMin < 2 {
81- ipfsRAMGBMin = 2
82- }
83-
84- // ipfsRAMMinQuantity := resource.NewScaledQuantity(ipfsRAMGBMin, resource.Giga)
85- ipfsRAMMaxQuantity := resource .NewScaledQuantity (2 * ipfsRAMGBMin , resource .Giga )
86- // ipfsCoresMinQuantity := resource.NewScaledQuantity(ipfsMilliCoresMin, resource.Milli)
87- ipfsCoresMaxQuantity := resource .NewScaledQuantity (2 * ipfsMilliCoresMin , resource .Milli )
88-
89- ipfsResources := corev1.ResourceRequirements {
90- // Requests: corev1.ResourceList{
91- // corev1.ResourceMemory: *ipfsRAMMinQuantity,
92- // corev1.ResourceCPU: *ipfsCoresMinQuantity,
93- // },
94- Limits : corev1.ResourceList {
95- corev1 .ResourceMemory : * ipfsRAMMaxQuantity ,
96- corev1 .ResourceCPU : * ipfsCoresMaxQuantity ,
97- },
98- }
99-
69+ ipfsResources := utils .IPFSContainerResources (m .Spec .IpfsStorage .Value ())
10070 expected := & appsv1.StatefulSet {
10171 ObjectMeta : metav1.ObjectMeta {
10272 Name : ssName ,
0 commit comments