Documentation
¶
Index ¶
- func ConvertTypedToUnstructured(typed interface{}) (map[string]interface{}, error)
- func ConvertUnstructuredToTyped(u map[string]interface{}, typed interface{}) error
- func CountReadyPods(pods *v1.PodList) int
- func CreateKubernetesClients(restConfig *rest.Config) (dynamic.Interface, meta.RESTMapper, error)
- func IsNodeReady(node *v1.Node) bool
- func ListPods(ctx context.Context, clientset kubernetes.Interface, namespace string, ...) (*v1.PodList, error)
- func PollForCondition(ctx context.Context, timeout, interval time.Duration, ...) error
- func ScalePodCliqueScalingGroup(ctx context.Context, restConfig *rest.Config, namespace, name string, ...) error
- func ScalePodCliqueScalingGroupWithClient(ctx context.Context, dynamicClient dynamic.Interface, namespace, name string, ...) error
- func ScalePodCliqueSet(ctx context.Context, restConfig *rest.Config, namespace, name string, ...) error
- func ScalePodCliqueSetWithClient(ctx context.Context, dynamicClient dynamic.Interface, namespace, name string, ...) error
- func SetNodeSchedulable(ctx context.Context, clientset kubernetes.Interface, nodeName string, ...) error
- func VerifyPodPhases(pods *v1.PodList, expectedRunning, expectedPending int) error
- func WaitAndGetReadyNode(ctx context.Context, clientset *kubernetes.Clientset, nodeName string, ...) (node *v1.Node, err error)
- func WaitForPodCount(ctx context.Context, clientset kubernetes.Interface, namespace string, ...) (*v1.PodList, error)
- func WaitForPodCountAndPhases(ctx context.Context, clientset kubernetes.Interface, ...) error
- func WaitForPods(ctx context.Context, restConfig *rest.Config, namespaces []string, ...) error
- func WaitForPodsInNamespace(ctx context.Context, namespace string, restConfig *rest.Config, ...) error
- type AppliedResource
- type LogLevel
- type Logger
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) GetLevel() LogLevel
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) Warn(args ...interface{})
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) WriterLevel(level LogLevel) io.Writer
- type PodPhaseCount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertTypedToUnstructured ¶
ConvertTypedToUnstructured converts a typed object to an unstructured map. Useful for converting typed structs to Helm values maps.
func ConvertUnstructuredToTyped ¶
ConvertUnstructuredToTyped converts an unstructured map to a typed object
func CountReadyPods ¶
CountReadyPods counts the number of ready pods (Running + Ready condition)
func CreateKubernetesClients ¶
CreateKubernetesClients creates the dynamic client and REST mapper.
func IsNodeReady ¶
IsNodeReady checks if a node is in Ready state
func ListPods ¶
func ListPods(ctx context.Context, clientset kubernetes.Interface, namespace string, labelSelector string) (*v1.PodList, error)
ListPods lists pods in a namespace with an optional label selector
func PollForCondition ¶
func PollForCondition(ctx context.Context, timeout, interval time.Duration, condition func() (bool, error)) error
PollForCondition repeatedly evaluates a condition function at the specified interval until it returns true or the timeout is reached. Returns an error if the condition fails, returns an error, or the timeout expires.
func ScalePodCliqueScalingGroup ¶
func ScalePodCliqueScalingGroup(ctx context.Context, restConfig *rest.Config, namespace, name string, replicas int, timeout, interval time.Duration) error
ScalePodCliqueScalingGroup scales a PodCliqueScalingGroup to the specified replica count It waits for the PCSG to exist before scaling
func ScalePodCliqueScalingGroupWithClient ¶
func ScalePodCliqueScalingGroupWithClient(ctx context.Context, dynamicClient dynamic.Interface, namespace, name string, replicas int, timeout, interval time.Duration) error
ScalePodCliqueScalingGroupWithClient scales a PodCliqueScalingGroup using an existing dynamic client It waits for the PCSG to exist before scaling
func ScalePodCliqueSet ¶
func ScalePodCliqueSet(ctx context.Context, restConfig *rest.Config, namespace, name string, replicas int) error
ScalePodCliqueSet scales a PodCliqueSet to the specified replica count
func ScalePodCliqueSetWithClient ¶
func ScalePodCliqueSetWithClient(ctx context.Context, dynamicClient dynamic.Interface, namespace, name string, replicas int) error
ScalePodCliqueSetWithClient scales a PodCliqueSet using an existing dynamic client
func SetNodeSchedulable ¶
func SetNodeSchedulable(ctx context.Context, clientset kubernetes.Interface, nodeName string, schedulable bool) error
SetNodeSchedulable sets a Kubernetes node to be unschedulable (cordoned) or schedulable (uncordoned). This function uses retry logic to handle optimistic concurrency conflicts that can occur when multiple controllers or processes are updating node objects concurrently.
func VerifyPodPhases ¶
VerifyPodPhases verifies that the pod counts match the expected values Pass -1 for any count you want to skip verification
func WaitAndGetReadyNode ¶
func WaitAndGetReadyNode(ctx context.Context, clientset *kubernetes.Clientset, nodeName string, timeout time.Duration, logger *Logger) (node *v1.Node, err error)
WaitAndGetReadyNode waits for a specific node to become ready after container restart and returns the ready node
func WaitForPodCount ¶
func WaitForPodCount(ctx context.Context, clientset kubernetes.Interface, namespace string, labelSelector string, expectedCount int, timeout time.Duration, interval time.Duration) (*v1.PodList, error)
WaitForPodCount waits for a specific number of pods to be created with the given label selector Returns the pod list once the expected count is reached
func WaitForPodCountAndPhases ¶
func WaitForPodCountAndPhases(ctx context.Context, clientset kubernetes.Interface, namespace, labelSelector string, expectedTotal, expectedRunning, expectedPending int, timeout, interval time.Duration) error
WaitForPodCountAndPhases waits for pods to reach specific total count and phase counts Pass -1 for any count you want to skip verification
func WaitForPods ¶
func WaitForPods(ctx context.Context, restConfig *rest.Config, namespaces []string, labelSelector string, expectedCount int, timeout time.Duration, interval time.Duration, logger *Logger) error
WaitForPods waits for pods to be ready in the specified namespaces labelSelector is optional (pass empty string for all pods), timeout of 0 defaults to 5 minutes, interval of 0 defaults to 5 seconds expectedCount is the expected number of pods (pass 0 to skip count validation)
func WaitForPodsInNamespace ¶
func WaitForPodsInNamespace(ctx context.Context, namespace string, restConfig *rest.Config, expectedCount int, timeout time.Duration, interval time.Duration, logger *Logger) error
WaitForPodsInNamespace waits for all pods in a namespace to be ready expectedCount is the expected number of pods (pass 0 to skip count validation)
Types ¶
type AppliedResource ¶
type AppliedResource struct {
Name string
Namespace string
GVK schema.GroupVersionKind
GVR schema.GroupVersionResource
}
AppliedResource holds information about an applied Kubernetes resource
func ApplyYAMLData ¶
func ApplyYAMLData(ctx context.Context, yamlData []byte, namespace string, dynamicClient dynamic.Interface, restMapper meta.RESTMapper, logger *Logger) ([]AppliedResource, error)
ApplyYAMLData applies YAML data to Kubernetes.
func ApplyYAMLFile ¶
func ApplyYAMLFile(ctx context.Context, yamlFilePath string, namespace string, restConfig *rest.Config, logger *Logger) ([]AppliedResource, error)
ApplyYAMLFile applies a YAML file containing Kubernetes resources namespace parameter is optional - pass empty string to use namespace from YAML
type LogLevel ¶
type LogLevel int
LogLevel represents the logging verbosity level
const ( // DebugLevel logs are typically voluminous, and are usually disabled in production. DebugLevel LogLevel = iota // InfoLevel is the default logging priority. InfoLevel // WarnLevel logs are more important than Info, but don't need individual human review. WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, it shouldn't generate any error-level logs. ErrorLevel )
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides a logrus-compatible interface backed by logr
func NewTestLogger ¶
NewTestLogger creates a new logger with the specified verbosity level
func NewTestLoggerWithOutput ¶
NewTestLoggerWithOutput creates a new logger with the specified verbosity level and output writer
type PodPhaseCount ¶
PodPhaseCount holds counts of pods by phase
func CountPodsByPhase ¶
func CountPodsByPhase(pods *v1.PodList) PodPhaseCount
CountPodsByPhase counts pods by their phase and returns a PodPhaseCount