Documentation ¶
Index ¶
- Constants
- func FilterAndClassifyByRunningState(pods []corev1.Pod) (result map[autoscalingv1alpha1.PodState][]*corev1.Pod, total int)
- func GetState(pod *corev1.Pod) autoscalingv1alpha1.PodState
- func SetState(pod *corev1.Pod, state autoscalingv1alpha1.PodState)
- func StateChanged(old, new *corev1.Pod) bool
- type StateChange
- type StateManager
Constants ¶
View Source
const (
LabelState = "kapacitystack.io/pod-state"
)
Variables ¶
This section is empty.
Functions ¶
func FilterAndClassifyByRunningState ¶
func FilterAndClassifyByRunningState(pods []corev1.Pod) (result map[autoscalingv1alpha1.PodState][]*corev1.Pod, total int)
FilterAndClassifyByRunningState filter and classify given pods by their running states. It returns the classified result and the total number of running pods.
func GetState ¶
func GetState(pod *corev1.Pod) autoscalingv1alpha1.PodState
GetState get the current State of pod.
func SetState ¶
func SetState(pod *corev1.Pod, state autoscalingv1alpha1.PodState)
SetState set State to pod.
func StateChanged ¶
StateChanged reports whether the given pod's state has changed.
Types ¶
type StateChange ¶
type StateChange struct { Online []*corev1.Pod Cutoff []*corev1.Pod Standby []*corev1.Pod Delete []*corev1.Pod }
StateChange tells which pods should be changed to which State.
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager provides a method to calculate pod state change.
func NewStateManager ¶
func NewStateManager(rp *autoscalingv1alpha1.ReplicaProfile, sorter sorter.Interface, currentRunningPods map[autoscalingv1alpha1.PodState][]*corev1.Pod) *StateManager
NewStateManager build a state manager to calculate pod state change based on given spec and status.
func (*StateManager) CalculateStateChange ¶
func (sm *StateManager) CalculateStateChange(ctx context.Context) (*StateChange, error)
CalculateStateChange calculate pod state change based on the spec and status info in StateManager. State transitions are shown as below:
delete pods +-----------------------------------------------------------------------------------------------------+ | | | | | turn off traffic +-----------------+ | | +-----------------------------------> | delete pods | | | | cutoff +----------------------------+ | | | +--------------------------------+ | | | | | | turn on traffic +--------+--------+ | | | | | | | | +---+-------+--v-+ | +---v----------v---+ | | | | | | online | | swap out memory | deleted | +---+-------^----+ | +---^----------+---+ | | | | | | | swap in memory +---------v---------+ | | | | turn on traffic | | | | | +----------------------------------| standby | | | | | +---------------------------+ | | +-------------------+ delete pods | | | +-----------------------------------------------------------------------------------------------------+ create new pods
Click to show internal directories.
Click to hide internal directories.