Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) GetClustername() string
- func (c *Client) GetEvent(name, namespace string) Event
- func (c *Client) GetEvents(filter Filter, sortorder Sort) ([]Event, error)
- func (c *Client) GetNamespaces() ([]string, error)
- func (c *Client) GetNodes() ([]string, error)
- func (c *Client) GetNodesMetrics(sortorder Sort) ([]Node, error)
- func (c *Client) GetPod(name, namespace string, selectedContainer int) (*Pod, error)
- func (c *Client) GetPodsMetrics(filter Filter, sortorder Sort) ([]Pod, error)
- type Container
- type Event
- type Filter
- type Node
- type Pod
- type Sort
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
GetClustername returns the name of the Kubernetes cluster.
func (*Client) GetNamespaces ¶
GetNamespaces returns a slice of namespaces.
func (*Client) GetNodesMetrics ¶
GetNodesMetrics returns the metrics for all nodes.
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 ¶
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)" )