common

package
v1.1.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2016 License: Apache-2.0 Imports: 13 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"
)

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

This section is empty.

Functions

func FilterNamespacedPodsByLabelSelector

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

func FilterNamespacedPodsBySelector

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

func FilterPodsByLabelSelector

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

func FilterPodsBySelector

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

Returns pods targeted by given selector.

func GetContainerImages

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

GetContainerImages returns container image strings from the given pod spec.

func IsLabelSelectorMatching

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

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 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(resourceSelector map[string]string, allPods []api.Pod,
	service api.Service, nodes []api.Node) []Endpoint

GetExternalEndpoints returns array of external endpoints for resources targeted by given selector.

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 {
	// Namespace.
	Namespace string `json:"namespace"`

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

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 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,
	nsQuery *NamespaceQuery, 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

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 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"`

	// 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 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.

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
}

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"`
}

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