topology_manager.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. Copyright 2019 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package topologymanager
  14. import (
  15. "k8s.io/api/core/v1"
  16. "k8s.io/kubernetes/pkg/kubelet/cm/topologymanager/socketmask"
  17. "k8s.io/kubernetes/pkg/kubelet/lifecycle"
  18. )
  19. //Manager interface provides methods for Kubelet to manage pod topology hints
  20. type Manager interface {
  21. //Manager implements pod admit handler interface
  22. lifecycle.PodAdmitHandler
  23. //Adds a hint provider to manager to indicate the hint provider
  24. //wants to be consoluted when making topology hints
  25. AddHintProvider(HintProvider)
  26. //Adds pod to Manager for tracking
  27. AddContainer(pod *v1.Pod, containerID string) error
  28. //Removes pod from Manager tracking
  29. RemoveContainer(containerID string) error
  30. //Interface for storing pod topology hints
  31. Store
  32. }
  33. //HintProvider interface is to be implemented by Hint Providers
  34. type HintProvider interface {
  35. GetTopologyHints(pod v1.Pod, container v1.Container) []TopologyHint
  36. }
  37. //Store interface is to allow Hint Providers to retrieve pod affinity
  38. type Store interface {
  39. GetAffinity(podUID string, containerName string) TopologyHint
  40. }
  41. //TopologyHint is a struct containing a SocketMask for a Container
  42. type TopologyHint struct {
  43. SocketAffinity socketmask.SocketMask
  44. // Preferred is set to true when the SocketMask encodes a preferred
  45. // allocation for the Container. It is set to false otherwise.
  46. Preferred bool
  47. }