pod

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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

func StateChanged(old, new *corev1.Pod) bool

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL