Documentation
¶
Index ¶
- Constants
- func ConvertClientObjectToMap(obj client.Object) (map[string]interface{}, error)
- func ConvertCommandToStringArray(command string) ([]string, error)
- func EvaluateCheckHook(k8sReader client.Reader, hook *kubeobjects.HookSpec, log logr.Logger) (bool, error)
- func EvaluateCheckHookExp(booleanExpression string, jsonData interface{}) (bool, error)
- func EvaluateCheckHookForObjects(objs []client.Object, hook *kubeobjects.HookSpec, log logr.Logger) (bool, error)
- func IsPodOwnedByDaemonSet(pod *corev1.Pod, dsName string) bool
- func IsPodOwnedByRS(pod *corev1.Pod, rsName string) bool
- func IsPodOwnedByStatefulSet(pod *corev1.Pod, ssName string) bool
- func IsRSOwnedByDeployment(rs *appsv1.ReplicaSet, depName string) bool
- func IsValidJSONPathExpression(expr string) bool
- func QueryJSONPath(data interface{}, jsonPath string) (reflect.Value, error)
- type CheckHook
- type DaemonSetPodLister
- type DeploymentPodLister
- type DeploymentResource
- func (d DeploymentResource) GetAnnotations() map[string]string
- func (d DeploymentResource) GetObjectMeta() metav1.Object
- func (d DeploymentResource) GetReplicasFromSpec() *int32
- func (d DeploymentResource) GetReplicasFromStatus() *int32
- func (d DeploymentResource) SetAnnotations(annotation map[string]string)
- func (d DeploymentResource) SetReplicas(replicas *int32)
- func (d DeploymentResource) Update(ctx context.Context, c client.Client) error
- type DirectPodLister
- type ExecHook
- type ExecPodSpec
- type HookContext
- type HookExecutor
- type JobHook
- type NameSelectorType
- type PodLister
- type Resource
- type ScaleHook
- type StatefulSetPodLister
- type StatefulSetResource
- func (s StatefulSetResource) GetAnnotations() map[string]string
- func (s StatefulSetResource) GetObjectMeta() metav1.Object
- func (s StatefulSetResource) GetReplicasFromSpec() *int32
- func (s StatefulSetResource) GetReplicasFromStatus() *int32
- func (s StatefulSetResource) SetAnnotations(annotation map[string]string)
- func (s StatefulSetResource) SetReplicas(replicas *int32)
- func (s StatefulSetResource) Update(ctx context.Context, c client.Client) error
Constants ¶
const ( ScaleUp = "up" ScaleDown = "down" ScaleSync = "sync" )
Variables ¶
This section is empty.
Functions ¶
func EvaluateCheckHook ¶
func EvaluateCheckHookExp ¶
func IsPodOwnedByDaemonSet ¶
IsPodOwnedByDaemonSet checks if a pod is owned by the specified DaemonSet and is running.
func IsPodOwnedByRS ¶
IsPodOwnedByRS checks if a pod is owned by the specified ReplicaSet and is running.
func IsPodOwnedByStatefulSet ¶
IsPodOwnedByStatefulSet checks if a pod is owned by the specified StatefulSet and is running.
func IsRSOwnedByDeployment ¶
func IsRSOwnedByDeployment(rs *appsv1.ReplicaSet, depName string) bool
IsRSOwnedByDeployment checks if a ReplicaSet is owned by the specified Deployment and has ready replicas.
func IsValidJSONPathExpression ¶
IsValidJSONPathExpression checks if a given expression is a valid JSONPath expression
Types ¶
type DaemonSetPodLister ¶
type DaemonSetPodLister struct {
ExecHook
}
DaemonSetPodLister handles pod discovery when SelectResource is "daemonset". It finds DaemonSets and returns one running pod from each.
func (*DaemonSetPodLister) GetPods ¶
func (l *DaemonSetPodLister) GetPods(log logr.Logger) ([]ExecPodSpec, error)
GetPods returns pods from DaemonSets matching the selector criteria. When SinglePodOnly is true, it returns one pod per DaemonSet. When SinglePodOnly is false, it returns all pods from all DaemonSets.
type DeploymentPodLister ¶
type DeploymentPodLister struct {
ExecHook
}
DeploymentPodLister handles pod discovery when SelectResource is "deployment". It finds deployments, then their ReplicaSets, then the pods owned by those ReplicaSets.
func (*DeploymentPodLister) GetPods ¶
func (l *DeploymentPodLister) GetPods(log logr.Logger) ([]ExecPodSpec, error)
GetPods returns pods from deployments matching the selector criteria. When SinglePodOnly is true, it returns one pod per deployment. When SinglePodOnly is false, it returns all pods from all deployments' ReplicaSets.
type DeploymentResource ¶
type DeploymentResource struct {
*appsv1.Deployment
}
func (DeploymentResource) GetAnnotations ¶
func (d DeploymentResource) GetAnnotations() map[string]string
func (DeploymentResource) GetObjectMeta ¶
func (d DeploymentResource) GetObjectMeta() metav1.Object
func (DeploymentResource) GetReplicasFromSpec ¶
func (d DeploymentResource) GetReplicasFromSpec() *int32
func (DeploymentResource) GetReplicasFromStatus ¶
func (d DeploymentResource) GetReplicasFromStatus() *int32
func (DeploymentResource) SetAnnotations ¶
func (d DeploymentResource) SetAnnotations(annotation map[string]string)
func (DeploymentResource) SetReplicas ¶
func (d DeploymentResource) SetReplicas(replicas *int32)
type DirectPodLister ¶
type DirectPodLister struct {
ExecHook
}
DirectPodLister handles pod discovery when SelectResource is "pod" or empty. It directly queries pods using label or name selectors.
func (*DirectPodLister) GetPods ¶
func (l *DirectPodLister) GetPods(log logr.Logger) ([]ExecPodSpec, error)
GetPods returns pods matching the selector criteria. If SinglePodOnly is true, returns only the first matching pod.
type ExecHook ¶
type ExecHook struct {
Hook *kubeobjects.HookSpec
Client client.Client
Reader client.Reader
Scheme *runtime.Scheme
RecipeElements util.RecipeElements
}
type ExecPodSpec ¶
type HookContext ¶
type HookContext struct {
Hook kubeobjects.HookSpec
Client client.Client
Reader client.Reader
Scheme *runtime.Scheme
RecipeElements util.RecipeElements
}
type HookExecutor ¶
Hook interface will help in executing the hooks based on the types. Supported types are "check", "scale", "exec", and "job". The implementor needs return the result which would be boolean and error if any.
func GetHookExecutor ¶
func GetHookExecutor(ctx HookContext) (HookExecutor, error)
Based on the hook type, return the appropriate implementation of the hook.
type JobHook ¶
type JobHook struct {
Hook *kubeobjects.HookSpec
Client client.Client
Reader client.Reader
Scheme *runtime.Scheme
RecipeElements util.RecipeElements
}
func (JobHook) CreateOrGetJob ¶
func (j JobHook) CreateOrGetJob(ctx context.Context, jobTemplate *batchv1.Job, log logr.Logger) (*batchv1.Job, error)
CreateOrGetJob creates a new job or retrieves an existing one based on ForceCreate flag.
type NameSelectorType ¶
type NameSelectorType string
const ( ValidNameSelector NameSelectorType = "valid" RegexNameSelector NameSelectorType = "regex" InvalidNameSelector NameSelectorType = "invalid" )
type PodLister ¶
type PodLister interface {
GetPods(log logr.Logger) ([]ExecPodSpec, error)
}
PodLister interface abstracts pod discovery based on SelectResource type. Each implementation handles a specific resource type (pod, deployment, statefulset, daemonset).
func NewPodLister ¶
NewPodLister returns the appropriate PodLister implementation based on SelectResource.
type StatefulSetPodLister ¶
type StatefulSetPodLister struct {
ExecHook
}
StatefulSetPodLister handles pod discovery when SelectResource is "statefulset". It finds StatefulSets and returns the first pod (index 0) from each.
func (*StatefulSetPodLister) GetPods ¶
func (l *StatefulSetPodLister) GetPods(log logr.Logger) ([]ExecPodSpec, error)
GetPods returns pods from StatefulSets matching the selector criteria. When SinglePodOnly is true, it returns one pod (index 0) per StatefulSet. When SinglePodOnly is false, it returns all pods from all StatefulSets.
type StatefulSetResource ¶
type StatefulSetResource struct {
*appsv1.StatefulSet
}
func (StatefulSetResource) GetAnnotations ¶
func (s StatefulSetResource) GetAnnotations() map[string]string
func (StatefulSetResource) GetObjectMeta ¶
func (s StatefulSetResource) GetObjectMeta() metav1.Object
func (StatefulSetResource) GetReplicasFromSpec ¶
func (s StatefulSetResource) GetReplicasFromSpec() *int32
func (StatefulSetResource) GetReplicasFromStatus ¶
func (s StatefulSetResource) GetReplicasFromStatus() *int32
func (StatefulSetResource) SetAnnotations ¶
func (s StatefulSetResource) SetAnnotations(annotation map[string]string)
func (StatefulSetResource) SetReplicas ¶
func (s StatefulSetResource) SetReplicas(replicas *int32)