k8s

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

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 wraps the Kubernetes clientset

func NewClient

func NewClient(kubeconfigPath string) (*Client, error)

NewClient creates a new Kubernetes client from a kubeconfig path

func (*Client) CheckConnection

func (c *Client) CheckConnection(ctx context.Context) error

CheckConnection verifies the connection to the cluster

func (*Client) Clientset

func (c *Client) Clientset() *kubernetes.Clientset

Clientset returns the underlying Kubernetes clientset

func (*Client) CurrentContext

func (c *Client) CurrentContext() string

CurrentContext returns the current context name

func (*Client) CurrentNamespace

func (c *Client) CurrentNamespace() string

CurrentNamespace returns the current namespace

func (*Client) DeleteDeployment added in v0.2.0

func (c *Client) DeleteDeployment(ctx context.Context, namespace, name string) error

DeleteDeployment deletes a deployment by name

func (*Client) DeletePod

func (c *Client) DeletePod(ctx context.Context, namespace, name string) error

DeletePod deletes a pod by name

func (*Client) GetAllNamespaceEvents added in v0.2.0

func (c *Client) GetAllNamespaceEvents(ctx context.Context, opts EventFilterOptions) ([]domain.Event, error)

GetAllNamespaceEvents returns events from all namespaces

func (*Client) GetClusterInfo

func (c *Client) GetClusterInfo(ctx context.Context) (*domain.ClusterInfo, error)

GetClusterInfo returns information about the connected cluster

func (*Client) GetDeployment added in v0.2.0

func (c *Client) GetDeployment(ctx context.Context, namespace, name string) (*domain.Deployment, error)

GetDeployment returns a single deployment with full details

func (*Client) GetDeployments added in v0.2.0

func (c *Client) GetDeployments(ctx context.Context, namespace string) ([]domain.Deployment, error)

GetDeployments returns all deployments in the specified namespace

func (*Client) GetEvents added in v0.2.0

func (c *Client) GetEvents(ctx context.Context, namespace string) ([]domain.Event, error)

GetEvents returns all events in the specified namespace

func (*Client) GetEventsFiltered added in v0.2.0

func (c *Client) GetEventsFiltered(ctx context.Context, namespace string, opts EventFilterOptions) ([]domain.Event, error)

GetEventsFiltered returns events with optional filtering

func (*Client) GetNamespaces

func (c *Client) GetNamespaces(ctx context.Context) ([]domain.Namespace, error)

GetNamespaces returns all namespaces with their status

func (*Client) GetPod

func (c *Client) GetPod(ctx context.Context, namespace, name string) (*domain.Pod, error)

GetPod returns a single pod by name with full details

func (*Client) GetPodContainers

func (c *Client) GetPodContainers(ctx context.Context, namespace, podName string) ([]string, error)

GetPodContainers returns the list of container names for a pod

func (*Client) GetPodEvents

func (c *Client) GetPodEvents(ctx context.Context, namespace, podName string) ([]domain.PodEvent, error)

GetPodEvents returns events for a specific pod

func (*Client) GetPodLogs

func (c *Client) GetPodLogs(ctx context.Context, namespace, podName string, opts LogOptions) (string, error)

GetPodLogs retrieves logs for a pod container

func (*Client) GetPods

func (c *Client) GetPods(ctx context.Context, namespace string) ([]domain.Pod, error)

GetPods returns all pods in the specified namespace

func (*Client) GetService added in v0.2.0

func (c *Client) GetService(ctx context.Context, namespace, name string) (*domain.Service, error)

GetService returns a single service with full details

func (*Client) GetServices added in v0.2.0

func (c *Client) GetServices(ctx context.Context, namespace string) ([]domain.Service, error)

GetServices returns all services in the specified namespace

func (*Client) ListNamespaces

func (c *Client) ListNamespaces(ctx context.Context) ([]string, error)

ListNamespaces returns all namespaces in the cluster

func (*Client) RestartDeployment added in v0.2.0

func (c *Client) RestartDeployment(ctx context.Context, namespace, name string) error

RestartDeployment triggers a rolling restart by patching the deployment's annotations

func (*Client) ScaleDeployment added in v0.2.0

func (c *Client) ScaleDeployment(ctx context.Context, namespace, name string, replicas int32) error

ScaleDeployment scales a deployment to the specified number of replicas

func (*Client) SetNamespace

func (c *Client) SetNamespace(ns string)

SetNamespace sets the current namespace

func (*Client) StreamPodLogs

func (c *Client) StreamPodLogs(ctx context.Context, namespace, podName string, opts LogOptions, lineChan chan<- string) error

StreamPodLogs streams logs for a pod container, sending each line to the provided channel The function returns when the context is cancelled or an error occurs

type EventFilterOptions added in v0.2.0

type EventFilterOptions struct {
	Type       string // "Normal", "Warning", or "" for all
	ObjectKind string // "Pod", "Deployment", etc. or "" for all
	Limit      int64  // Maximum number of events (0 = no limit)
}

EventFilterOptions specifies filters for event retrieval

type LogOptions

type LogOptions struct {
	Container  string
	Follow     bool
	TailLines  int64
	Timestamps bool
	Previous   bool
}

LogOptions configures log retrieval

func DefaultLogOptions

func DefaultLogOptions() LogOptions

DefaultLogOptions returns sensible default log options

type MetricsClient added in v0.2.0

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

MetricsClient wraps the Kubernetes metrics API client

func NewMetricsClient added in v0.2.0

func NewMetricsClient(kubeconfigPath string) (*MetricsClient, error)

NewMetricsClient creates a new metrics client from the kubeconfig path

func (*MetricsClient) CheckMetricsAvailable added in v0.2.0

func (m *MetricsClient) CheckMetricsAvailable(ctx context.Context) bool

CheckMetricsAvailable tests if the metrics server is available

func (*MetricsClient) GetPodMetric added in v0.2.0

func (m *MetricsClient) GetPodMetric(ctx context.Context, namespace, name string) (*domain.PodMetrics, error)

GetPodMetric returns metrics for a single pod

func (*MetricsClient) GetPodMetrics added in v0.2.0

func (m *MetricsClient) GetPodMetrics(ctx context.Context, namespace string) (map[string]domain.PodMetrics, error)

GetPodMetrics returns metrics for all pods in the namespace

Jump to

Keyboard shortcuts

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