cluster

package
v4.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package cluster contains a Kubernetes cluster monitor.

This plugin collects high level metrics about a K8s cluster and sends them to SignalFx. The basic technique is to pull data from the K8s API and keep up-to-date copies of datapoints for each metric that we collect and then ship them off at the end of each reporting interval. The K8s streaming watch API is used to effeciently maintain the state between read intervals (see `clusterstate.go`).

This plugin should only be run at one place in the cluster, or else metrics would be duplicated. This plugin supports two ways of ensuring that:

2) You can simply pass a config flag `alwaysClusterReporter` with value of `true` to this plugin and it will always report cluster metrics. This method uses less cluster resources (e.g. network sockets, watches on the api server) but requires special case configuration for a single agent in the cluster, which may be more error prone.

This plugin requires read-only access to the K8s API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	config.MonitorConfig
	// If `true`, leader election is skipped and metrics are always reported.
	AlwaysClusterReporter bool `yaml:"alwaysClusterReporter"`
	// If specified, only resources within the given namespace will be
	// monitored.  If omitted (blank) all supported resources across all
	// namespaces will be monitored.
	Namespace string `yaml:"namespace"`
	// If set to true, the Kubernetes node name will be used as the dimension
	// to which to sync properties about each respective node.  This is
	// necessary if your cluster's machines do not have unique machine-id
	// values, as can happen when machine images are improperly cloned.
	UseNodeName bool `yaml:"useNodeName"`
	// Config for the K8s API client
	KubernetesAPI *kubernetes.APIConfig `yaml:"kubernetesAPI" default:"{}"`
	// A list of node status condition types to report as metrics.  The metrics
	// will be reported as datapoints of the form `kubernetes.node_<type_snake_cased>`
	// with a value of `0` corresponding to "False", `1` to "True", and `-1`
	// to "Unknown".
	NodeConditionTypesToReport []string `yaml:"nodeConditionTypesToReport" default:"[\"Ready\"]"`
}

Config for the K8s monitor

func (*Config) Validate

func (c *Config) Validate() error

Validate the k8s-specific config

type Monitor

type Monitor struct {
	Output types.Output
	// contains filtered or unexported fields
}

Monitor for K8s Cluster Metrics. Also handles syncing certain properties about pods.

func (*Monitor) Configure

func (m *Monitor) Configure(config *Config) error

Configure is called by the plugin framework when configuration changes

func (*Monitor) Shutdown

func (m *Monitor) Shutdown()

Shutdown halts everything that is syncing

func (*Monitor) Start

func (m *Monitor) Start() error

Start starts syncing resources and sending datapoints to ingest

type State

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

State makes use of the K8s client's "reflector" helper to watch the API server for changes and keep the datapoint cache up to date,

func (*State) Start

func (cs *State) Start()

Start starts syncing any resource that isn't already being synced

func (*State) Stop

func (cs *State) Stop()

Stop all running goroutines. There is a bug/limitation in the k8s go client's Controller where goroutines are leaked even when using the stop channel properly. See https://github.com/kubernetes/client-go/blob/release-6.0/tools/cache/controller.go#L144

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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