extensions

package
v1.77.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 23 Imported by: 27

Documentation

Index

Constants

View Source
const HeartBeatResourceName = "gardener-extension-heartbeat"

HeartBeatResourceName is the name of the lease that is managed by the extensions heartbeat controller.

Variables

View Source
var TimeNow = time.Now

TimeNow returns the current time. Exposed for testing.

Functions

func AnnotateObjectWithOperation added in v1.25.0

func AnnotateObjectWithOperation(ctx context.Context, w client.Writer, obj client.Object, operation string) error

AnnotateObjectWithOperation annotates the object with the provided operation annotation value.

func CloudProfileFromCluster

func CloudProfileFromCluster(cluster *extensionsv1alpha1.Cluster) (*gardencorev1beta1.CloudProfile, error)

CloudProfileFromCluster returns the CloudProfile resource inside the Cluster resource.

func DeleteExtensionObject added in v1.25.0

func DeleteExtensionObject(
	ctx context.Context,
	c client.Writer,
	obj extensionsv1alpha1.Object,
	deleteOpts ...client.DeleteOption,
) error

DeleteExtensionObject deletes a given extension object. Passed objects are expected to be filled with the latest state the controller/component observed/retrieved, but at least namespace and name.

func DeleteExtensionObjects added in v1.25.0

func DeleteExtensionObjects(
	ctx context.Context,
	c client.Client,
	listObj client.ObjectList,
	namespace string,
	predicateFunc func(obj extensionsv1alpha1.Object) bool,
	deleteOpts ...client.DeleteOption,
) error

DeleteExtensionObjects lists all extension objects and loops over them. It executes the given predicateFunc for each of them, and if it evaluates to true then the object will be deleted.

func GenericTokenKubeconfigSecretNameFromCluster added in v1.43.0

func GenericTokenKubeconfigSecretNameFromCluster(cluster *Cluster) string

GenericTokenKubeconfigSecretNameFromCluster reads the generic-token-kubeconfig.secret.gardener.cloud/name annotation and returns its value. If the annotation is not present then it falls back to the deprecated SecretNameGenericTokenKubeconfig.

func GetShoot

func GetShoot(ctx context.Context, c client.Reader, namespace string) (*gardencorev1beta1.Shoot, error)

GetShoot tries to read Gardener's Cluster extension resource in the given namespace and return the embedded Shoot resource.

func GetShootStateForCluster added in v1.43.0

func GetShootStateForCluster(
	ctx context.Context,
	gardenClient client.Client,
	seedClient client.Client,
	clusterName string,
) (
	*gardencorev1beta1.ShootState,
	*gardencorev1beta1.Shoot,
	error,
)

GetShootStateForCluster retrieves the ShootState and the Shoot resources for a given Cluster name by first fetching the *extensionsv1alpha1.Cluster object in the seed, extracting the Shoot resource from it and then fetching the *gardencorev1beta1.ShootState resource from the garden.

func MigrateExtensionObject added in v1.25.0

func MigrateExtensionObject(
	ctx context.Context,
	c client.Writer,
	obj extensionsv1alpha1.Object,
) error

MigrateExtensionObject adds the migrate operation annotation to the extension object. Passed objects are expected to be filled with the latest state the controller/component observed/retrieved, but at least namespace and name.

func MigrateExtensionObjects added in v1.25.0

func MigrateExtensionObjects(
	ctx context.Context,
	c client.Client,
	listObj client.ObjectList,
	namespace string,
	predicateFunc func(obj extensionsv1alpha1.Object) bool,
) error

MigrateExtensionObjects lists all extension objects of a given kind and annotates them with the Migrate operation. It executes the given predicateFunc for each of them, and if it evaluates to true, then it migrates the extension object. If predicateFunc is nil then migrates all extension objects.

func RestoreExtensionObjectState added in v1.21.0

func RestoreExtensionObjectState(
	ctx context.Context,
	c client.Client,
	shootState *gardencorev1beta1.ShootState,
	extensionObj extensionsv1alpha1.Object,
	kind string,
) error

RestoreExtensionObjectState restores the status.state field of the extension objects and deploys any required objects from the provided shoot state

func RestoreExtensionWithDeployFunction added in v1.21.0

func RestoreExtensionWithDeployFunction(
	ctx context.Context,
	c client.Client,
	shootState *gardencorev1beta1.ShootState,
	kind string,
	deployFunc func(ctx context.Context, operationAnnotation string) (extensionsv1alpha1.Object, error),
) error

RestoreExtensionWithDeployFunction deploys the extension object with the passed in deployFunc and sets its operation annotation to wait-for-state. It then restores the state of the extension object from the ShootState, creates any required state object and sets the operation annotation to restore.

func SeedFromCluster

func SeedFromCluster(cluster *extensionsv1alpha1.Cluster) (*gardencorev1beta1.Seed, error)

SeedFromCluster returns the Seed resource inside the Cluster resource.

func ShootFromCluster

func ShootFromCluster(cluster *extensionsv1alpha1.Cluster) (*gardencorev1beta1.Shoot, error)

ShootFromCluster returns the Shoot resource inside the Cluster resource.

func SyncClusterResourceToSeed added in v1.21.0

func SyncClusterResourceToSeed(
	ctx context.Context,
	c client.Client,
	clusterName string,
	shoot *gardencorev1beta1.Shoot,
	cloudProfile *gardencorev1beta1.CloudProfile,
	seed *gardencorev1beta1.Seed,
) error

SyncClusterResourceToSeed creates or updates the `extensions.gardener.cloud/v1alpha1.Cluster` resource in the seed cluster by adding the shoot, seed, and cloudprofile specification.

func WaitUntilExtensionObjectDeleted added in v1.25.0

func WaitUntilExtensionObjectDeleted(
	ctx context.Context,
	c client.Client,
	log logr.Logger,
	obj extensionsv1alpha1.Object,
	kind string,
	interval time.Duration,
	timeout time.Duration,
) error

WaitUntilExtensionObjectDeleted waits until an extension oject is deleted from the system. Passed objects are expected to be filled with the latest state the controller/component observed/retrieved, but at least namespace and name.

func WaitUntilExtensionObjectMigrated added in v1.25.0

func WaitUntilExtensionObjectMigrated(
	ctx context.Context,
	c client.Client,
	obj extensionsv1alpha1.Object,
	kind string,
	interval time.Duration,
	timeout time.Duration,
) error

WaitUntilExtensionObjectMigrated waits until the migrate operation for the extension object is successful. Passed objects are expected to be filled with the latest state the controller/component observed/retrieved, but at least namespace and name.

func WaitUntilExtensionObjectReady added in v1.25.0

func WaitUntilExtensionObjectReady(
	ctx context.Context,
	c client.Client,
	log logr.Logger,
	obj extensionsv1alpha1.Object,
	kind string,
	interval time.Duration,
	severeThreshold time.Duration,
	timeout time.Duration,
	postReadyFunc func() error,
) error

WaitUntilExtensionObjectReady waits until the given extension object has become ready. Passed objects are expected to be filled with the latest state the controller/component applied/observed/retrieved, but at least namespace and name.

func WaitUntilExtensionObjectsDeleted added in v1.25.0

func WaitUntilExtensionObjectsDeleted(
	ctx context.Context,
	c client.Client,
	log logr.Logger,
	listObj client.ObjectList,
	kind string,
	namespace string,
	interval time.Duration,
	timeout time.Duration,
	predicateFunc func(obj extensionsv1alpha1.Object) bool,
) error

WaitUntilExtensionObjectsDeleted lists all extension objects and loops over them. It executes the given predicateFunc for each of them, and if it evaluates to true, then it waits for the object to be deleted. If the component needs to wait for a given subset of all extension objects to be deleted (e.g. after deleting unwanted objects), it should pass a predicateFunc that filters objects to wait for by name.

func WaitUntilExtensionObjectsMigrated added in v1.25.0

func WaitUntilExtensionObjectsMigrated(
	ctx context.Context,
	c client.Client,
	listObj client.ObjectList,
	kind string,
	namespace string,
	interval time.Duration,
	timeout time.Duration,
	predicateFunc func(obj extensionsv1alpha1.Object) bool,
) error

WaitUntilExtensionObjectsMigrated lists all extension objects of a given kind and waits until they are migrated. It executes the given predicateFunc for each of them, and if it evaluates to true, then it waits for the extension object to be migrated. If predicateFunc is nil then waits for all extension objects to be migrated.

func WaitUntilObjectReadyWithHealthFunction added in v1.21.0

func WaitUntilObjectReadyWithHealthFunction(
	ctx context.Context,
	c client.Client,
	log logr.Logger,
	healthFunc health.Func,
	obj client.Object,
	kind string,
	interval time.Duration,
	severeThreshold time.Duration,
	timeout time.Duration,
	postReadyFunc func() error,
) error

WaitUntilObjectReadyWithHealthFunction waits until the given object has become ready. It takes the health check function that should be executed. Passed objects are expected to be filled with the latest state the controller/component observed/retrieved, but at least namespace and name.

Types

type Cluster

type Cluster struct {
	ObjectMeta   metav1.ObjectMeta
	CloudProfile *gardencorev1beta1.CloudProfile
	Seed         *gardencorev1beta1.Seed
	Shoot        *gardencorev1beta1.Shoot
}

Cluster contains the decoded resources of Gardener's extension Cluster resource.

func GetCluster

func GetCluster(ctx context.Context, c client.Reader, namespace string) (*Cluster, error)

GetCluster tries to read Gardener's Cluster extension resource in the given namespace.

Jump to

Keyboard shortcuts

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