Documentation ¶
Index ¶
- func CreateNamespaceIfNeed(ctx context.Context, client kubernetes.Interface, namespace string, ...) error
- func NewClient(kubeconfig *string, config Config) (kubernetes.Interface, error)
- func NewDynamicClient(kubeconfig *string, config Config) (dynamic.Interface, error)
- func WaitForJobPodsReady(ctx context.Context, clientset kubernetes.Interface, namespace string, ...) error
- func WatchJobPodLogs(ctx context.Context, clientset kubernetes.Interface, namespace, jobName string, ...) error
- type Config
- type DeleteFunc
- type ListFunc
- type Manager
- func (m *Manager) DeleteEvents(ctx context.Context, async bool) error
- func (m *Manager) DeleteJobs(ctx context.Context, labelSelector string, async bool) error
- func (m *Manager) DeleteNodes(ctx context.Context, labelSelector string, async bool) error
- func (m *Manager) DeletePods(ctx context.Context, labelSelector string, async bool) error
- func (m *Manager) Metrics() (...)
- func (m *Manager) Start(ctx context.Context) error
- func (m *Manager) Stop()
- func (m *Manager) WaitForJobsToTerminate(ctx context.Context, client kubernetes.Interface, labelSelector string) error
- func (m *Manager) WaitForNodesToTerminate(ctx context.Context, client kubernetes.Interface, labelSelector string) error
- func (m *Manager) WaitForPodsToComplete(ctx context.Context, labelSelector string, logger *slog.Logger) error
- func (m *Manager) WaitForPodsToTerminate(ctx context.Context, client kubernetes.Interface, labelSelector string) error
- type ManagerConfig
- type RateLimiterConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNamespaceIfNeed ¶ added in v0.1.2
func CreateNamespaceIfNeed(ctx context.Context, client kubernetes.Interface, namespace string, logger *slog.Logger) error
CreateNamespaceIfNeed creates the provided namespace if it does not exist.
func NewClient ¶
func NewClient(kubeconfig *string, config Config) (kubernetes.Interface, error)
NewClient creates a new Kubernetes client and automatically detects in-cluster and out-of-cluster config.
func NewDynamicClient ¶
NewDynamicClient creates a new dynamic Kubernetes client and automatically detects in-cluster and out-of-cluster config.
func WaitForJobPodsReady ¶
func WaitForJobPodsReady( ctx context.Context, clientset kubernetes.Interface, namespace string, jobName string, timeout time.Duration, ) error
WaitForJobPodsReady waits for all pods associated with the given job to become ready.
func WatchJobPodLogs ¶
func WatchJobPodLogs(ctx context.Context, clientset kubernetes.Interface, namespace, jobName string, out io.Writer) error
WatchJobPodLogs streams logs from all pods associated with the given job.
Types ¶
type DeleteFunc ¶
type DeleteFunc func(ctx context.Context, client kubernetes.Interface, deleteOpts metav1.DeleteOptions, listOpts metav1.ListOptions, async bool) error
type ListFunc ¶
type ListFunc func(ctx context.Context, client kubernetes.Interface, opts metav1.ListOptions) (empty bool, err error)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is used to manage Kubernetes resources.
func NewManager ¶
func NewManager(client kubernetes.Interface, cfg *ManagerConfig) *Manager
func (*Manager) DeleteEvents ¶ added in v0.2.2
DeleteEvents uses retries to deletes Kubernetes Event resources having provided label. If async is set to false, this function will block until jobs are terminated or context exceeds deadline.
func (*Manager) DeleteJobs ¶
DeleteJobs retries to delete Kubernetes Job resources having provided label. If async is set to false, this function will block until jobs are terminated or context exceeds deadline.
func (*Manager) DeleteNodes ¶
DeleteNodes deletes all Kubernetes Node resources having provided label. If async is set to false, this function will block until nodes are terminated or context exceeds deadline.
func (*Manager) DeletePods ¶
DeletePods retries to delete Kubernetes Pod resources having provided label. If async is set to false, this function will block until pods are terminated or context exceeds deadline.
func (*Manager) Metrics ¶
func (m *Manager) Metrics() (nodeCreationMetrics, podCreationMetrics, jobCreationMetrics ratelimiter.Metrics)
func (*Manager) Start ¶
Start starts the Manager and the pod & node creation rate limiters. It blocks until the Manager is stopped the context is cancelled or all rate limited executors have finished.
func (*Manager) WaitForJobsToTerminate ¶
func (m *Manager) WaitForJobsToTerminate(ctx context.Context, client kubernetes.Interface, labelSelector string) error
WaitForJobsToTerminate waits for the jobs with the provided labelSelector to terminate.
func (*Manager) WaitForNodesToTerminate ¶
func (m *Manager) WaitForNodesToTerminate(ctx context.Context, client kubernetes.Interface, labelSelector string) error
WaitForNodesToTerminate waits for the nodes with the provided labelSelector to terminate.
func (*Manager) WaitForPodsToComplete ¶ added in v0.2.1
func (m *Manager) WaitForPodsToComplete(ctx context.Context, labelSelector string, logger *slog.Logger) error
WaitForPodsToComplete waits for the pods with the provided labelSelector to complete.
func (*Manager) WaitForPodsToTerminate ¶
func (m *Manager) WaitForPodsToTerminate(ctx context.Context, client kubernetes.Interface, labelSelector string) error
WaitForPodsToTerminate waits for the pods with the provided labelSelector to terminate.
type ManagerConfig ¶
type ManagerConfig struct { // Namespace is the namespace in which resources should be created. Namespace string // Logger is the logger that should be used by the Manager. Logger *slog.Logger // RandomEnvVars is used to determine whether random environment variables should be added to created Pods or Jobs. RandomEnvVars bool // PodRateLimiterConfig is the configuration for the rate limited PodCreator. PodRateLimiterConfig RateLimiterConfig // NodeRateLimiterConfig is the configuration for the rate limited NodeCreator. NodeRateLimiterConfig RateLimiterConfig // JobRateLimiterConfig is the configuration for the rate limited JobCreator. JobRateLimiterConfig RateLimiterConfig }
ManagerConfig is used to configure a new Manager.
type RateLimiterConfig ¶
type RateLimiterConfig struct { // Frequency is the frequency at which the rate limiter should be invoked. Frequency time.Duration // Requests is the number of requests that should be made per invocation. Requests int // Limit is the maximum number of items that should be processed Limit int }
RateLimiterConfig is used to configure the rate limiter for a specific resource type.