api

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConfigNotFound is thrown if there is not a confgiuration file for Kubernetes.
	ErrConfigNotFound = errors.New("config not found")
)

Functions

This section is empty.

Types

type Client

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

Client implements the our API client for Kubernetes.

func NewClient

func NewClient(kubeconfig string) (*Client, error)

NewClient initialize our client for Kubernetes. As first we check the 'kubeconfig' command-line flag which is passed as argument to our function. If the flag is not provided we check the 'KUBECONFIG' environment variable. In the last step we check the home directory of the user for the configuration file of Kubernetes.

func (*Client) GetClustername

func (c *Client) GetClustername() string

GetClustername returns the name of the Kubernetes cluster.

func (*Client) GetEvent added in v1.1.0

func (c *Client) GetEvent(name, namespace string) Event

GetEvent returns a single event.

func (*Client) GetEvents added in v1.1.0

func (c *Client) GetEvents(filter Filter, sortorder Sort) ([]Event, error)

GetEvents returns events.

func (*Client) GetNamespaces

func (c *Client) GetNamespaces() ([]string, error)

GetNamespaces returns a slice of namespaces.

func (*Client) GetNodes

func (c *Client) GetNodes() ([]string, error)

GetNodes returns a slice of node names.

func (*Client) GetNodesMetrics

func (c *Client) GetNodesMetrics(sortorder Sort) ([]Node, error)

GetNodesMetrics returns the metrics for all nodes.

func (*Client) GetPod

func (c *Client) GetPod(name, namespace string, selectedContainer int) (*Pod, error)

GetPod returns a pod with all details.

func (*Client) GetPodsMetrics

func (c *Client) GetPodsMetrics(filter Filter, sortorder Sort) ([]Pod, error)

GetPodsMetrics returns metrics for all pods.

type Container

type Container struct {
	Name      string
	Memory    int64
	MemoryMax int64
	MemoryMin int64
	CPU       int64
	CPUMax    int64
	CPUMin    int64
	Status    string
	Restarts  int32
}

Container represents a container in a pod of the Kubernetes cluster with all needed fields.

type Event

type Event struct {
	UID            string
	Message        string
	Timestamp      int64
	Count          int32
	Name           string
	Namespace      string
	Kind           string
	Type           string
	Reason         string
	Source         string
	Node           string
	FirstTimestamp time.Time
	LastTimestamp  time.Time
}

Event represents a event in a pod of the Kubernetes cluster with all needed fields.

type Filter

type Filter struct {
	Namespace string
	Node      string
	Status    int
	EventType string
}

Filter is our custom type which applies a filter for the data which is returned by the Kubernetes API.

type Node

type Node struct {
	Name        string
	PodsCount   int
	MemoryTotal int64
	MemoryUsed  int64
	CPUTotal    int64
	CPUUsed     int64
	ExternalIP  string
	InternalIP  string
}

Node represents a node in the Kubernetes cluster with all needed fields.

type Pod

type Pod struct {
	Name                    string
	Namespace               string
	NodeName                string
	Memory                  int64
	MemoryMax               int64
	MemoryMaxContainerCount int64
	CPU                     int64
	CPUMax                  int64
	CPUMaxContainerCount    int64
	ContainersCount         int
	ContainersReady         int64
	Status                  string
	StatusGeneral           int
	Restarts                int64
	Labels                  map[string]string
	Annotations             map[string]string
	ControlledBy            []string
	CreationDate            time.Time
	IP                      string
	Containers              []Container
	LogLines                []string
	Events                  []Event
}

Pod represents a pod in the Kubernetes cluster with all needed fields.

type Sort

type Sort string

Sort is our custom type which represents the sort order for the data which is returned by the Kubernetes API.

const (
	// SortCPUASC sorts the results of an API request by cpu usage (ASC).
	SortCPUASC Sort = "CPU (A)"
	// SortCPUDESC sorts the results of an API request by cpu usage (DESC).
	SortCPUDESC Sort = "CPU (D)"
	// SortMemoryASC sorts the results of an API request by memory usage (ASC).
	SortMemoryASC Sort = "Memory (A)"
	// SortMemoryDESC sorts the results of an API request by memory usage (DESC).
	SortMemoryDESC Sort = "Memory (D)"
	// SortName sorts the results of an API request by the name.
	SortName Sort = "Name"
	// SortNamespace sorts the results of an API request by the namespace.
	SortNamespace Sort = "Namespace"
	// SortPodsASC sorts the results of an API request by the number of pods (ASC).
	SortPodsASC Sort = "Pods (A)"
	// SortPodsDESC sorts the results of an API request by the number of pods (DESC).
	SortPodsDESC Sort = "Pods (D)"
	// SortRestartsASC sorts the results of an API request by the number of restarts (asc).
	SortRestartsASC Sort = "Restarts (A)"
	// SortRestartsDESC sorts the results of an API request by the number of restarts (desc).
	SortRestartsDESC Sort = "Restarts (D)"
	// SortStatus sorts the results of an API request by the status.
	SortStatus Sort = "Status"
	// SortTimeASC sorts the results of an API request by the timestamp (asc).
	SortTimeASC = "Timestamp (A)"
	// SortTimeDESC sorts the results of an API request by the timestamp (desc).
	SortTimeDESC = "Timestamp (D)"
)

Jump to

Keyboard shortcuts

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