applyset

package
v1.30.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyResults

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

ApplyResults contains the results of an Apply operation.

func (*ApplyResults) AllApplied

func (r *ApplyResults) AllApplied() bool

AllApplied is true if the desired state has been successfully applied for all objects. Note: you likely also want to check AllHealthy, if you want to be sure the objects are "ready".

func (*ApplyResults) AllHealthy

func (r *ApplyResults) AllHealthy() bool

AllHealthy is true if all the objects have been applied and have converged to a "ready" state. Note that this is only meaningful if AllApplied is true.

type ApplySet

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

ApplySet is a set of objects that we want to apply to the cluster.

An ApplySet has a few cases which it tries to optimize for: * We can change the objects we're applying * We want to watch the objects we're applying / be notified of changes * We want to know when the objects we apply are "healthy" * We expose a "try once" method to better support running from a controller.

TODO: Pluggable health functions. TODO: Pruning

func New

func New(options Options) (*ApplySet, error)

New constructs a new ApplySet

func (*ApplySet) ApplyOnce

func (a *ApplySet) ApplyOnce(ctx context.Context) (*ApplyResults, error)

ApplyOnce will make one attempt to apply all objects and observe their health. It does not wait for the objects to become healthy, but will report their health.

TODO: Limit the amount of time this takes, particularly if we have thousands of objects.

We don't _have_ to try to apply all objects if it is taking too long.

TODO: We re-apply every object every iteration; we should be able to do better.

func (*ApplySet) SetDesiredObjects

func (a *ApplySet) SetDesiredObjects(objects []ApplyableObject) error

SetDesiredObjects is used to replace the desired state of all the objects. Any objects not specified are removed from the "desired" set.

type ApplyableObject

type ApplyableObject interface {
	// GroupVersionKind returns the GroupVersionKind structure describing the type of the object
	GroupVersionKind() schema.GroupVersionKind
	// GetNamespace returns the namespace of the object
	GetNamespace() string
	// GetName returns the name of the object
	GetName() string

	// The object should implement json marshalling
	json.Marshaler
}

ApplyableObject is implemented by objects that can be applied to the cluster. We don't need much, so this might allow for more efficient implementations in future.

type ManagedFieldsMigrator added in v1.26.0

type ManagedFieldsMigrator struct {
	Client     *UnstructuredClient
	NewManager string
}

ManagedFieldsMigrator manages the migration of field managers from client-side managers to the server-side manager.

func (*ManagedFieldsMigrator) Migrate added in v1.26.0

Migrate migrates from client-side field managers to the NewManager (with an Apply operation). This is needed to move from client-side apply to server-side apply.

type Options

type Options struct {
	// Client is the dynamic kubernetes client used to apply objects to the k8s cluster.
	Client dynamic.Interface
	// RESTMapper is used to map object kind to resources, and to know if objects are cluster-scoped.
	RESTMapper meta.RESTMapper
	// PatchOptions holds the options used when applying, in particular the fieldManager
	PatchOptions metav1.PatchOptions
}

Options holds the parameters for building an ApplySet.

type UnstructuredClient added in v1.26.0

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

UnstructuredClient is a client that makes it easier to work with unstructured objects. It is similar to client.Client in controller-runtime, but is never cached.

func NewUnstructuredClient added in v1.26.0

func NewUnstructuredClient(options Options) *UnstructuredClient

NewUnstructuredClient constructs an UnstructuredClient

func (*UnstructuredClient) Get added in v1.26.0

Get reads the specified object.

func (*UnstructuredClient) Patch added in v1.26.0

Patch performs a Patch operation, used for server-side apply and client-side patch.

func (*UnstructuredClient) Update added in v1.26.0

Update performs an Update operation on the object. Generally we should prefer server-side-apply.

Jump to

Keyboard shortcuts

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