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 ¶
- Variables
- func AvailableContexts(kubeconfigPath string) ([]string, error)
- type Client
- func ConnectAll(ctx context.Context, kubeconfigPath string, contexts []string, workers int) []*Client
- func NewClient(_ context.Context, kubeconfigPath, contextName string) (*Client, error)
- func NewTestClient(contextName string, vi *TestVersionInfo) *Client
- func NewTestClientWithClientset(contextName string, cs kubernetes.Interface) *Client
- func NewTestClientWithDynamic(contextName string, cs kubernetes.Interface, dyn dynamic.Interface) *Client
- type TestVersionInfo
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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.
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.