common

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceKindReplicaSet            = "replicaset"
	ResourceKindService               = "service"
	ResourceKindDeployment            = "deployment"
	ResourceKindPod                   = "pod"
	ResourceKindEvent                 = "event"
	ResourceKindReplicationController = "replicationcontroller"
	ResourceKindDaemonSet             = "daemonset"
	ResourceKindJob                   = "job"
	ResourceKindPetSet                = "petset"
	ResourceKindNamespace             = "namespace"
	ResourceKindNode                  = "node"
	ResourceKindSecret                = "secret"
	ResourceKindConfigMap             = "configmap"
	ResourceKindPersistentVolume      = "persistentvolume"
)

List of all resource kinds supported by the UI.

View Source
const (
	ClientTypeDefault         = "restclient"
	ClientTypeExtensionClient = "extensionclient"
	ClientTypeAppsClient      = "appsclient"
	ClientTypeBatchClient     = "batchclient"
)

List of client types supported by the UI.

Variables

View Source
var NoPagination = NewPaginationQuery(-1, -1)

By default backend pagination will not be applied.

Functions

func FilterNamespacedPodsByLabelSelector

func FilterNamespacedPodsByLabelSelector(pods []api.Pod, namespace string,
	labelSelector *unversioned.LabelSelector) []api.Pod

FilterNamespacedPodsByLabelSelector returns pods targeted by given resource label selector in given namespace.

func FilterNamespacedPodsBySelector

func FilterNamespacedPodsBySelector(pods []api.Pod, namespace string,
	resourceSelector map[string]string) []api.Pod

FilterNamespacedPodsBySelector returns pods targeted by given resource label selector in given namespace.

func FilterNamespacedServicesBySelector added in v1.1.1

func FilterNamespacedServicesBySelector(services []api.Service, namespace string,
	resourceSelector map[string]string) []api.Service

FilterNamespacedServicesBySelector returns services targeted by given resource selector in given namespace.

func FilterPodsByLabelSelector

func FilterPodsByLabelSelector(pods []api.Pod, labelSelector *unversioned.LabelSelector) []api.Pod

FilterPodsByLabelSelector returns pods targeted by given resource label selector.

func FilterPodsBySelector

func FilterPodsBySelector(pods []api.Pod, resourceSelector map[string]string) []api.Pod

FilterPodsBySelector returns pods targeted by given resource selector.

func GetContainerImages

func GetContainerImages(podTemplate *api.PodSpec) []string

GetContainerImages returns container image strings from the given pod spec.

func GetNodeByName

func GetNodeByName(nodes []api.Node, nodeName string) *api.Node

GetNodeByName returns the node with the given name from the list

func IsLabelSelectorMatching

func IsLabelSelectorMatching(selector map[string]string,
	labelSelector *unversioned.LabelSelector) bool

IsLabelSelectorMatching returns true when a resource with the given selector targets the same Resources(or subset) that a tested object selector with the given selector.

func IsSelectorMatching

func IsSelectorMatching(labelSelector map[string]string,
	testedObjectLabels map[string]string) bool

IsSelectorMatching returns true when an object with the given selector targets the same Resources (or subset) that the tested object with the given selector.

Types

type ClientType

type ClientType string

ClientType represents type of client that is used to perform generic operations on resources. Different resources belong to different client, i.e. Deployments belongs to extension client and PetSets to apps client.

type ConfigMapListChannel added in v1.1.1

type ConfigMapListChannel struct {
	List  chan *api.ConfigMapList
	Error chan error
}

ConfigMapListChannel is a list and error channels to ConfigMaps.

func GetConfigMapListChannel added in v1.1.1

func GetConfigMapListChannel(client client.ConfigMapsNamespacer, nsQuery *NamespaceQuery, numReads int) ConfigMapListChannel

GetConfigMapListChannel returns a pair of channels to a ConfigMap list and errors that both must be read numReads times.

type DaemonSetListChannel

type DaemonSetListChannel struct {
	List  chan *extensions.DaemonSetList
	Error chan error
}

DaemonSetListChannel is a list and error channels to Nodes.

func GetDaemonSetListChannel

func GetDaemonSetListChannel(client client.DaemonSetsNamespacer,
	nsQuery *NamespaceQuery, numReads int) DaemonSetListChannel

GetDaemonSetListChannel returns a pair of channels to a DaemonSet list and errors that both must be read numReads times.

type DeploymentListChannel

type DeploymentListChannel struct {
	List  chan *extensions.DeploymentList
	Error chan error
}

DeploymentListChannel is a list and error channels to Deployments.

func GetDeploymentListChannel

func GetDeploymentListChannel(client client.DeploymentsNamespacer,
	nsQuery *NamespaceQuery, numReads int) DeploymentListChannel

GetDeploymentListChannel returns a pair of channels to a Deployment list and errors that both must be read numReads times.

type Endpoint

type Endpoint struct {
	// Hostname, either as a domain name or IP address.
	Host string `json:"host"`

	// List of ports opened for this endpoint on the hostname.
	Ports []ServicePort `json:"ports"`
}

Endpoint describes an endpoint that is host and a list of available ports for that host.

func GetExternalEndpoints

func GetExternalEndpoints(service *api.Service) []Endpoint

GetExternalEndpoints returns endpoints that are externally reachable for a service.

func GetInternalEndpoint

func GetInternalEndpoint(serviceName, namespace string, ports []api.ServicePort) Endpoint

GetInternalEndpoint returns internal endpoint name for the given service properties, e.g., "my-service.namespace 80/TCP" or "my-service 53/TCP,53/UDP".

type Event

type Event struct {
	ObjectMeta ObjectMeta `json:"objectMeta"`
	TypeMeta   TypeMeta   `json:"typeMeta"`

	// A human-readable description of the status of related object.
	Message string `json:"message"`

	// Component from which the event is generated.
	SourceComponent string `json:"sourceComponent"`

	// Host name on which the event is generated.
	SourceHost string `json:"sourceHost"`

	// Reference to a piece of an object, which triggered an event. For example
	// "spec.containers{name}" refers to container within pod with given name, if no container
	// name is specified, for example "spec.containers[2]", then it refers to container with
	// index 2 in this pod.
	SubObject string `json:"object"`

	// The number of times this event has occurred.
	Count int32 `json:"count"`

	// The time at which the event was first recorded.
	FirstSeen unversioned.Time `json:"firstSeen"`

	// The time at which the most recent occurrence of this event was recorded.
	LastSeen unversioned.Time `json:"lastSeen"`

	// Short, machine understandable string that gives the reason
	// for this event being generated.
	Reason string `json:"reason"`

	// Event type (at the moment only normal and warning are supported).
	Type string `json:"type"`
}

Event is a single event representation.

type EventList

type EventList struct {
	ListMeta ListMeta `json:"listMeta"`

	// List of events from given namespace.
	Events []Event `json:"events"`
}

EventList is an events response structure.

type EventListChannel

type EventListChannel struct {
	List  chan *api.EventList
	Error chan error
}

EventListChannel is a list and error channels to Nodes.

func GetEventListChannel

func GetEventListChannel(client client.EventNamespacer,
	nsQuery *NamespaceQuery, numReads int) EventListChannel

GetEventListChannel returns a pair of channels to an Event list and errors that both must be read numReads times.

func GetEventListChannelWithOptions

func GetEventListChannelWithOptions(client client.EventNamespacer,
	nsQuery *NamespaceQuery, options api.ListOptions, numReads int) EventListChannel

GetEventListChannelWithOptions is GetEventListChannel plus list options.

type JobListChannel

type JobListChannel struct {
	List  chan *batch.JobList
	Error chan error
}

JobListChannel is a list and error channels to Nodes.

func GetJobListChannel

func GetJobListChannel(client client.JobsNamespacer,
	nsQuery *NamespaceQuery, numReads int) JobListChannel

GetJobListChannel returns a pair of channels to a Job list and errors that both must be read numReads times.

type ListMeta added in v1.1.1

type ListMeta struct {
	// Total number of items on the list. Used for pagination.
	TotalItems int `json:"totalItems"`
}

ListMeta describes list of objects, i.e. holds information about pagination options set for the list.

type MetricResult added in v1.1.1

type MetricResult struct {
	Timestamp time.Time `json:"timestamp"`
	Value     uint64    `json:"value"`
}

MetricResult is a some sample measurement of a non-negative, integer quantity (for example, memory usage in bytes observed at some moment)

type MetricsByPod added in v1.1.1

type MetricsByPod struct {
	// Metrics by namespace and name of a pod.
	MetricsMap map[string]map[string]PodMetrics `json:"metricsMap"`
}

MetricsByPod is a metrics map by pod name.

type NamespaceQuery

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

NamespaceQuery is a query for namespaces of a list of objects. There's three cases:

  1. No namespace selected: this means "user namespaces" query, i.e., all except kube-system
  2. Single namespace selected: this allows for optimizations when querying backends
  3. More than one namespace selected: resources from all namespaces are queried and then filtered here.

func NewNamespaceQuery

func NewNamespaceQuery(namespaces []string) *NamespaceQuery

NewNamespaceQuery creates new query for given namespaces.

func NewSameNamespaceQuery

func NewSameNamespaceQuery(namespace string) *NamespaceQuery

NewSameNamespaceQuery creates new namespace query that queries single namespace.

func (*NamespaceQuery) Matches

func (n *NamespaceQuery) Matches(namespace string) bool

Matches returns true when the given namespace matches this query.

func (*NamespaceQuery) ToRequestParam

func (n *NamespaceQuery) ToRequestParam() string

ToRequestParam returns K8s API namespace query for list of objects from this namespaces. This is an optimization to query for single namespace if one was selected and for all namespaces otherwise.

type NodeListChannel

type NodeListChannel struct {
	List  chan *api.NodeList
	Error chan error
}

NodeListChannel is a list and error channels to Nodes.

func GetNodeListChannel

func GetNodeListChannel(client client.NodesInterface, numReads int) NodeListChannel

GetNodeListChannel returns a pair of channels to a Node list and errors that both must be read numReads times.

type ObjectMeta

type ObjectMeta struct {
	// Name is unique within a namespace. Name is primarily intended for creation
	// idempotence and configuration definition.
	Name string `json:"name,omitempty"`

	// Namespace defines the space within which name must be unique. An empty namespace is
	// equivalent to the "default" namespace, but "default" is the canonical representation.
	// Not all objects are required to be scoped to a namespace - the value of this field for
	// those objects will be empty.
	Namespace string `json:"namespace,omitempty"`

	// Labels are key value pairs that may be used to scope and select individual resources.
	// Label keys are of the form:
	//     label-key ::= prefixed-name | name
	//     prefixed-name ::= prefix '/' name
	//     prefix ::= DNS_SUBDOMAIN
	//     name ::= DNS_LABEL
	// The prefix is optional.  If the prefix is not specified, the key is assumed to be private
	// to the user.  Other system components that wish to use labels must specify a prefix.
	Labels map[string]string `json:"labels,omitempty"`

	// Annotations are unstructured key value data stored with a resource that may be set by
	// external tooling. They are not queryable and should be preserved when modifying
	// objects.  Annotation keys have the same formatting restrictions as Label keys. See the
	// comments on Labels for details.
	Annotations map[string]string `json:"annotations,omitempty"`

	// CreationTimestamp is a timestamp representing the server time when this object was
	// created. It is not guaranteed to be set in happens-before order across separate operations.
	// Clients may not set this value. It is represented in RFC3339 form and is in UTC.
	CreationTimestamp unversioned.Time `json:"creationTimestamp,omitempty"`
}

ObjectMeta is metadata about an instance of a resource.

func NewObjectMeta

func NewObjectMeta(k8SObjectMeta api.ObjectMeta) ObjectMeta

NewObjectMeta returns internal endpoint name for the given service properties, e.g., NewObjectMeta creates a new instance of ObjectMeta struct based on K8s object meta.

type PaginationQuery added in v1.1.1

type PaginationQuery struct {
	// How many items per page should be returned
	ItemsPerPage int
	// Number of page that should be returned when pagination is applied to the list
	Page int
}

PaginationQuery structure represents pagination settings

func NewPaginationQuery added in v1.1.1

func NewPaginationQuery(itemsPerPage, page int) *PaginationQuery

NewPaginationQuery return pagination query structure based on given parameters

func (*PaginationQuery) CanPaginate added in v1.1.1

func (p *PaginationQuery) CanPaginate(itemsCount, startingIndex int) bool

CanPaginate returns true if pagination can be applied to the list, false otherwise

func (*PaginationQuery) GetPaginationSettings added in v1.1.1

func (p *PaginationQuery) GetPaginationSettings(itemsCount int) (startIndex int, endIndex int)

GetPaginationSettings based on number of items and pagination query parameters returns start and end index that can be used to return paginated list of items.

type PersistentVolumeListChannel added in v1.1.1

type PersistentVolumeListChannel struct {
	List  chan *api.PersistentVolumeList
	Error chan error
}

PersistentVolumeListChannel is a list and error channels to PersistentVolumes.

func GetPersistentVolumeListChannel added in v1.1.1

func GetPersistentVolumeListChannel(client client.PersistentVolumesInterface, numReads int) PersistentVolumeListChannel

GetPersistentVolumeListChannel returns a pair of channels to a PersistentVolume list and errors that both must be read numReads times.

type PetSetListChannel

type PetSetListChannel struct {
	List  chan *apps.PetSetList
	Error chan error
}

PetSetListChannel is a list and error channels to Nodes.

func GetPetSetListChannel

func GetPetSetListChannel(client client.PetSetNamespacer,
	nsQuery *NamespaceQuery, numReads int) PetSetListChannel

GetPetSetListChannel returns a pair of channels to a PetSet list and errors that both must be read numReads times.

type PodInfo

type PodInfo struct {
	// Number of pods that are created.
	Current int32 `json:"current"`

	// Number of pods that are desired.
	Desired int32 `json:"desired"`

	// Number of pods that are currently running.
	Running int32 `json:"running"`

	// Number of pods that are currently waiting.
	Pending int32 `json:"pending"`

	// Number of pods that are failed.
	Failed int32 `json:"failed"`

	// Number of pods that are succeeded.
	Succeeded int32 `json:"succeeded"`

	// Unique warning messages related to pods in this resource.
	Warnings []Event `json:"warnings"`
}

PodInfo represents aggregate information about controller's pods.

func GetPodInfo

func GetPodInfo(current int32, desired int32, pods []api.Pod) PodInfo

GetPodInfo returns aggregate information about a group of pods.

type PodListChannel

type PodListChannel struct {
	List  chan *api.PodList
	Error chan error
}

PodListChannel is a list and error channels to Nodes.

func GetPodListChannel

func GetPodListChannel(client client.PodsNamespacer,
	nsQuery *NamespaceQuery, numReads int) PodListChannel

GetPodListChannel returns a pair of channels to a Pod list and errors that both must be read numReads times.

func GetPodListChannelWithOptions

func GetPodListChannelWithOptions(client client.PodsNamespacer, nsQuery *NamespaceQuery,
	options api.ListOptions, numReads int) PodListChannel

GetPodListChannelWithOptions is GetPodListChannel plus listing options.

type PodMetrics added in v1.1.1

type PodMetrics struct {
	// Most recent measure of CPU usage on all cores in nanoseconds.
	CPUUsage *uint64 `json:"cpuUsage"`
	// Pod memory usage in bytes.
	MemoryUsage *uint64 `json:"memoryUsage"`
	// Timestamped samples of CPUUsage over some short period of history
	CPUUsageHistory []MetricResult `json:"cpuUsageHistory"`
	// Timestamped samples of pod memory usage over some short period of history
	MemoryUsageHistory []MetricResult `json:"memoryUsageHistory"`
}

PodMetrics is a structure representing pods metrics, contains information about CPU and memory usage.

type PodMetricsChannel added in v1.1.1

type PodMetricsChannel struct {
	MetricsByPod chan *MetricsByPod
	Error        chan error
}

PodMetricsChannel is a list and error channels to MetricsByPod.

func GetPodListMetricsChannel added in v1.1.1

func GetPodListMetricsChannel(heapsterClient kdClient.HeapsterClient, pods []api.Pod, numReads int) PodMetricsChannel

GetPodListMetricsChannel returns a pair of channels to MetricsByPod and errors that both must be read numReads times.

func GetPodMetricsChannel added in v1.1.1

func GetPodMetricsChannel(heapsterClient kdClient.HeapsterClient, name string, namespace string) PodMetricsChannel

GetPodMetricsChannel returns a pair of channels to MetricsByPod and errors that both must be read 1 time.

type RESTClient

type RESTClient interface {
	Delete() *restclient.Request
	Put() *restclient.Request
	Get() *restclient.Request
}

RESTClient is an interface for REST operations used in this file.

type ReplicaSetListChannel

type ReplicaSetListChannel struct {
	List  chan *extensions.ReplicaSetList
	Error chan error
}

ReplicaSetListChannel is a list and error channels to Replica Sets.

func GetReplicaSetListChannel

func GetReplicaSetListChannel(client client.ReplicaSetsNamespacer,
	nsQuery *NamespaceQuery, numReads int) ReplicaSetListChannel

GetReplicaSetListChannel returns a pair of channels to a ReplicaSet list and errors that both must be read numReads times.

func GetReplicaSetListChannelWithOptions

func GetReplicaSetListChannelWithOptions(client client.ReplicaSetsNamespacer,
	nsQuery *NamespaceQuery, options api.ListOptions, numReads int) ReplicaSetListChannel

GetReplicaSetListChannelWithOptions returns a pair of channels to a ReplicaSet list filtered by provided options and errors that both must be read numReads times.

type ReplicationControllerListChannel

type ReplicationControllerListChannel struct {
	List  chan *api.ReplicationControllerList
	Error chan error
}

ReplicationControllerListChannel is a list and error channels to Nodes.

func GetReplicationControllerListChannel

func GetReplicationControllerListChannel(client client.ReplicationControllersNamespacer,
	nsQuery *NamespaceQuery, numReads int) ReplicationControllerListChannel

GetReplicationControllerListChannel Returns a pair of channels to a Replication Controller list and errors that both must be read numReads times.

type ResourceChannels

type ResourceChannels struct {
	// List and error channels to Replication Controllers.
	ReplicationControllerList ReplicationControllerListChannel

	// List and error channels to Replica Sets.
	ReplicaSetList ReplicaSetListChannel

	// List and error channels to Deployments.
	DeploymentList DeploymentListChannel

	// List and error channels to Daemon Sets.
	DaemonSetList DaemonSetListChannel

	// List and error channels to Jobs.
	JobList JobListChannel

	// List and error channels to Services.
	ServiceList ServiceListChannel

	// List and error channels to Pods.
	PodList PodListChannel

	// List and error channels to Events.
	EventList EventListChannel

	// List and error channels to Nodes.
	NodeList NodeListChannel

	// List and error channels to PetSets.
	PetSetList PetSetListChannel

	// List and error channels to PetSets.
	ConfigMapList ConfigMapListChannel

	// List and error channels to PodMetrics.
	PodMetrics PodMetricsChannel

	// List and error channels to PersistentVolumes
	PersistentVolumeList PersistentVolumeListChannel
}

ResourceChannels struct holds channels to resource lists. Each list channel is paired with an error channel which *must* be read sequentially: first read the list channel and then the error channel.

This struct can be used when there are multiple clients that want to process, e.g., a list of pods. With this helper, the list can be read only once from the backend and distributed asynchronously to clients that need it.

When a channel is nil, it means that no resource list is available for getting.

Each channel pair can be read up to N times. N is specified upon creation of the channels.

type ResourceKind

type ResourceKind string

ResourceKind is an unique name for each resource. It can used for API discovery and generic code that does things based on the kind. For example, there may be a generic "deleter" that based on resource kind, name and namespace deletes it.

type ResourceVerber

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

ResourceVerber is a struct responsible for doing common verb operations on resources, like DELETE, PUT, UPDATE.

func NewResourceVerber

func NewResourceVerber(client, extensionsClient, appsClient,
	batchClient RESTClient) ResourceVerber

NewResourceVerber creates a new resource verber that uses the given client for performing operations.

func (*ResourceVerber) Delete

func (verber *ResourceVerber) Delete(kind string, namespace string, name string) error

Delete deletes the resource of the given kind in the given namespace with the given name.

func (*ResourceVerber) Get

func (verber *ResourceVerber) Get(kind string, namespace string, name string) (runtime.Object, error)

Get gets the resource of the given kind in the given namespace with the given name.

func (*ResourceVerber) Put

func (verber *ResourceVerber) Put(kind string, namespace string, name string,
	object runtime.Object) error

Put puts new resource version of the given kind in the given namespace with the given name.

type ServiceListChannel

type ServiceListChannel struct {
	List  chan *api.ServiceList
	Error chan error
}

ServiceListChannel is a list and error channels to Services.

func GetServiceListChannel

func GetServiceListChannel(client client.ServicesNamespacer,
	nsQuery *NamespaceQuery, numReads int) ServiceListChannel

GetServiceListChannel returns a pair of channels to a Service list and errors that both must be read numReads times.

type ServicePort

type ServicePort struct {
	// Positive port number.
	Port int32 `json:"port"`

	// Protocol name, e.g., TCP or UDP.
	Protocol api.Protocol `json:"protocol"`

	// The port on each node on which service is exposed.
	NodePort int32 `json:"nodePort"`
}

ServicePort is a pair of port and protocol, e.g. a service endpoint.

func GetServicePorts

func GetServicePorts(apiPorts []api.ServicePort) []ServicePort

GetServicePorts returns human readable name for the given service ports list.

type TypeMeta

type TypeMeta struct {
	// Kind is a string value representing the REST resource this object represents.
	// Servers may infer this from the endpoint the client submits requests to.
	// In smalllettercase.
	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds
	Kind ResourceKind `json:"kind,omitempty"`
}

TypeMeta describes an individual object in an API response or request with strings representing the type of the object.

func NewTypeMeta

func NewTypeMeta(kind ResourceKind) TypeMeta

NewTypeMeta creates new type mete for the resource kind.

Jump to

Keyboard shortcuts

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