Documentation
¶
Overview ¶
internal/controller/common/kubeutil/apply.go Package kubeutil provides utility functions for interacting with Kubernetes resources.
internal/controller/common/kubeutil/health.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildObjectResultMapKey ¶
BuildObjectResultMapKey creates a unique string key for the applyResults map. It uses the object's GVK string, Namespace, and Name.
func CheckHealth ¶
func CheckHealth(ctx context.Context, k8sClient client.Client, scheme *runtime.Scheme, ns, name, apiVersion, kind string) (bool, string, error)
CheckHealth checks the K8s readiness/health status of a resource based on its Kind. Returns: isHealthy (bool), a message describing status, and an error if check process failed.
Types ¶
type ApplyResult ¶
type ApplyResult struct { // Operation indicates the result (Created, Updated, Configured, None, Deleted - less relevant for Apply). // Using OperationResultNone for SSA success unless K8s version/libraries provide more detail. Operation controllerutil.OperationResult // Error holds any error that occurred during the apply operation. Error error }
ApplyResult contains the result of an apply operation (SSA). Note: With Server-Side Apply, accurately determining Created vs Updated vs Unchanged often requires comparing the object before and after, which adds complexity. OperationResultNone is often returned for successful SSA calls if no mutations occurred or detection is hard.
func ApplyObject ¶
func ApplyObject(ctx context.Context, k8sClient client.Client, obj client.Object, fieldManager string) ApplyResult
ApplyObject idempotently applies the desired state of a Kubernetes object using Server-Side Apply. It creates the object if it doesn't exist, or patches it based on the desired state, managing fields via the specified fieldManager. The input 'obj' should be a *pointer* to a valid client.Object (e.g., &appsv1.Deployment{}). It should contain the complete desired state *with* Kind, APIVersion, Name, Namespace set.