canary

package
v1.40.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeHash added in v1.34.0

func ComputeHash(spec interface{}) string

ComputeHash returns a hash value calculated from a spec 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 MakeStatusConditions

func MakeStatusConditions(cd *flaggerv1.Canary,
	phase flaggerv1.CanaryPhase) (bool, []flaggerv1.CanaryCondition)

MakeStatusCondition updates the canary status conditions based on canary phase

Types

type ConfigRef

type ConfigRef struct {
	Name     string
	Type     ConfigRefType
	Checksum string
}

ConfigRef holds the reference to a tracked Kubernetes ConfigMap or Secret

func (*ConfigRef) GetName

func (c *ConfigRef) GetName() string

GetName returns the config ref type and name

type ConfigRefType

type ConfigRefType string
const (
	ConfigRefMap    ConfigRefType = "configmap"
	ConfigRefSecret ConfigRefType = "secret"
)

type ConfigTracker

type ConfigTracker struct {
	KubeClient    kubernetes.Interface
	FlaggerClient clientset.Interface
	Logger        *zap.SugaredLogger
}

ConfigTracker is managing the operations for Kubernetes ConfigMaps and Secrets

func (*ConfigTracker) ApplyPrimaryConfigs

func (ct *ConfigTracker) ApplyPrimaryConfigs(spec corev1.PodSpec, refs map[string]ConfigRef) corev1.PodSpec

ApplyPrimaryConfigs appends the primary suffix to all ConfigMaps and Secrets found in the PodSpec

func (*ConfigTracker) CreatePrimaryConfigs

func (ct *ConfigTracker) CreatePrimaryConfigs(cd *flaggerv1.Canary, refs map[string]ConfigRef, includeLabelPrefix []string) error

CreatePrimaryConfigs syncs the primary Kubernetes ConfigMaps and Secrets with those found in the target deployment

func (*ConfigTracker) GetConfigRefs

func (ct *ConfigTracker) GetConfigRefs(cd *flaggerv1.Canary) (*map[string]string, error)

GetConfigRefs returns a map of configs and their checksum

func (*ConfigTracker) GetTargetConfigs

func (ct *ConfigTracker) GetTargetConfigs(cd *flaggerv1.Canary) (map[string]ConfigRef, error)

GetTargetConfigs scans the target deployment for Kubernetes ConfigMaps and Secrets and returns a list of config references

func (*ConfigTracker) HasConfigChanged

func (ct *ConfigTracker) HasConfigChanged(cd *flaggerv1.Canary) (bool, error)

HasConfigChanged checks for changes in ConfigMaps and Secrets by comparing the checksum for each ConfigRef stored in Canary.Status.TrackedConfigs

type Controller

type Controller interface {
	IsPrimaryReady(canary *flaggerv1.Canary) (bool, error)
	IsCanaryReady(canary *flaggerv1.Canary) (bool, error)
	GetMetadata(canary *flaggerv1.Canary) (string, string, map[string]int32, error)
	SyncStatus(canary *flaggerv1.Canary, status flaggerv1.CanaryStatus) error
	SetStatusFailedChecks(canary *flaggerv1.Canary, val int) error
	SetStatusWeight(canary *flaggerv1.Canary, val int) error
	SetStatusIterations(canary *flaggerv1.Canary, val int) error
	SetStatusPhase(canary *flaggerv1.Canary, phase flaggerv1.CanaryPhase) error
	Initialize(canary *flaggerv1.Canary) (bool, error)
	Promote(canary *flaggerv1.Canary) error
	HasTargetChanged(canary *flaggerv1.Canary) (bool, error)
	HaveDependenciesChanged(canary *flaggerv1.Canary) (bool, error)
	ScaleToZero(canary *flaggerv1.Canary) error
	ScaleFromZero(canary *flaggerv1.Canary) error
	Finalize(canary *flaggerv1.Canary) error
}

type DaemonSetController

type DaemonSetController struct {
	// contains filtered or unexported fields
}

DaemonSetController is managing the operations for Kubernetes DaemonSet kind

func (*DaemonSetController) Finalize

func (c *DaemonSetController) Finalize(cd *flaggerv1.Canary) error

Finalize scale the reference instance from zero

func (*DaemonSetController) GetMetadata

func (c *DaemonSetController) GetMetadata(cd *flaggerv1.Canary) (string, string, map[string]int32, error)

GetMetadata returns the pod label selector and svc ports

func (*DaemonSetController) HasTargetChanged

func (c *DaemonSetController) HasTargetChanged(cd *flaggerv1.Canary) (bool, error)

HasTargetChanged returns true if the canary DaemonSet pod spec has changed

func (*DaemonSetController) HaveDependenciesChanged

func (c *DaemonSetController) HaveDependenciesChanged(cd *flaggerv1.Canary) (bool, error)

func (*DaemonSetController) Initialize

func (c *DaemonSetController) Initialize(cd *flaggerv1.Canary) (bool, error)

Initialize creates the primary DaemonSet if it does not exist.

func (*DaemonSetController) IsCanaryReady

func (c *DaemonSetController) IsCanaryReady(cd *flaggerv1.Canary) (bool, error)

IsCanaryReady checks the canary daemonset and returns an error if the daemonset is in the middle of a rolling update

func (*DaemonSetController) IsPrimaryReady

func (c *DaemonSetController) IsPrimaryReady(cd *flaggerv1.Canary) (bool, error)

IsPrimaryReady checks the primary daemonset status and returns an error if the daemonset is in the middle of a rolling update

func (*DaemonSetController) Promote

func (c *DaemonSetController) Promote(cd *flaggerv1.Canary) error

Promote copies the pod spec, secrets and config maps from canary to primary

func (*DaemonSetController) ScaleFromZero

func (c *DaemonSetController) ScaleFromZero(cd *flaggerv1.Canary) error

func (*DaemonSetController) ScaleToZero

func (c *DaemonSetController) ScaleToZero(cd *flaggerv1.Canary) error

func (*DaemonSetController) SetStatusFailedChecks

func (c *DaemonSetController) SetStatusFailedChecks(cd *flaggerv1.Canary, val int) error

SetStatusFailedChecks updates the canary failed checks counter

func (*DaemonSetController) SetStatusIterations

func (c *DaemonSetController) SetStatusIterations(cd *flaggerv1.Canary, val int) error

SetStatusIterations updates the canary status iterations value

func (*DaemonSetController) SetStatusPhase

func (c *DaemonSetController) SetStatusPhase(cd *flaggerv1.Canary, phase flaggerv1.CanaryPhase) error

SetStatusPhase updates the canary status phase

func (*DaemonSetController) SetStatusWeight

func (c *DaemonSetController) SetStatusWeight(cd *flaggerv1.Canary, val int) error

SetStatusWeight updates the canary status weight value

func (*DaemonSetController) SyncStatus

func (c *DaemonSetController) SyncStatus(cd *flaggerv1.Canary, status flaggerv1.CanaryStatus) error

SyncStatus encodes the canary pod spec and updates the canary status

type DeploymentController

type DeploymentController struct {
	// contains filtered or unexported fields
}

DeploymentController is managing the operations for Kubernetes Deployment kind

func (*DeploymentController) Finalize

func (c *DeploymentController) Finalize(cd *flaggerv1.Canary) error

Finalize will set the replica count from the primary to the reference instance. This method is used during a delete to attempt to revert the deployment back to the original state. Error is returned if unable update the reference deployment replicas to the primary replicas

func (*DeploymentController) GetMetadata

func (c *DeploymentController) GetMetadata(cd *flaggerv1.Canary) (string, string, map[string]int32, error)

GetMetadata returns the pod label selector and svc ports

func (*DeploymentController) HasTargetChanged

func (c *DeploymentController) HasTargetChanged(cd *flaggerv1.Canary) (bool, error)

HasTargetChanged returns true if the canary deployment pod spec has changed

func (*DeploymentController) HaveDependenciesChanged

func (c *DeploymentController) HaveDependenciesChanged(cd *flaggerv1.Canary) (bool, error)

func (*DeploymentController) Initialize

func (c *DeploymentController) Initialize(cd *flaggerv1.Canary) (bool, error)

Initialize creates the primary deployment if it does not exist.

func (*DeploymentController) IsCanaryReady

func (c *DeploymentController) IsCanaryReady(cd *flaggerv1.Canary) (bool, error)

IsCanaryReady checks the canary deployment status and returns an error if the deployment is in the middle of a rolling update or if the pods are unhealthy it will return a non retriable error if the rolling update is stuck

func (*DeploymentController) IsPrimaryReady

func (c *DeploymentController) IsPrimaryReady(cd *flaggerv1.Canary) (bool, error)

IsPrimaryReady checks the primary deployment status and returns an error if the deployment is in the middle of a rolling update or if the pods are unhealthy it will return a non retryable error if the rolling update is stuck

func (*DeploymentController) Promote

func (c *DeploymentController) Promote(cd *flaggerv1.Canary) error

Promote copies the pod spec, secrets and config maps from canary to primary

func (*DeploymentController) ScaleFromZero

func (c *DeploymentController) ScaleFromZero(cd *flaggerv1.Canary) error

func (*DeploymentController) ScaleToZero

func (c *DeploymentController) ScaleToZero(cd *flaggerv1.Canary) error

ScaleToZero Scale sets the canary deployment replicas

func (*DeploymentController) SetStatusFailedChecks

func (c *DeploymentController) SetStatusFailedChecks(cd *flaggerv1.Canary, val int) error

SetStatusFailedChecks updates the canary failed checks counter

func (*DeploymentController) SetStatusIterations

func (c *DeploymentController) SetStatusIterations(cd *flaggerv1.Canary, val int) error

SetStatusIterations updates the canary status iterations value

func (*DeploymentController) SetStatusPhase

func (c *DeploymentController) SetStatusPhase(cd *flaggerv1.Canary, phase flaggerv1.CanaryPhase) error

SetStatusPhase updates the canary status phase

func (*DeploymentController) SetStatusWeight

func (c *DeploymentController) SetStatusWeight(cd *flaggerv1.Canary, val int) error

SetStatusWeight updates the canary status weight value

func (*DeploymentController) SyncStatus

func (c *DeploymentController) SyncStatus(cd *flaggerv1.Canary, status flaggerv1.CanaryStatus) error

SyncStatus encodes the canary pod spec and updates the canary status

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

func NewFactory

func NewFactory(kubeClient kubernetes.Interface,
	flaggerClient clientset.Interface,
	configTracker Tracker,
	labels []string,
	includeLabelPrefix []string,
	logger *zap.SugaredLogger) *Factory

func (*Factory) Controller

func (factory *Factory) Controller(kind string) Controller

func (*Factory) ScalerReconciler added in v1.22.0

func (factory *Factory) ScalerReconciler(kind string) ScalerReconciler

type HPAReconciler added in v1.22.0

type HPAReconciler struct {
	// contains filtered or unexported fields
}

HPAReconciler is a ScalerReconciler that reconciles HPAs.

func (*HPAReconciler) PauseTargetScaler added in v1.22.0

func (hr *HPAReconciler) PauseTargetScaler(cd *flaggerv1.Canary) error

func (*HPAReconciler) ReconcilePrimaryScaler added in v1.22.0

func (hr *HPAReconciler) ReconcilePrimaryScaler(cd *flaggerv1.Canary, init bool) error

func (*HPAReconciler) ResumeTargetScaler added in v1.22.0

func (hr *HPAReconciler) ResumeTargetScaler(cd *flaggerv1.Canary) error

type NopTracker

type NopTracker struct{}

NopTracker no-operation tracker

func (*NopTracker) ApplyPrimaryConfigs

func (nt *NopTracker) ApplyPrimaryConfigs(spec corev1.PodSpec, _ map[string]ConfigRef) corev1.PodSpec

func (*NopTracker) CreatePrimaryConfigs

func (nt *NopTracker) CreatePrimaryConfigs(*flaggerv1.Canary, map[string]ConfigRef, []string) error

func (*NopTracker) GetConfigRefs

func (nt *NopTracker) GetConfigRefs(*flaggerv1.Canary) (*map[string]string, error)

func (*NopTracker) GetTargetConfigs

func (nt *NopTracker) GetTargetConfigs(*flaggerv1.Canary) (map[string]ConfigRef, error)

func (*NopTracker) HasConfigChanged

func (nt *NopTracker) HasConfigChanged(*flaggerv1.Canary) (bool, error)

type ScaledObjectReconciler added in v1.22.0

type ScaledObjectReconciler struct {
	// contains filtered or unexported fields
}

ScaledObjectReconciler is a ScalerReconciler that reconciles KEDA ScaledObjects.

func (*ScaledObjectReconciler) PauseTargetScaler added in v1.22.0

func (sor *ScaledObjectReconciler) PauseTargetScaler(cd *flaggerv1.Canary) error

func (*ScaledObjectReconciler) ReconcilePrimaryScaler added in v1.22.0

func (sor *ScaledObjectReconciler) ReconcilePrimaryScaler(cd *flaggerv1.Canary, init bool) error

func (*ScaledObjectReconciler) ResumeTargetScaler added in v1.22.0

func (sor *ScaledObjectReconciler) ResumeTargetScaler(cd *flaggerv1.Canary) error

type ScalerReconciler added in v1.22.0

type ScalerReconciler interface {
	ReconcilePrimaryScaler(cd *flaggerv1.Canary, init bool) error
	PauseTargetScaler(cd *flaggerv1.Canary) error
	ResumeTargetScaler(cd *flaggerv1.Canary) error
}

ScalerReconciler represents a reconciler that can reconcile resources that can scale other resources.

type ServiceController

type ServiceController struct {
	// contains filtered or unexported fields
}

ServiceController is managing the operations for Kubernetes service kind

func (*ServiceController) Finalize

func (c *ServiceController) Finalize(_ *flaggerv1.Canary) error

func (*ServiceController) GetMetadata

func (c *ServiceController) GetMetadata(_ *flaggerv1.Canary) (string, string, map[string]int32, error)

GetMetadata returns the pod label selector, label value and svc ports

func (*ServiceController) HasTargetChanged

func (c *ServiceController) HasTargetChanged(cd *flaggerv1.Canary) (bool, error)

HasServiceChanged returns true if the canary service spec has changed

func (*ServiceController) HaveDependenciesChanged

func (c *ServiceController) HaveDependenciesChanged(_ *flaggerv1.Canary) (bool, error)

func (*ServiceController) Initialize

func (c *ServiceController) Initialize(cd *flaggerv1.Canary) (bool, error)

Initialize creates or updates the primary and canary services to prepare for the canary release process targeted on the K8s service

func (*ServiceController) IsCanaryReady

func (c *ServiceController) IsCanaryReady(_ *flaggerv1.Canary) (bool, error)

func (*ServiceController) IsPrimaryReady

func (c *ServiceController) IsPrimaryReady(_ *flaggerv1.Canary) (bool, error)

func (*ServiceController) Promote

func (c *ServiceController) Promote(cd *flaggerv1.Canary) error

Promote copies target's spec from canary to primary

func (*ServiceController) ScaleFromZero

func (c *ServiceController) ScaleFromZero(_ *flaggerv1.Canary) error

func (*ServiceController) ScaleToZero

func (c *ServiceController) ScaleToZero(_ *flaggerv1.Canary) error

Scale sets the canary deployment replicas

func (*ServiceController) SetStatusFailedChecks

func (c *ServiceController) SetStatusFailedChecks(cd *flaggerv1.Canary, val int) error

SetStatusFailedChecks updates the canary failed checks counter

func (*ServiceController) SetStatusIterations

func (c *ServiceController) SetStatusIterations(cd *flaggerv1.Canary, val int) error

SetStatusIterations updates the canary status iterations value

func (*ServiceController) SetStatusPhase

func (c *ServiceController) SetStatusPhase(cd *flaggerv1.Canary, phase flaggerv1.CanaryPhase) error

SetStatusPhase updates the canary status phase

func (*ServiceController) SetStatusWeight

func (c *ServiceController) SetStatusWeight(cd *flaggerv1.Canary, val int) error

SetStatusWeight updates the canary status weight value

func (*ServiceController) SyncStatus

func (c *ServiceController) SyncStatus(cd *flaggerv1.Canary, status flaggerv1.CanaryStatus) error

type Tracker

type Tracker interface {
	GetTargetConfigs(cd *flaggerv1.Canary) (map[string]ConfigRef, error)
	GetConfigRefs(cd *flaggerv1.Canary) (*map[string]string, error)
	HasConfigChanged(cd *flaggerv1.Canary) (bool, error)
	CreatePrimaryConfigs(cd *flaggerv1.Canary, refs map[string]ConfigRef, includeLabelPrefix []string) error
	ApplyPrimaryConfigs(spec corev1.PodSpec, refs map[string]ConfigRef) corev1.PodSpec
}

Jump to

Keyboard shortcuts

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