kuber

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: MIT Imports: 28 Imported by: 6

Documentation

Index

Constants

View Source
const NodeRoleLabelPrefix = "node-role.kubernetes.io/"

Variables

This section is empty.

Functions

func GetContainersByNode

func GetContainersByNode(pods []kapi.Pod) map[string]int

func RangePods

func RangePods(
	pods []kapi.Pod,
	fn func(kapi.Pod) bool) error

Types

type Container

type Container struct {
	// cluster where host of container located in
	Cluster string `json:"cluster,omitempty"`
	// image of container
	Image string `json:"image"`
	// limits of container
	Limits *ContainerResources `json:"limits,omitempty"`
	// requests of container
	Requests *ContainerResources `json:"requests,omitempty"`
	// name of container (not guaranteed to be unique in cluster scope)
	Name string `json:"name"`
	// namespace where pod located in
	Namespace string `json:"namespace"`
	// node where container located in
	Node string `json:"node"`
	// pod where container located in
	Pod string `json:"pod"`
}

Container user type.

func GetContainers

func GetContainers(
	pods []kapi.Pod,
	namespace *string,
	pod *string,
	container *string,
) ([]*Container, error)

type ContainerResources

type ContainerResources struct {
	CPU    int `json:"cpu"`
	Memory int `json:"memory"`
}

ContainerResources user type.

type ContainerResourcesRequirements

type ContainerResourcesRequirements struct {
	Name     string
	Requests RequestLimit
	Limits   RequestLimit
}

ContainerResources container resources

type Kube

type Kube struct {
	Clientset     *kubernetes.Clientset
	ClientV1Beta2 *beta2client.AppsV1beta2Client
	ClientBatch   *batch.BatchV1beta1Client
	// contains filtered or unexported fields
}

Kube kube struct

func InitKubernetes

func InitKubernetes(
	args map[string]interface{},
	client *client.Client,
) (*Kube, error)

func (*Kube) GetCronJobs

func (kube *Kube) GetCronJobs() (
	*kbeta1.CronJobList, error,
)

GetCronJobs get cron jobs

func (*Kube) GetDaemonSets

func (kube *Kube) GetDaemonSets() (
	*kbeta2.DaemonSetList, error,
)

GetDaemonSets get daemon sets

func (*Kube) GetDeployments

func (kube *Kube) GetDeployments() (*kbeta2.DeploymentList, error)

GetDeployments get deployments

func (*Kube) GetLimitRanges

func (kube *Kube) GetLimitRanges() (
	*kv1.LimitRangeList, error,
)

GetLimitRanges get limits and ranges for namespaces

func (*Kube) GetNodes

func (kube *Kube) GetNodes() (*kv1.NodeList, error)

GetNodes get kubernetes nodes

func (*Kube) GetPods

func (kube *Kube) GetPods() (*kv1.PodList, error)

GetPods get kubernetes pods

func (*Kube) GetReplicaSets

func (kube *Kube) GetReplicaSets() (
	*kbeta2.ReplicaSetList, error,
)

GetReplicaSets get replicasets

func (*Kube) GetReplicationControllers

func (kube *Kube) GetReplicationControllers() (
	*kv1.ReplicationControllerList, error,
)

GetReplicationControllers get replication controllers

func (*Kube) GetResources

func (kube *Kube) GetResources() (
	pods []kv1.Pod,
	limitRanges []kv1.LimitRange,
	resources []Resource,
	rawResources map[string]interface{},
	err error,
)

func (*Kube) GetStatefulSet

func (kube *Kube) GetStatefulSet(namespace, name string) (
	*v1.StatefulSet, error,
)

func (*Kube) GetStatefulSets

func (kube *Kube) GetStatefulSets() (
	*kbeta2.StatefulSetList, error,
)

GetStatefulSets get statuful sets

func (*Kube) SetResources

func (kube *Kube) SetResources(
	kind string,
	name string,
	namespace string,
	totalResources TotalResources,
) (skipped bool, err error)

SetResources set resources for a service

type Node

type Node struct {
	ID            uuid.UUID    `json:"id,omitempty"`
	Name          string       `json:"name"`
	IP            string       `json:"ip"`
	Roles         string       `json:"roles"`
	KubeletPort   int32        `json:"port"`
	Provider      string       `json:"provider,omitempty"`
	Region        string       `json:"region,omitempty"`
	InstanceType  string       `json:"instance_type,omitempty"`
	InstanceSize  string       `json:"instance_size,omitempty"`
	Capacity      NodeCapacity `json:"capacity"`
	Allocatable   NodeCapacity `json:"allocatable"`
	Containers    int          `json:"containers,omitempty"`
	ContainerList []*Container `json:"container_list,omitempty"`
}

func AddContainerListToNodes

func AddContainerListToNodes(
	nodes []Node,
	pods []kapi.Pod,
	namespace *string,
	pod *string,
	container *string,
) []Node

func GetNodes

func GetNodes(nodes []kapi.Node) []Node

func UpdateNodesContainers

func UpdateNodesContainers(nodes []Node, containers map[string]int) []Node

type NodeCapacity

type NodeCapacity struct {
	CPU              int `json:"cpu"`
	Memory           int `json:"memory"`
	StorageEphemeral int `json:"storage_ephemeral"`
	Pods             int `json:"pods"`
}

func GetNodeCapacity

func GetNodeCapacity(resources kapi.ResourceList) NodeCapacity

type RawResources

type RawResources struct {
	PodList        *kv1.PodList
	LimitRangeList *kv1.LimitRangeList

	CronJobList *kbeta1.CronJobList

	DeploymentList  *kbeta2.DeploymentList
	StatefulSetList *kbeta2.StatefulSetList
	DaemonSetList   *kbeta2.DaemonSetList
	ReplicaSetList  *kbeta2.ReplicaSetList
}

type RequestLimit

type RequestLimit struct {
	CPU    *int64
	Memory *int64
}

RequestLimit request limit

type Resource

type Resource struct {
	Namespace      string
	Name           string
	Kind           string
	Annotations    map[string]string
	ReplicasStatus proto.ReplicasStatus
	Containers     []kv1.Container
	PodRegexp      *regexp.Regexp
}

type TotalResources

type TotalResources struct {
	Replicas   *int
	Containers []ContainerResourcesRequirements
}

TotalResources service resources and replicas

Jump to

Keyboard shortcuts

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