kubernetes

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WorkloadTypePod = "pod"
	WorkloadTypeJob = "job"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Kubeconfig is the path to the kubeconfig file. Empty uses in-cluster config.
	Kubeconfig string `mapstructure:"kubeconfig" json:"kubeconfig"`

	// Context is the kubeconfig context to use. Empty uses the current context.
	Context string `mapstructure:"context" json:"context"`

	// Namespace is the default namespace for workloads. Defaults to "default".
	Namespace string `mapstructure:"namespace" json:"namespace"`

	// ServiceAccount is the default service account for pods.
	ServiceAccount string `mapstructure:"service_account" json:"service_account"`

	// ImagePullPolicy controls when images are pulled: "Always", "IfNotPresent", "Never".
	ImagePullPolicy string `mapstructure:"image_pull_policy" json:"image_pull_policy"`

	// ImagePullSecrets are names of secrets used for private registry auth.
	ImagePullSecrets []string `mapstructure:"image_pull_secrets" json:"image_pull_secrets"`

	// WorkloadType controls what K8s resource is created: "pod", "job". Defaults to "job".
	WorkloadType string `mapstructure:"workload_type" json:"workload_type"`

	// TTLAfterFinished is the seconds after a Job finishes before it's cleaned up. -1 disables.
	TTLAfterFinished *int32 `mapstructure:"ttl_after_finished" json:"ttl_after_finished"`

	// ActiveDeadlineSeconds is the maximum time a Job can run before being terminated.
	ActiveDeadlineSeconds *int64 `mapstructure:"active_deadline_seconds" json:"active_deadline_seconds"`
}

Config holds Kubernetes-specific workload configuration.

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

ApplyDefaults fills in zero-valued fields.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the Kubernetes configuration.

type Manager

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

Manager implements workload.Manager using the Kubernetes API.

func NewManager

func NewManager(cfg *Config, defaultLabels map[string]string, log *logger.Logger) (*Manager, error)

NewManager creates a new Kubernetes workload manager.

func (*Manager) Deploy

Deploy creates and starts a Kubernetes workload (Pod or Job).

func (*Manager) HealthCheck

func (m *Manager) HealthCheck(ctx context.Context) error

HealthCheck verifies the Kubernetes cluster is reachable.

func (*Manager) List

List returns workloads matching the given filter.

func (*Manager) Logs

func (m *Manager) Logs(ctx context.Context, id string, opts workload.LogOptions) ([]string, error)

Logs retrieves log output from a workload.

func (*Manager) Remove

func (m *Manager) Remove(ctx context.Context, id string) error

Remove is equivalent to Stop for Kubernetes (deletes the resource).

func (*Manager) Restart

func (m *Manager) Restart(ctx context.Context, id string) error

Restart deletes and recreates the pod. For Jobs, this is not directly supported.

func (*Manager) Status

func (m *Manager) Status(ctx context.Context, id string) (*workload.WorkloadStatus, error)

Status returns the current status of a workload.

func (*Manager) Stop

func (m *Manager) Stop(ctx context.Context, id string) error

Stop deletes the workload (Pod or Job).

func (*Manager) Wait

func (m *Manager) Wait(ctx context.Context, id string) (*workload.WaitResult, error)

Wait blocks until the workload exits.

Jump to

Keyboard shortcuts

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