pub

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

+k8s:openapi-gen=true +kubebuilder:object:generate=true

Index

Constants

View Source
const (
	// InPlaceUpdateReady must be added into template.spec.readinessGates when pod podUpdatePolicy
	// is InPlaceIfPossible or InPlaceOnly. The condition in podStatus will be updated to False before in-place
	// updating and updated to True after the update is finished. This ensures pod to remain at NotReady state while
	// in-place update is happening.
	InPlaceUpdateReady v1.PodConditionType = "InPlaceUpdateReady"

	// InPlaceUpdateStateKey records the state of inplace-update.
	// The value of annotation is InPlaceUpdateState.
	InPlaceUpdateStateKey string = "apps.kruise.io/inplace-update-state"
	// TODO: will be removed since v1.0.0
	InPlaceUpdateStateKeyOld string = "inplace-update-state"

	// InPlaceUpdateGraceKey records the spec that Pod should be updated when
	// grace period ends.
	InPlaceUpdateGraceKey string = "apps.kruise.io/inplace-update-grace"
	// TODO: will be removed since v1.0.0
	InPlaceUpdateGraceKeyOld string = "inplace-update-grace"

	// RuntimeContainerMetaKey is a key in pod annotations. Kruise-daemon should report the
	// states of runtime containers into its value, which is a structure JSON of RuntimeContainerMetaSet type.
	RuntimeContainerMetaKey = "apps.kruise.io/runtime-containers-meta"
)
View Source
const (
	// ContainerLaunchPriorityEnvName is the env name that users have to define in pod container
	// to identity the launch priority of this container.
	ContainerLaunchPriorityEnvName = "KRUISE_CONTAINER_PRIORITY"
	// ContainerLaunchBarrierEnvName is the env name that Kruise webhook will inject into containers
	// if the pod have configured launch priority.
	ContainerLaunchBarrierEnvName = "KRUISE_CONTAINER_BARRIER"

	// ContainerLaunchPriorityKey is the annotation key that users could define in pod annotation
	// to make containers in pod launched by ordinal.
	ContainerLaunchPriorityKey = "apps.kruise.io/container-launch-priority"
	// ContainerLaunchOrdered is the annotation value that indicates containers in pod should be launched by ordinal.
	ContainerLaunchOrdered = "Ordered"
)
View Source
const (
	// KruisePodReadyConditionType can support multiple writers, such as:
	// - ContainerRecreateRequest;
	// - Workload controller, including CloneSet, Advanced StatefulSet, Advanced Daemonset.
	//
	// If its corresponding condition status was set to "False" by multiple writers,
	// the condition status will be considered as "True" only when all these writers
	// set it to "True".
	KruisePodReadyConditionType v1.PodConditionType = "KruisePodReady"
)
View Source
const (
	// PubUnavailablePodLabelPrefix indicates if the pod has this label, both kruise workload and
	// pub will determine that the pod is unavailable, even if pod.status.ready=true.
	// Main users non-destructive offline and other scenarios
	PubUnavailablePodLabelPrefix = "unavailable-pod.kruise.io/"
)

Variables

This section is empty.

Functions

func GetInPlaceUpdateGrace

func GetInPlaceUpdateGrace(obj metav1.Object) (string, bool)

func GetInPlaceUpdateState

func GetInPlaceUpdateState(obj metav1.Object) (string, bool)

func HasUnavailableLabel

func HasUnavailableLabel(labels map[string]string) bool

func RemoveInPlaceUpdateGrace

func RemoveInPlaceUpdateGrace(obj metav1.Object)

Types

type InPlaceUpdateContainerBatch

type InPlaceUpdateContainerBatch struct {
	// Timestamp is the time for this update batch
	Timestamp metav1.Time `json:"timestamp"`
	// Containers is the name list of containers for this update batch
	Containers []string `json:"containers"`
}

InPlaceUpdateContainerBatch indicates the timestamp and containers for a batch update

func (*InPlaceUpdateContainerBatch) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InPlaceUpdateContainerBatch.

func (*InPlaceUpdateContainerBatch) DeepCopyInto

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type InPlaceUpdateContainerStatus

type InPlaceUpdateContainerStatus struct {
	ImageID string `json:"imageID,omitempty"`
}

InPlaceUpdateContainerStatus records the statuses of the container that are mainly used to determine whether the InPlaceUpdate is completed.

func (*InPlaceUpdateContainerStatus) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InPlaceUpdateContainerStatus.

func (*InPlaceUpdateContainerStatus) DeepCopyInto

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type InPlaceUpdatePreCheckBeforeNext

type InPlaceUpdatePreCheckBeforeNext struct {
	ContainersRequiredReady []string `json:"containersRequiredReady,omitempty"`
}

InPlaceUpdatePreCheckBeforeNext contains the pre-check that must pass before the next containers can be in-place update.

func (*InPlaceUpdatePreCheckBeforeNext) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InPlaceUpdatePreCheckBeforeNext.

func (*InPlaceUpdatePreCheckBeforeNext) DeepCopyInto

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type InPlaceUpdateState

type InPlaceUpdateState struct {
	// Revision is the updated revision hash.
	Revision string `json:"revision"`

	// UpdateTimestamp is the start time when the in-place update happens.
	UpdateTimestamp metav1.Time `json:"updateTimestamp"`

	// LastContainerStatuses records the before-in-place-update container statuses. It is a map from ContainerName
	// to InPlaceUpdateContainerStatus
	LastContainerStatuses map[string]InPlaceUpdateContainerStatus `json:"lastContainerStatuses"`

	// UpdateEnvFromMetadata indicates there are envs from annotations/labels that should be in-place update.
	UpdateEnvFromMetadata bool `json:"updateEnvFromMetadata,omitempty"`

	// NextContainerImages is the containers with lower priority that waiting for in-place update images in next batch.
	NextContainerImages map[string]string `json:"nextContainerImages,omitempty"`

	// NextContainerRefMetadata is the containers with lower priority that waiting for in-place update labels/annotations in next batch.
	NextContainerRefMetadata map[string]metav1.ObjectMeta `json:"nextContainerRefMetadata,omitempty"`

	// PreCheckBeforeNext is the pre-check that must pass before the next containers can be in-place update.
	PreCheckBeforeNext *InPlaceUpdatePreCheckBeforeNext `json:"preCheckBeforeNext,omitempty"`

	// ContainerBatchesRecord records the update batches that have patched in this revision.
	ContainerBatchesRecord []InPlaceUpdateContainerBatch `json:"containerBatchesRecord,omitempty"`
}

InPlaceUpdateState records latest inplace-update state, including old statuses of containers.

func (*InPlaceUpdateState) DeepCopy

func (in *InPlaceUpdateState) DeepCopy() *InPlaceUpdateState

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InPlaceUpdateState.

func (*InPlaceUpdateState) DeepCopyInto

func (in *InPlaceUpdateState) DeepCopyInto(out *InPlaceUpdateState)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type InPlaceUpdateStrategy

type InPlaceUpdateStrategy struct {
	// GracePeriodSeconds is the timespan between set Pod status to not-ready and update images in Pod spec
	// when in-place update a Pod.
	GracePeriodSeconds int32 `json:"gracePeriodSeconds,omitempty"`
}

InPlaceUpdateStrategy defines the strategies for in-place update.

func (*InPlaceUpdateStrategy) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InPlaceUpdateStrategy.

func (*InPlaceUpdateStrategy) DeepCopyInto

func (in *InPlaceUpdateStrategy) DeepCopyInto(out *InPlaceUpdateStrategy)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Lifecycle

type Lifecycle struct {
	// PreDelete is the hook before Pod to be deleted.
	PreDelete *LifecycleHook `json:"preDelete,omitempty"`
	// InPlaceUpdate is the hook before Pod to update and after Pod has been updated.
	InPlaceUpdate *LifecycleHook `json:"inPlaceUpdate,omitempty"`
	// PreNormal is the hook after Pod to be created and ready to be Normal.
	PreNormal *LifecycleHook `json:"preNormal,omitempty"`
}

Lifecycle contains the hooks for Pod lifecycle.

func (*Lifecycle) DeepCopy

func (in *Lifecycle) DeepCopy() *Lifecycle

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Lifecycle.

func (*Lifecycle) DeepCopyInto

func (in *Lifecycle) DeepCopyInto(out *Lifecycle)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type LifecycleHook

type LifecycleHook struct {
	LabelsHandler     map[string]string `json:"labelsHandler,omitempty"`
	FinalizersHandler []string          `json:"finalizersHandler,omitempty"`
	// MarkPodNotReady = true means:
	// - Pod will be set to 'NotReady' at preparingDelete/preparingUpdate state.
	// - Pod will be restored to 'Ready' at Updated state if it was set to 'NotReady' at preparingUpdate state.
	// Currently, MarkPodNotReady only takes effect on InPlaceUpdate & PreDelete hook.
	// Default to false.
	MarkPodNotReady bool `json:"markPodNotReady,omitempty"`
}

func (*LifecycleHook) DeepCopy

func (in *LifecycleHook) DeepCopy() *LifecycleHook

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LifecycleHook.

func (*LifecycleHook) DeepCopyInto

func (in *LifecycleHook) DeepCopyInto(out *LifecycleHook)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type LifecycleStateType

type LifecycleStateType string
const (
	LifecycleStateKey     = "lifecycle.apps.kruise.io/state"
	LifecycleTimestampKey = "lifecycle.apps.kruise.io/timestamp"

	// LifecycleStatePreparingNormal means the Pod is created but unavailable.
	// It will translate to Normal state if Lifecycle.PreNormal is hooked.
	LifecycleStatePreparingNormal LifecycleStateType = "PreparingNormal"
	// LifecycleStateNormal is a necessary condition for Pod to be available.
	LifecycleStateNormal LifecycleStateType = "Normal"
	// LifecycleStatePreparingUpdate means pod is being prepared to update.
	// It will translate to Updating state if Lifecycle.InPlaceUpdate is Not hooked.
	LifecycleStatePreparingUpdate LifecycleStateType = "PreparingUpdate"
	// LifecycleStateUpdating means the Pod is being updated.
	// It will translate to Updated state if the in-place update of the Pod is done.
	LifecycleStateUpdating LifecycleStateType = "Updating"
	// LifecycleStateUpdated means the Pod is updated, but unavailable.
	// It will translate to Normal state if Lifecycle.InPlaceUpdate is hooked.
	LifecycleStateUpdated LifecycleStateType = "Updated"
	// LifecycleStatePreparingDelete means the Pod is prepared to delete.
	// The Pod will be deleted by workload if Lifecycle.PreDelete is Not hooked.
	LifecycleStatePreparingDelete LifecycleStateType = "PreparingDelete"
)

type RuntimeContainerHashes

type RuntimeContainerHashes struct {
	// PlainHash is the hash that directly calculated from pod.spec.container[x].
	// Usually it is calculated by Kubelet and will be in annotation of each runtime container.
	PlainHash uint64 `json:"plainHash"`
	// ExtractedEnvFromMetadataHash is the hash that calculated from pod.spec.container[x],
	// whose envs from annotations/labels have already been extracted to the real values.
	ExtractedEnvFromMetadataHash uint64 `json:"extractedEnvFromMetadataHash,omitempty"`
}

RuntimeContainerHashes contains the hashes of such container.

func (*RuntimeContainerHashes) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuntimeContainerHashes.

func (*RuntimeContainerHashes) DeepCopyInto

func (in *RuntimeContainerHashes) DeepCopyInto(out *RuntimeContainerHashes)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type RuntimeContainerMeta

type RuntimeContainerMeta struct {
	Name         string                 `json:"name"`
	ContainerID  string                 `json:"containerID"`
	RestartCount int32                  `json:"restartCount"`
	Hashes       RuntimeContainerHashes `json:"hashes"`
}

RuntimeContainerMeta contains the meta data of a runtime container.

func (*RuntimeContainerMeta) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuntimeContainerMeta.

func (*RuntimeContainerMeta) DeepCopyInto

func (in *RuntimeContainerMeta) DeepCopyInto(out *RuntimeContainerMeta)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type RuntimeContainerMetaSet

type RuntimeContainerMetaSet struct {
	Containers []RuntimeContainerMeta `json:"containers"`
}

RuntimeContainerMetaSet contains all the containers' meta of the Pod.

func GetRuntimeContainerMetaSet

func GetRuntimeContainerMetaSet(obj metav1.Object) (*RuntimeContainerMetaSet, error)

func (*RuntimeContainerMetaSet) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuntimeContainerMetaSet.

func (*RuntimeContainerMetaSet) DeepCopyInto

func (in *RuntimeContainerMetaSet) DeepCopyInto(out *RuntimeContainerMetaSet)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type UpdatePriorityOrderTerm

type UpdatePriorityOrderTerm struct {
	// Calculate priority by value of this key.
	// Values of this key, will be sorted by GetInt(val). GetInt method will find the last int in value,
	// such as getting 5 in value '5', getting 10 in value 'sts-10'.
	OrderedKey string `json:"orderedKey"`
}

UpdatePriorityOrderTerm defines order priority.

func (*UpdatePriorityOrderTerm) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdatePriorityOrderTerm.

func (*UpdatePriorityOrderTerm) DeepCopyInto

func (in *UpdatePriorityOrderTerm) DeepCopyInto(out *UpdatePriorityOrderTerm)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type UpdatePriorityStrategy

type UpdatePriorityStrategy struct {
	// Order priority terms, pods will be sorted by the value of orderedKey.
	// For example:
	// “`
	// orderPriority:
	// - orderedKey: key1
	// - orderedKey: key2
	// “`
	// First, all pods which have key1 in labels will be sorted by the value of key1.
	// Then, the left pods which have no key1 but have key2 in labels will be sorted by
	// the value of key2 and put behind those pods have key1.
	OrderPriority []UpdatePriorityOrderTerm `json:"orderPriority,omitempty"`
	// Weight priority terms, pods will be sorted by the sum of all terms weight.
	WeightPriority []UpdatePriorityWeightTerm `json:"weightPriority,omitempty"`
}

UpdatePriorityStrategy is the strategy to define priority for pods update. Only one of orderPriority and weightPriority can be set.

func (*UpdatePriorityStrategy) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdatePriorityStrategy.

func (*UpdatePriorityStrategy) DeepCopyInto

func (in *UpdatePriorityStrategy) DeepCopyInto(out *UpdatePriorityStrategy)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*UpdatePriorityStrategy) FieldsValidation

func (strategy *UpdatePriorityStrategy) FieldsValidation() error

FieldsValidation checks invalid fields in UpdatePriorityStrategy.

type UpdatePriorityWeightTerm

type UpdatePriorityWeightTerm struct {
	// Weight associated with matching the corresponding matchExpressions, in the range 1-100.
	Weight int32 `json:"weight"`
	// MatchSelector is used to select by pod's labels.
	MatchSelector metav1.LabelSelector `json:"matchSelector"`
}

UpdatePriorityWeightTerm defines weight priority.

func (*UpdatePriorityWeightTerm) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdatePriorityWeightTerm.

func (*UpdatePriorityWeightTerm) DeepCopyInto

func (in *UpdatePriorityWeightTerm) DeepCopyInto(out *UpdatePriorityWeightTerm)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

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