controller

package
v0.0.0-...-aa25bfb Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: AGPL-3.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeploymentVersionUpdater

type DeploymentVersionUpdater struct {
	VersionUpdater
	kclient.Client
	Scheme *runtime.Scheme
}

DeploymentVersionUpdater Reconciles a podSpec by changing its image

func (*DeploymentVersionUpdater) Reconcile

Reconcile treats a reconciliation request for a Deployment object. It gets the object, retrieves its current version, and calls the VersionUpdater to find if the Deployment should be updated. If it's the case, it changes the Teleport image version and updates the Deployment in Kubernetes.

func (*DeploymentVersionUpdater) SetupWithManager

func (r *DeploymentVersionUpdater) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager makes the DeploymentVersionUpdater managed by a ctrl.Manager. Once started, the manager will send Deployment reconciliation requests to the DeploymentVersionUpdater controller.

type MaintenanceNotTriggeredError

type MaintenanceNotTriggeredError struct {
	Message string `json:"message"`
}

MaintenanceNotTriggeredError indicates that no trigger returned true and the controller did not reconcile.

func (*MaintenanceNotTriggeredError) Error

Error returns log friendly description of an error

type NoNewVersionError

type NoNewVersionError struct {
	Message        string `json:"message"`
	CurrentVersion string `json:"currentVersion"`
	NextVersion    string `json:"nextVersion"`
}

NoNewVersionError indicates that no new version was found and the controller did not reconcile.

func (*NoNewVersionError) Error

func (e *NoNewVersionError) Error() string

Error returns log friendly description of an error

type StatefulSetVersionUpdater

type StatefulSetVersionUpdater struct {
	VersionUpdater
	kclient.Client
	Scheme *runtime.Scheme
}

func (*StatefulSetVersionUpdater) Reconcile

Reconcile treats a reconciliation request for a StatefulSet object. It gets the object, retrieves its current version, and calls the VersionUpdater to find if the StatefulSet should be updated. If it's the case, it changes the Teleport image version and updates the StatefulSet in Kubernetes.

WARNING: StatefulSets rollouts can end up being stuck because of unready pods. We must delete those unhealthy pods to ensure the rollout is not blocked. Deleting only after an update is not idempotent, and deleting every reconciliation or maintenance might be disruptive and cause misleading error if something else is broken (i.e. the state is invalid but we keep deleting the pods). To mitigate the disruption, we only delete unhealthy pods whose spec is not based on the current PodTemplate. We attempt to unstuck a rollout:

  • when a maintenance was triggered but no new version was found (unhealthy pods will trigger maintenance thanks to the WorkloadUnhealthyTrigger)
  • when a maintenance was triggered, new version was found, but we failed to validate the image.
  • when the version was successfully updated

We do not try to unblock in the following cases:

  • when a maintenance was not triggered (nothing to do, the most common case)
  • when we encounter an unknown error when checking maintenance,version,image
  • when we face an error when updating the statefulset (99% chance we conflicted with something else and are being requeued, the update will pass the next time)

func (*StatefulSetVersionUpdater) SetupWithManager

func (r *StatefulSetVersionUpdater) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager makes the DeploymentVersionUpdater managed by a ctrl.Manager. Once started, the manager will send Deployment reconciliation requests to the DeploymentVersionUpdater controller.

type VersionUpdater

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

func NewVersionUpdater

NewVersionUpdater returns a version updater using the given version.Getter, img.Validators, maintenance.Triggers and baseImage.

func (*VersionUpdater) GetVersion

func (r *VersionUpdater) GetVersion(ctx context.Context, obj client.Object, currentVersion string) (img.NamedTaggedDigested, error)

GetVersion does all the version update logic: checking if a maintenance is allowed, retrieving the new version, comparing it with the current version and validating the new image signature. If all steps are successfully executed and there's a new version, it returns a digested reference to the new image that should be deployed.

Jump to

Keyboard shortcuts

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