k8s

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchNodesMetrics

func FetchNodesMetrics(c *Client) ([]mv1beta1.NodeMetrics, error)

FetchNodesMetrics retrieve metrics from metrics server.

func FetchPodsMetrics

func FetchPodsMetrics(c *Client, ns string) ([]mv1beta1.PodMetrics, error)

FetchPodsMetrics return all metrics for pods in a given namespace.

func GetNodesMetrics

func GetNodesMetrics(nodes []v1.Node, metrics []mv1beta1.NodeMetrics, mmx NodesMetrics)

GetNodesMetrics retrieves metrics for a given set of nodes.

func GetPodsMetrics

func GetPodsMetrics(pods []mv1beta1.PodMetrics, mmx PodsMetrics)

GetPodsMetrics retrieves metrics for all pods in a given namespace.

Types

type Client

type Client struct {
	*config.Config
	// contains filtered or unexported fields
}

Client represents a Kubernetes api server client.

func NewClient

func NewClient(config *config.Config) *Client

NewClient returns a dialable api server configuration.

func (*Client) ClusterHasMetrics

func (c *Client) ClusterHasMetrics() bool

ClusterHasMetrics checks if metrics server is available on the cluster.

func (*Client) Dial

func (c *Client) Dial() (kubernetes.Interface, error)

Dial returns a handle to api server.

func (*Client) DialOrDie

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

DialOrDie returns an api server client connection or dies.

func (*Client) FetchNodesMetrics

func (c *Client) FetchNodesMetrics() ([]mv1beta1.NodeMetrics, error)

FetchNodesMetrics fetch all node metrics.

func (*Client) FetchPodsMetrics

func (c *Client) FetchPodsMetrics(ns string) ([]mv1beta1.PodMetrics, error)

FetchPodsMetrics fetch all pods metrics in a given namespace.

func (*Client) GetEndpoints

func (c *Client) GetEndpoints(svcFQN string) (*v1.Endpoints, error)

GetEndpoints returns a endpoint by name.

func (*Client) GetPod

func (c *Client) GetPod(sel map[string]string) (*v1.Pod, error)

GetPod returns a pod via a label query.

func (*Client) InUseNamespaces

func (c *Client) InUseNamespaces(nss []string)

InUseNamespaces returns a list of namespaces referenced by pods.

func (*Client) ListAllNS added in v0.1.1

func (c *Client) ListAllNS() (map[string]v1.Namespace, error)

ListAllNS fetch all namespaces on this cluster.

func (*Client) ListAllPods added in v0.1.1

func (c *Client) ListAllPods() (map[string]v1.Pod, error)

ListAllPods fetch all pods on the cluster.

func (*Client) ListCRBs added in v0.1.2

func (c *Client) ListCRBs() (map[string]rbacv1.ClusterRoleBinding, error)

ListCRBs returns a ClusterRoleBindings.

func (*Client) ListEndpoints

func (c *Client) ListEndpoints() (map[string]v1.Endpoints, error)

ListEndpoints returns a endpoint by name.

func (*Client) ListNS

func (c *Client) ListNS() ([]v1.Namespace, error)

ListNS lists all available namespaces.

func (*Client) ListNodes

func (c *Client) ListNodes() ([]v1.Node, error)

ListNodes list all available nodes on the cluster.

func (*Client) ListPods

func (c *Client) ListPods() (map[string]v1.Pod, error)

ListPods list all available pods.

func (*Client) ListRBs added in v0.1.2

func (c *Client) ListRBs() (map[string]rbacv1.RoleBinding, error)

ListRBs returns all RoleBindings.

func (*Client) ListServices

func (c *Client) ListServices() ([]v1.Service, error)

ListServices lists all available services in a given namespace.

type ContainerMetrics

type ContainerMetrics map[string]Metrics

ContainerMetrics tracks container metrics

type Metrics

type Metrics struct {
	CurrentCPU int64
	CurrentMEM float64
}

Metrics represent an aggregation of all pod containers metrics.

func (Metrics) Empty

func (m Metrics) Empty() bool

Empty checks if we have any metrics.

type NodeMetrics

type NodeMetrics struct {
	CurrentCPU int64
	CurrentMEM float64
	AvailCPU   int64
	AvailMEM   float64
	TotalCPU   int64
	TotalMEM   float64
}

NodeMetrics describes raw node metrics.

func (NodeMetrics) Empty

func (n NodeMetrics) Empty() bool

Empty checks if we have any metrics.

type NodesMetrics

type NodesMetrics map[string]NodeMetrics

NodesMetrics tracks usage metrics per nodes.

type PodsMetrics

type PodsMetrics map[string]ContainerMetrics

PodsMetrics tracks usage metrics per pods.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳