4242)
4343
4444const (
45- MemoryAvailable = "memory.available"
46- NodeFSAvailable = "nodefs.available"
47-
4845 GiBMiBRatio = 1024
4946 MiBByteRatio = 1024 * 1024
5047 TerwayMinENIRequirements = 11
@@ -60,7 +57,7 @@ type ZoneData struct {
6057 Available bool
6158}
6259
63- func NewInstanceType (ctx context.Context ,
60+ func NewInstanceType (ctx context.Context , overhead corev1. ResourceList ,
6461 info * ecsclient.DescribeInstanceTypesResponseBodyInstanceTypesInstanceType ,
6562 kc * v1alpha1.KubeletConfiguration , region string , systemDisk * v1alpha1.SystemDisk ,
6663 offerings cloudprovider.Offerings , clusterCNI string ) * cloudprovider.InstanceType {
@@ -74,9 +71,10 @@ func NewInstanceType(ctx context.Context,
7471 Offerings : offerings ,
7572 Capacity : computeCapacity (ctx , info , kc .MaxPods , kc .PodsPerCore , systemDisk , clusterCNI ),
7673 Overhead : & cloudprovider.InstanceTypeOverhead {
77- KubeReserved : kubeReservedResources (kc .KubeReserved ),
78- SystemReserved : systemReservedResources (kc .SystemReserved ),
79- EvictionThreshold : evictionThreshold (memory (ctx , info ), ephemeralStorage (systemDisk ), kc .EvictionHard , kc .EvictionSoft ),
74+ // Follow overhead will be merged, so we can set only one overhead totally
75+ KubeReserved : overhead ,
76+ SystemReserved : corev1.ResourceList {},
77+ EvictionThreshold : corev1.ResourceList {},
8078 },
8179 }
8280 if it .Requirements .Compatible (scheduling .NewRequirements (scheduling .NewRequirement (corev1 .LabelOSStable , corev1 .NodeSelectorOpIn , string (corev1 .Windows )))) == nil {
@@ -178,62 +176,6 @@ func computeCapacity(ctx context.Context,
178176 return resourceList
179177}
180178
181- func kubeReservedResources (kubeReserved map [string ]string ) corev1.ResourceList {
182- resources := corev1.ResourceList {
183- // TODO: Following data is extract from real env
184- // Please check it more
185- corev1 .ResourceMemory : resource .MustParse ("447Mi" ),
186- corev1 .ResourceCPU : resource .MustParse ("35m" ),
187- }
188-
189- return lo .Assign (resources , lo .MapEntries (kubeReserved , func (k string , v string ) (corev1.ResourceName , resource.Quantity ) {
190- return corev1 .ResourceName (k ), resource .MustParse (v )
191- }))
192- }
193-
194- func systemReservedResources (systemReserved map [string ]string ) corev1.ResourceList {
195- resources := corev1.ResourceList {
196- // TODO: Following data is extract from real env
197- // Please check it more
198- corev1 .ResourceMemory : resource .MustParse ("447Mi" ),
199- corev1 .ResourceCPU : resource .MustParse ("35m" ),
200- }
201-
202- return lo .Assign (resources , lo .MapEntries (systemReserved , func (k string , v string ) (corev1.ResourceName , resource.Quantity ) {
203- return corev1 .ResourceName (k ), resource .MustParse (v )
204- }))
205- }
206-
207- func evictionThreshold (memory * resource.Quantity , storage * resource.Quantity , evictionHard map [string ]string , evictionSoft map [string ]string ) corev1.ResourceList {
208- overhead := corev1.ResourceList {
209- // TODO: Following data is extract from real env
210- // Please check it more
211- corev1 .ResourceMemory : resource .MustParse ("300Mi" ),
212- }
213-
214- override := corev1.ResourceList {}
215- var evictionSignals []map [string ]string
216- if evictionHard != nil {
217- evictionSignals = append (evictionSignals , evictionHard )
218- }
219- if evictionSoft != nil {
220- evictionSignals = append (evictionSignals , evictionSoft )
221- }
222-
223- for _ , m := range evictionSignals {
224- temp := corev1.ResourceList {}
225- if v , ok := m [MemoryAvailable ]; ok {
226- temp [corev1 .ResourceMemory ] = computeEvictionSignal (* memory , v )
227- }
228- if v , ok := m [NodeFSAvailable ]; ok {
229- temp [corev1 .ResourceEphemeralStorage ] = computeEvictionSignal (* storage , v )
230- }
231- override = resources .MaxResources (override , temp )
232- }
233- // Assign merges maps from left to right so overrides will always be taken last
234- return lo .Assign (overhead , override )
235- }
236-
237179// computeEvictionSignal computes the resource quantity value for an eviction signal value, computed off the
238180// base capacity value if the signal value is a percentage or as a resource quantity if the signal value isn't a percentage
239181func computeEvictionSignal (capacity resource.Quantity , signalValue string ) resource.Quantity {
0 commit comments