...

Source file src/k8s.io/kubernetes/pkg/kubelet/apis/podresources/types.go

Documentation: k8s.io/kubernetes/pkg/kubelet/apis/podresources

     1  /*
     2  Copyright 2020 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  //go:generate mockgen -source=types.go -destination=testing/provider_mock.go -package=testing DevicesProvider,PodsProvider,CPUsProvider,MemoryProvider
    18  package podresources
    19  
    20  import (
    21  	v1 "k8s.io/api/core/v1"
    22  	podresourcesapi "k8s.io/kubelet/pkg/apis/podresources/v1"
    23  )
    24  
    25  // DevicesProvider knows how to provide the devices used by the given container
    26  type DevicesProvider interface {
    27  	// UpdateAllocatedDevices frees any Devices that are bound to terminated pods.
    28  	UpdateAllocatedDevices()
    29  	// GetDevices returns information about the devices assigned to pods and containers
    30  	GetDevices(podUID, containerName string) []*podresourcesapi.ContainerDevices
    31  	// GetAllocatableDevices returns information about all the devices known to the manager
    32  	GetAllocatableDevices() []*podresourcesapi.ContainerDevices
    33  }
    34  
    35  // PodsProvider knows how to provide the pods admitted by the node
    36  type PodsProvider interface {
    37  	GetPods() []*v1.Pod
    38  	GetPodByName(namespace, name string) (*v1.Pod, bool)
    39  }
    40  
    41  // CPUsProvider knows how to provide the cpus used by the given container
    42  type CPUsProvider interface {
    43  	// GetCPUs returns information about the cpus assigned to pods and containers
    44  	GetCPUs(podUID, containerName string) []int64
    45  	// GetAllocatableCPUs returns the allocatable (not allocated) CPUs
    46  	GetAllocatableCPUs() []int64
    47  }
    48  
    49  type MemoryProvider interface {
    50  	// GetMemory returns information about the memory assigned to containers
    51  	GetMemory(podUID, containerName string) []*podresourcesapi.ContainerMemory
    52  	// GetAllocatableMemory returns the allocatable memory from the node
    53  	GetAllocatableMemory() []*podresourcesapi.ContainerMemory
    54  }
    55  
    56  type DynamicResourcesProvider interface {
    57  	// GetDynamicResources returns information about dynamic resources assigned to pods and containers
    58  	GetDynamicResources(pod *v1.Pod, container *v1.Container) []*podresourcesapi.DynamicResource
    59  }
    60  
    61  type PodResourcesProviders struct {
    62  	Pods             PodsProvider
    63  	Devices          DevicesProvider
    64  	Cpus             CPUsProvider
    65  	Memory           MemoryProvider
    66  	DynamicResources DynamicResourcesProvider
    67  }
    68  

View as plain text