Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateNewBatchTarget(rolloutSpec *v1alpha1.ReleasePlan, workloadReplicas, currentBatch int) int
- 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 GenRandomStr(length int) string
- func GetRolloutCondition(status rolloutv1alpha1.RolloutStatus, ...) *rolloutv1alpha1.RolloutCondition
- func HashReleasePlanBatches(releasePlan *v1alpha1.ReleasePlan) string
- func IsControlledBy(object, owner metav1.Object) bool
- func NewRegistry(c *rest.Config) error
- func NewRolloutCondition(condType rolloutv1alpha1.RolloutConditionType, status corev1.ConditionStatus, ...) *rolloutv1alpha1.RolloutCondition
- func RemoveRolloutCondition(status *rolloutv1alpha1.RolloutStatus, ...)
- func SafeEncodeString(s string) string
- func SetRolloutCondition(status *rolloutv1alpha1.RolloutStatus, ...) bool
- func UpdateFinalizer(c client.Client, object client.Object, op FinalizerOpType, finalizer string) error
- type ControllerFinder
- type ControllerFinderFunc
- type FinalizerOpType
- type GenericClientset
- type RolloutState
- type Workload
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" )
const ( CanaryDeploymentLabel = "rollouts.kruise.io/canary-deployment" BatchReleaseControlAnnotation = "batchrelease.rollouts.kruise.io/control-info" StashCloneSetPartition = "batchrelease.rollouts.kruise.io/stash-partition" CanaryDeploymentLabelKey = "rollouts.kruise.io/canary-deployment" CanaryDeploymentFinalizer = "finalizer.rollouts.kruise.io/batch-release" )
Variables ¶
var ( ControllerKindDep = apps.SchemeGroupVersion.WithKind("Deployment") ControllerKruiseKindCS = appsv1alpha1.SchemeGroupVersion.WithKind("CloneSet") )
var (
CloneSetGVK = appsv1alpha1.SchemeGroupVersion.WithKind("CloneSet")
)
Functions ¶
func CalculateNewBatchTarget ¶
func CalculateNewBatchTarget(rolloutSpec *v1alpha1.ReleasePlan, workloadReplicas, currentBatch int) int
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 GetRolloutCondition ¶
func GetRolloutCondition(status rolloutv1alpha1.RolloutStatus, condType rolloutv1alpha1.RolloutConditionType) *rolloutv1alpha1.RolloutCondition
GetRolloutCondition returns the condition with the provided type.
func HashReleasePlanBatches ¶
func HashReleasePlanBatches(releasePlan *v1alpha1.ReleasePlan) string
func IsControlledBy ¶
func NewRegistry ¶
NewRegistry creates clientset by client-go
func NewRolloutCondition ¶
func NewRolloutCondition(condType rolloutv1alpha1.RolloutConditionType, status corev1.ConditionStatus, reason, message string) *rolloutv1alpha1.RolloutCondition
NewRolloutCondition creates a new rollout condition.
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 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 GenericClientset ¶
type GenericClientset struct {
DiscoveryClient discovery.DiscoveryInterface
KubeClient kubeclientset.Interface
KruiseClient kruiseclientset.Interface
}
GenericClientset defines a generic client
func GetGenericClient ¶
func GetGenericClient() *GenericClientset
GetGenericClient returns default clientset
type RolloutState ¶
type RolloutState struct {
RolloutName string
}
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.TypeMeta
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
// 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.