kube

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package kube wraps client-go and provides Fleetsweeper's connection helpers for multi-cluster scans, including QPS/burst tuning, a user agent for apiserver audit trails, and concurrent ConnectAll fan-out.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLoadConfig indicates a failure loading or parsing the kubeconfig file.
	ErrLoadConfig = errors.New("load kubeconfig")
	// ErrConnect indicates a failure connecting to a cluster.
	ErrConnect = errors.New("connect to cluster")
)

Functions

func AvailableContexts

func AvailableContexts(kubeconfigPath string) ([]string, error)

AvailableContexts returns all context names defined in the kubeconfig file.

Types

type Client

type Client struct {
	// Context is the kubeconfig context name this client is connected to.
	Context string
	// contains filtered or unexported fields
}

Client wraps a Kubernetes client connection to a single cluster.

func ConnectAll

func ConnectAll(ctx context.Context, kubeconfigPath string, contexts []string, workers int) []*Client

ConnectAll connects to the given kubeconfig contexts concurrently. Unreachable clusters are logged as warnings and excluded from the result.

func NewClient

func NewClient(_ context.Context, kubeconfigPath, contextName string) (*Client, error)

NewClient creates a Client connected to the named kubeconfig context. When kubeconfigPath is empty and the process is running inside a Kubernetes pod the in-cluster service account configuration is used instead and the "in-cluster" context name is returned.

func NewTestClient

func NewTestClient(contextName string, vi *TestVersionInfo) *Client

NewTestClient creates a Client backed by a fake clientset for testing.

func NewTestClientWithClientset

func NewTestClientWithClientset(contextName string, cs kubernetes.Interface) *Client

NewTestClientWithClientset creates a Client using the provided fake clientset.

func NewTestClientWithDynamic added in v0.1.1

func NewTestClientWithDynamic(contextName string, cs kubernetes.Interface, dyn dynamic.Interface) *Client

NewTestClientWithDynamic creates a Client backed by both a typed clientset and a dynamic client, for scanners that consult discovery and the dynamic API. Either interface may be nil when a test does not exercise it.

func (*Client) Clientset

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

Clientset returns the typed Kubernetes client interface.

func (*Client) Dynamic

func (c *Client) Dynamic() dynamic.Interface

Dynamic returns the dynamic Kubernetes client interface.

type TestVersionInfo

type TestVersionInfo struct {
	// Major is the major version number.
	Major string
	// Minor is the minor version number.
	Minor string
	// GitVersion is the full version string.
	GitVersion string
	// Platform is the server platform string.
	Platform string
}

TestVersionInfo holds version data for constructing test clients.

Jump to

Keyboard shortcuts

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