Documentation ¶
Index ¶
- type ApplyResults
- type ApplySet
- type ApplyableObject
- type ManagedFieldsMigrator
- type Options
- type UnstructuredClient
- func (c *UnstructuredClient) Get(ctx context.Context, gvk schema.GroupVersionKind, nn types.NamespacedName) (*unstructured.Unstructured, error)
- func (c *UnstructuredClient) Patch(ctx context.Context, gvk schema.GroupVersionKind, nn types.NamespacedName, ...) (*unstructured.Unstructured, error)
- func (c *UnstructuredClient) Update(ctx context.Context, obj *unstructured.Unstructured, opt metav1.UpdateOptions) (*unstructured.Unstructured, error)
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 (*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
func (m *ManagedFieldsMigrator) Migrate(ctx context.Context, obj *unstructured.Unstructured) error
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
func (c *UnstructuredClient) Get(ctx context.Context, gvk schema.GroupVersionKind, nn types.NamespacedName) (*unstructured.Unstructured, error)
Get reads the specified object.
func (*UnstructuredClient) Patch ¶ added in v1.26.0
func (c *UnstructuredClient) Patch(ctx context.Context, gvk schema.GroupVersionKind, nn types.NamespacedName, patchType types.PatchType, data []byte, opt metav1.PatchOptions) (*unstructured.Unstructured, error)
Patch performs a Patch operation, used for server-side apply and client-side patch.
func (*UnstructuredClient) Update ¶ added in v1.26.0
func (c *UnstructuredClient) Update(ctx context.Context, obj *unstructured.Unstructured, opt metav1.UpdateOptions) (*unstructured.Unstructured, error)
Update performs an Update operation on the object. Generally we should prefer server-side-apply.