k8s

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package k8s provides Kubernetes cluster interaction capabilities. This file contains caching functionality for cluster status.

Package k8s provides Kubernetes cluster interaction capabilities. This file contains helper functions for collecting cluster health data.

Package k8s provides Kubernetes cluster interaction capabilities. It handles kubeconfig parsing, cluster discovery, and status monitoring across multiple Kubernetes clusters with support for concurrent operations.

Package k8s provides Kubernetes cluster interaction capabilities. This file defines shared types used by the provider and collectors.

Index

Constants

View Source
const (
	// DefaultAPITimeout is the default timeout for Kubernetes API calls
	DefaultAPITimeout = 30 * time.Second
	// DiscoveryTimeout is the timeout for discovery API calls (version checks)
	DiscoveryTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedClusterStatus

type CachedClusterStatus struct {
	Status    *ClusterStatus
	ExpiresAt time.Time
}

CachedClusterStatus holds a cached cluster status with expiration

type ClusterInfo

type ClusterInfo struct {
	Name        string
	Server      string
	Context     string
	User        string
	Namespace   string
	IsCurrent   bool
	IsReachable bool
}

ClusterInfo represents information about a Kubernetes cluster

type ClusterStatus

type ClusterStatus struct {
	ClusterInfo
	Version       string
	NodeCount     int
	HealthyNodes  int
	Nodes         []NodeInfo
	NamespaceList []string
	APIServerURL  string
	Error         string
	PodCount      int
	HealthyPods   int
	UnhealthyPods []PodInfo
}

ClusterStatus represents detailed status information about a cluster

type NodeInfo

type NodeInfo struct {
	Name   string
	Status string
	Roles  []string
	Age    string
}

NodeInfo represents information about a Kubernetes node

type PodInfo

type PodInfo struct {
	Name      string
	Namespace string
	Status    string
	Reason    string
	Restarts  int32
}

PodInfo represents information about an unhealthy pod

type Provider

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

Provider manages Kubernetes cluster information and operations

func NewProvider

func NewProvider(kubeconfigPath string) (*Provider, error)

NewProvider creates a new Kubernetes provider

func (*Provider) ClearCache

func (p *Provider) ClearCache()

ClearCache clears all cached cluster statuses

func (*Provider) GetAllClusterStatuses

func (p *Provider) GetAllClusterStatuses(ctx context.Context) []*ClusterStatus

GetAllClusterStatuses returns status information for all clusters in parallel

func (*Provider) GetClusterByContext

func (p *Provider) GetClusterByContext(contextName string) (*ClusterInfo, error)

GetClusterByContext returns cluster information for a specific context

func (*Provider) GetClusterStatus

func (p *Provider) GetClusterStatus(ctx context.Context, contextName string) (*ClusterStatus, error)

func (*Provider) GetClusters

func (p *Provider) GetClusters() []*ClusterInfo

GetClusters returns a list of all clusters in the kubeconfig

func (*Provider) GetCurrentContext

func (p *Provider) GetCurrentContext() string

GetCurrentContext returns the current context name

func (*Provider) SetCacheTTL

func (p *Provider) SetCacheTTL(ttl time.Duration)

SetCacheTTL sets the cache time-to-live duration

func (*Provider) SetCurrentContext

func (p *Provider) SetCurrentContext(contextName string) error

SetCurrentContext overrides the current context

Jump to

Keyboard shortcuts

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