kubernetes

package
v0.0.0-...-64e3f11 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCollectionRetry = 1
View Source
const DefaultInformerResync = 24
View Source
const (
	FatalNodeError = nodeError("unable to retrieve required metrics from any node via direct or proxy connection")
)

Variables

This section is empty.

Functions

func CollectKubeMetrics

func CollectKubeMetrics(config KubeAgentConfig)

CollectKubeMetrics Collects metrics from Kubernetes on a predetermined interval

func SendData

func SendData(ms *os.File, uid string, mc client.MetricClient) (err error)

SendData takes Cloudability metric sample and sends data to Cloudability via go client

Types

type ClientsetNodeSource

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

ClientsetNodeSource implements NodeSource interface

func NewClientsetNodeSource

func NewClientsetNodeSource(clientSet kubernetes.Interface) ClientsetNodeSource

NewClientsetNodeSource returns a ClientsetNodeSource with the given clientSet

func (ClientsetNodeSource) GetReadyNodes

func (cns ClientsetNodeSource) GetReadyNodes(ctx context.Context) ([]v1.Node, error)

GetReadyNodes fetches the list of nodes from the clientSet and filters down to only ready nodes

func (ClientsetNodeSource) NodeAddress

func (cns ClientsetNodeSource) NodeAddress(node *v1.Node) (string, int32, error)

NodeAddress returns the internal IP address and kubelet port of a given node

type ClusterVersion

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

ClusterVersion contains a concatenated version number as well as the k8s version discovery info

type Connection

type Connection uint8

Connection is a bitmask that describes the manner(s) in which the agent can connect to an endpoint

const (
	// By bitshifting each constant with iota we can use Connection as a bitmask
	Direct Connection = 1 << iota // 0001 = 1
	Proxy                         // 0010 = 2
	// Unreachable defined at end to avoid affecting iota,
	// as it should always be set to 0
	Unreachable Connection = 0
)

func (*Connection) AddMethod

func (c *Connection) AddMethod(method Connection)

AddMethod adds the provided nonzero method to the bitmask (use SetUnreachable for Unreachable)

func (*Connection) ClearMethod

func (c *Connection) ClearMethod(method Connection)

ClearMethod removes the method from the bitmask

func (*Connection) SetUnreachable

func (c *Connection) SetUnreachable()

SetUnreachable sets the connection as unreachable

func (Connection) String

func (c Connection) String() string

type ConnectionMethod

type ConnectionMethod struct {
	ConnType Connection
	API      nodeAPI

	FriendlyName string
	// contains filtered or unexported fields
}

type Endpoint

type Endpoint string

Endpoint represents the various metrics endpoints we hit

const (
	// NodeStatsSummaryEndpoint the /stats/summary endpoint
	NodeStatsSummaryEndpoint Endpoint = "/stats/summary"
)

type EndpointMask

type EndpointMask map[Endpoint]Connection

EndpointMask a map representing the currently active endpoints. The keys of the map are the currently active endpoints.

func (EndpointMask) Available

func (m EndpointMask) Available(endpoint Endpoint, method Connection) bool

Available gets the availability of an endpoint for the specified connection method

func (EndpointMask) DirectAllowed

func (m EndpointMask) DirectAllowed(endpoint Endpoint) bool

func (EndpointMask) Options

func (m EndpointMask) Options(endpoint Endpoint) string

func (EndpointMask) ProxyAllowed

func (m EndpointMask) ProxyAllowed(endpoint Endpoint) bool

func (EndpointMask) SetAvailability

func (m EndpointMask) SetAvailability(endpoint Endpoint, method Connection, available bool)

SetAvailability sets an endpoint availability state according to the supplied boolean

func (EndpointMask) SetUnreachable

func (m EndpointMask) SetUnreachable(endpoint Endpoint)

func (EndpointMask) Unreachable

func (m EndpointMask) Unreachable(endpoint Endpoint) bool

type KubeAgentConfig

type KubeAgentConfig struct {
	APIKey          string
	BearerToken     string
	BearerTokenPath string
	Cert            string
	ClusterName     string
	ClusterHostURL  string

	HeapsterURL       string
	Key               string
	OutboundProxyAuth string
	OutboundProxy     string

	ForceKubeProxy        bool
	Insecure              bool
	OutboundProxyInsecure bool
	UseInClusterConfig    bool
	PollInterval          int
	ConcurrentPollers     int
	CollectionRetryLimit  uint

	AgentStartTime   time.Time
	Clientset        kubernetes.Interface
	ClusterVersion   ClusterVersion
	HeapsterProxyURL url.URL
	OutboundProxyURL url.URL
	HTTPClient       http.Client
	NodeClient       raw.Client
	InClusterClient  raw.Client

	TLSClientConfig        rest.TLSClientConfig
	Namespace              string
	ScratchDir             string
	NodeMetrics            EndpointMask
	Informers              map[string]*cache.SharedIndexInformer
	InformerResyncInterval int
	ParseMetricData        bool
	// contains filtered or unexported fields
}

KubeAgentConfig K8s agent configuration

type NodeSource

type NodeSource interface {
	GetReadyNodes(ctx context.Context) ([]v1.Node, error)
	NodeAddress(node *v1.Node) (string, int32, error)
}

NodeSource is an interface to get a list of Nodes

Jump to

Keyboard shortcuts

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