kube

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package kube provides a client for interacting with jobs and pods through the KubeAPI in a single namespace Originally Generated by Claude 3.5 Sonnet

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a Kubernetes Client

func NewClient

func NewClient(clientset kubernetes.Interface) (*Client, error)

NewClient creates a new Kubernetes client from a clientset

func (*Client) CleanupJob

func (c *Client) CleanupJob(ctx context.Context, jobName string) error

CleanupJob deletes a job and polls the KubeAPI until deletion is confirmed. It's context-aware, so set ctx to something like `context.WithTimeout(ctx, 10*time.Second)` to set a timeout.

func (*Client) CreateJob

func (c *Client) CreateJob(ctx context.Context, job *batchv1.Job) (*batchv1.Job, error)

CreateJob creates a Kubernetes Job with the provided spec

func (*Client) DeleteJob

func (c *Client) DeleteJob(ctx context.Context, jobName string) error

DeleteJob deletes a Kubernetes Job by name

func (*Client) GetJob

func (c *Client) GetJob(ctx context.Context, jobName string) (*batchv1.Job, error)

GetJob retrieves a Kubernetes Job by name

func (*Client) GetJobLogs

func (c *Client) GetJobLogs(ctx context.Context, jobName string) (string, error)

GetJobLogs retrieves logs from a Kubernetes Job's pods

func (*Client) GetNamespace

func (c *Client) GetNamespace() string

GetNamespace returns the configured namespace for the client

func (*Client) SetNamespace

func (c *Client) SetNamespace(namespace string)

SetNamespace sets the namespace for the client

func (*Client) WaitForJobCompletion

func (c *Client) WaitForJobCompletion(ctx context.Context, jobName string) error

WaitForJobCompletion waits for a job to complete (succeed or fail). It's context-aware, so set ctx to something like `context.WithTimeout(ctx, 10*time.Second)` to set a timeout.

func (*Client) WatchJob

func (c *Client) WatchJob(ctx context.Context, jobName string) (watch.Interface, error)

WatchJob watches a Kubernetes Job for changes

type ClientInterface

type ClientInterface interface {
	GetNamespace() string
	SetNamespace(namespace string)
	CreateJob(ctx context.Context, job *batchv1.Job) (*batchv1.Job, error)
	CleanupJob(ctx context.Context, jobName string) error
	DeleteJob(ctx context.Context, jobName string) error
	WaitForJobCompletion(ctx context.Context, jobName string) error
	GetJobLogs(ctx context.Context, jobName string) (string, error)
}

ClientInterface defines the interface for Kubernetes operations. This interface exists to aid in testing.

Jump to

Keyboard shortcuts

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