Documentation
¶
Index ¶
- Constants
- Variables
- func AddWatcherDynamically(c controller.Controller, h handler.EventHandler, gvk schema.GroupVersionKind) (bool, error)
- func AddWorkloadWatcher(c controller.Controller, handler handler.EventHandler) error
- func CalculateNewBatchTarget(rolloutSpec *v1alpha1.ReleasePlan, workloadReplicas, currentBatch int) int
- func ClaimWorkload(c client.Client, planController *v1alpha1.BatchRelease, object client.Object, ...) error
- func ComputeHash(template *v1.PodTemplateSpec, collisionCount *int32) string
- func DeepHashObject(hasher hash.Hash, objectToWrite interface{})
- func DiscoverGVK(gvk schema.GroupVersionKind) bool
- func DumpJSON(o interface{}) string
- func EqualIgnoreHash(template1, template2 *v1.PodTemplateSpec) bool
- func FilterActiveDeployment(ds []*apps.Deployment) []*apps.Deployment
- func FilterActivePods(pods []*v1.Pod) []*v1.Pod
- func GenRandomStr(length int) string
- func GetEmptyWorkloadObject(gvk schema.GroupVersionKind) client.Object
- func GetGVKFrom(workloadRef *rolloutv1alpha1.WorkloadRef) schema.GroupVersionKind
- func GetOwnerWorkload(r client.Reader, object client.Object) (client.Object, error)
- func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)
- func GetPodConditionFromList(conditions []v1.PodCondition, conditionType v1.PodConditionType) (int, *v1.PodCondition)
- func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition
- func GetRolloutCondition(status rolloutv1alpha1.RolloutStatus, ...) *rolloutv1alpha1.RolloutCondition
- func GetStatefulSetMaxUnavailable(object *unstructured.Unstructured) *intstr.IntOrString
- func GetStatefulSetPartition(object *unstructured.Unstructured) int32
- func HashReleasePlanBatches(releasePlan *v1alpha1.ReleasePlan) string
- func IsCompletedPod(pod *v1.Pod) bool
- func IsConsistentWithRevision(pod *v1.Pod, revision string) bool
- func IsOwnedBy(r client.Reader, child, parent client.Object) (bool, error)
- func IsPodReady(pod *v1.Pod) bool
- func IsPodReadyConditionTrue(status v1.PodStatus) bool
- func IsStatefulSetRollingUpdate(object *unstructured.Unstructured) bool
- func IsSupportedWorkload(gvk schema.GroupVersionKind) bool
- func IsWorkloadType(object client.Object, t WorkloadType) bool
- func ListOwnedPods(c client.Client, object client.Object) ([]*v1.Pod, error)
- func NewRolloutCondition(condType rolloutv1alpha1.RolloutConditionType, status corev1.ConditionStatus, ...) *rolloutv1alpha1.RolloutCondition
- func ParseReplicasFrom(object *unstructured.Unstructured) int32
- func ParseStatusIntFrom(object *unstructured.Unstructured, field string) int64
- func ParseStatusStringFrom(object *unstructured.Unstructured, field string) string
- func ParseTemplateFrom(object *unstructured.Unstructured) *v1.PodTemplateSpec
- func PatchPodBatchLabel(c client.Client, pods []*v1.Pod, rolloutID string, batchID int32, ...) (bool, error)
- func PatchSpec(c client.Client, object client.Object, spec map[string]interface{}) error
- func ReleaseWorkload(c client.Client, object client.Object) error
- func RemoveRolloutCondition(status *rolloutv1alpha1.RolloutStatus, ...)
- func SafeEncodeString(s string) string
- func SetRolloutCondition(status *rolloutv1alpha1.RolloutStatus, ...) bool
- func SetStatefulSetPartition(object *unstructured.Unstructured, partition int32)
- func UpdateFinalizer(c client.Client, object client.Object, op FinalizerOpType, finalizer string) error
- type ControllerFinder
- type ControllerFinderFunc
- type FinalizerOpType
- type RolloutState
- type Workload
- type WorkloadInfo
- type WorkloadStatus
- type WorkloadType
Constants ¶
const ( // InRolloutProgressingAnnotation marks workload as entering the rollout progressing process //and does not allow paused=false during this process InRolloutProgressingAnnotation = "rollouts.kruise.io/in-progressing" // finalizer KruiseRolloutFinalizer = "rollouts.kruise.io/rollout" // rollout spec hash RolloutHashAnnotation = "rollouts.kruise.io/hash" // RolloutIDLabel is designed to distinguish each workload revision publications. // The value of RolloutIDLabel corresponds Rollout.Spec.RolloutID. RolloutIDLabel = "apps.kruise.io/rollout-id" // RolloutBatchIDLabel is the label key of batch id that will be patched to pods during rollout. // Only when RolloutIDLabel is set, RolloutBatchIDLabel will be patched. // Users can use RolloutIDLabel and RolloutBatchIDLabel to select the pods that are upgraded in some certain batch and release. RolloutBatchIDLabel = "apps.kruise.io/rollout-batch-id" WorkloadTypeLabel = "rollouts.kruise.io/workload-type" )
const ( // BatchReleaseControlAnnotation is controller info about batchRelease when rollout BatchReleaseControlAnnotation = "batchrelease.rollouts.kruise.io/control-info" // CanaryDeploymentLabel is to label canary deployment that is created by batchRelease controller CanaryDeploymentLabel = "rollouts.kruise.io/canary-deployment" // CanaryDeploymentFinalizer is a finalizer to resources patched by batchRelease controller CanaryDeploymentFinalizer = "finalizer.rollouts.kruise.io/batch-release" )
Variables ¶
var ( ControllerKindRS = apps.SchemeGroupVersion.WithKind("ReplicaSet") ControllerKindDep = apps.SchemeGroupVersion.WithKind("Deployment") ControllerKindSts = apps.SchemeGroupVersion.WithKind("StatefulSet") ControllerKruiseKindCS = appsv1alpha1.SchemeGroupVersion.WithKind("CloneSet") ControllerKruiseKindSts = appsv1beta1.SchemeGroupVersion.WithKind("StatefulSet") ControllerKruiseOldKindSts = appsv1alpha1.SchemeGroupVersion.WithKind("StatefulSet") )
Functions ¶
func AddWatcherDynamically ¶ added in v0.2.0
func AddWatcherDynamically(c controller.Controller, h handler.EventHandler, gvk schema.GroupVersionKind) (bool, error)
func AddWorkloadWatcher ¶ added in v0.2.0
func AddWorkloadWatcher(c controller.Controller, handler handler.EventHandler) error
func CalculateNewBatchTarget ¶
func CalculateNewBatchTarget(rolloutSpec *v1alpha1.ReleasePlan, workloadReplicas, currentBatch int) int
func ClaimWorkload ¶ added in v0.2.0
func ComputeHash ¶
func ComputeHash(template *v1.PodTemplateSpec, collisionCount *int32) string
ComputeHash returns a hash value calculated from pod template and a collisionCount to avoid hash collision. The hash will be safe encoded to avoid bad words.
func DeepHashObject ¶
DeepHashObject writes specified object to hash using the spew library which follows pointers and prints actual values of the nested objects ensuring the hash does not change when a pointer changes.
func DiscoverGVK ¶
func DiscoverGVK(gvk schema.GroupVersionKind) bool
func EqualIgnoreHash ¶
func EqualIgnoreHash(template1, template2 *v1.PodTemplateSpec) bool
func FilterActiveDeployment ¶
func FilterActiveDeployment(ds []*apps.Deployment) []*apps.Deployment
func GenRandomStr ¶
func GetEmptyWorkloadObject ¶ added in v0.2.0
func GetEmptyWorkloadObject(gvk schema.GroupVersionKind) client.Object
func GetGVKFrom ¶ added in v0.2.0
func GetGVKFrom(workloadRef *rolloutv1alpha1.WorkloadRef) schema.GroupVersionKind
func GetOwnerWorkload ¶ added in v0.2.0
GetOwnerWorkload return the top-level workload that is controlled by rollout, if the object has no owner, just return nil
func GetPodCondition ¶ added in v0.2.0
func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)
GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.
func GetPodConditionFromList ¶ added in v0.2.0
func GetPodConditionFromList(conditions []v1.PodCondition, conditionType v1.PodConditionType) (int, *v1.PodCondition)
GetPodConditionFromList extracts the provided condition from the given list of condition and returns the index of the condition and the condition. Returns -1 and nil if the condition is not present.
func GetPodReadyCondition ¶ added in v0.2.0
func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition
GetPodReadyCondition extracts the pod ready condition from the given status and returns that. Returns nil if the condition is not present.
func GetRolloutCondition ¶
func GetRolloutCondition(status rolloutv1alpha1.RolloutStatus, condType rolloutv1alpha1.RolloutConditionType) *rolloutv1alpha1.RolloutCondition
GetRolloutCondition returns the condition with the provided type.
func GetStatefulSetMaxUnavailable ¶ added in v0.2.0
func GetStatefulSetMaxUnavailable(object *unstructured.Unstructured) *intstr.IntOrString
func GetStatefulSetPartition ¶ added in v0.2.0
func GetStatefulSetPartition(object *unstructured.Unstructured) int32
func HashReleasePlanBatches ¶
func HashReleasePlanBatches(releasePlan *v1alpha1.ReleasePlan) string
func IsCompletedPod ¶ added in v0.2.0
func IsConsistentWithRevision ¶ added in v0.2.0
func IsOwnedBy ¶ added in v0.2.0
IsOwnedBy will return true if the child is owned by parent directly or indirectly.
func IsPodReady ¶ added in v0.2.0
IsPodReady returns true if a pod is ready; false otherwise.
func IsPodReadyConditionTrue ¶ added in v0.2.0
IsPodReadyConditionTrue returns true if a pod is ready; false otherwise.
func IsStatefulSetRollingUpdate ¶ added in v0.2.0
func IsStatefulSetRollingUpdate(object *unstructured.Unstructured) bool
func IsSupportedWorkload ¶ added in v0.2.0
func IsSupportedWorkload(gvk schema.GroupVersionKind) bool
func IsWorkloadType ¶ added in v0.2.0
func IsWorkloadType(object client.Object, t WorkloadType) bool
func ListOwnedPods ¶ added in v0.2.0
func NewRolloutCondition ¶
func NewRolloutCondition(condType rolloutv1alpha1.RolloutConditionType, status corev1.ConditionStatus, reason, message string) *rolloutv1alpha1.RolloutCondition
NewRolloutCondition creates a new rollout condition.
func ParseReplicasFrom ¶ added in v0.2.0
func ParseReplicasFrom(object *unstructured.Unstructured) int32
ParseReplicasFrom parses replicas from unstructured workload object
func ParseStatusIntFrom ¶ added in v0.2.0
func ParseStatusIntFrom(object *unstructured.Unstructured, field string) int64
ParseStatusIntFrom can parse some fields with int type from unstructured workload object status
func ParseStatusStringFrom ¶ added in v0.2.0
func ParseStatusStringFrom(object *unstructured.Unstructured, field string) string
ParseStatusStringFrom can parse some fields with string type from unstructured workload object status
func ParseTemplateFrom ¶ added in v0.2.0
func ParseTemplateFrom(object *unstructured.Unstructured) *v1.PodTemplateSpec
ParseTemplateFrom parses template from unstructured workload object
func PatchPodBatchLabel ¶ added in v0.2.0
func ReleaseWorkload ¶ added in v0.2.0
func RemoveRolloutCondition ¶
func RemoveRolloutCondition(status *rolloutv1alpha1.RolloutStatus, condType rolloutv1alpha1.RolloutConditionType)
RemoveRolloutCondition removes the rollout condition with the provided type.
func SafeEncodeString ¶
SafeEncodeString encodes s using the same characters as rand.String. This reduces the chances of bad words and ensures that strings generated from hash functions appear consistent throughout the API.
func SetRolloutCondition ¶
func SetRolloutCondition(status *rolloutv1alpha1.RolloutStatus, condition rolloutv1alpha1.RolloutCondition) bool
SetRolloutCondition updates the rollout to include the provided condition. If the condition that we are about to add already exists and has the same status and reason, then we are not going to update by returning false. Returns true if the condition was updated
func SetStatefulSetPartition ¶ added in v0.2.0
func SetStatefulSetPartition(object *unstructured.Unstructured, partition int32)
func UpdateFinalizer ¶
Types ¶
type ControllerFinder ¶
func NewControllerFinder ¶
func NewControllerFinder(c client.Client) *ControllerFinder
func (*ControllerFinder) GetReplicaSetsForDeployment ¶
func (r *ControllerFinder) GetReplicaSetsForDeployment(obj *apps.Deployment) ([]apps.ReplicaSet, error)
func (*ControllerFinder) GetWorkloadForRef ¶
func (r *ControllerFinder) GetWorkloadForRef(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*Workload, error)
type ControllerFinderFunc ¶
type ControllerFinderFunc func(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*Workload, error)
ControllerFinderFunc is a function type that maps a pod to a list of controllers and their scale.
type FinalizerOpType ¶
type FinalizerOpType string
const ( AddFinalizerOpType FinalizerOpType = "Add" RemoveFinalizerOpType FinalizerOpType = "Remove" )
type RolloutState ¶
type RolloutState struct {
RolloutName string `json:"rolloutName"`
}
RolloutState is annotation[rollouts.kruise.io/in-progressing] value
func GetRolloutState ¶
func GetRolloutState(annotations map[string]string) (*RolloutState, error)
type Workload ¶
type Workload struct {
metav1.ObjectMeta
// replicas
Replicas int32
// stable revision
StableRevision string
// canary revision
CanaryRevision string
// pod template hash is used as service selector hash
PodTemplateHash string
// canary replicas
CanaryReplicas int32
// canary ready replicas
CanaryReadyReplicas int32
// Revision hash key
RevisionLabelKey string
// Is it in rollback phase
IsInRollback bool
// indicate whether the workload can enter the rollout process
// 1. workload.Spec.Paused = true
// 2. the Deployment is not in a stable version (only one version of RS)
InRolloutProgressing bool
// whether the status consistent with the spec
// workload.generation == status.observedGeneration
IsStatusConsistent bool
}
Workload is used to return (controller, scale, selector) fields from the controller finder functions.
type WorkloadInfo ¶ added in v0.2.0
type WorkloadInfo struct {
Paused bool
Replicas *int32
GVKWithName string
Selector labels.Selector
Metadata *metav1.ObjectMeta
Status *WorkloadStatus
}
func NewWorkloadInfo ¶ added in v0.2.0
func NewWorkloadInfo() *WorkloadInfo
func ParseStatefulSetInfo ¶ added in v0.2.0
func ParseStatefulSetInfo(object *unstructured.Unstructured, namespacedName types.NamespacedName) *WorkloadInfo
type WorkloadStatus ¶ added in v0.2.0
type WorkloadStatus struct {
Replicas int32
ReadyReplicas int32
UpdatedReplicas int32
UpdatedReadyReplicas int32
AvailableReplicas int32
ObservedGeneration int64
UpdateRevision string
StableRevision string
}
func ParseWorkloadStatus ¶ added in v0.2.0
func ParseWorkloadStatus(object client.Object) *WorkloadStatus
type WorkloadType ¶ added in v0.2.0
type WorkloadType string
const ( StatefulSetType WorkloadType = "statefulset" DeploymentType WorkloadType = "deployment" CloneSetType WorkloadType = "cloneset" )