common

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualIgnoreHash added in v1.6.1

func EqualIgnoreHash(template1, template2 v1.PodTemplateSpec) bool

EqualIgnoreHash returns true if two given podTemplateSpec are equal, ignoring the diff in value of Labels[pod-template-hash] We ignore pod-template-hash because the hash result would be different upon podTemplateSpec API changes (e.g. the addition of a new field will cause the hash code to change) Note that we assume input podTemplateSpecs contain non-empty labels

func FilterDeploymentPodsByOwnerReference added in v1.6.1

func FilterDeploymentPodsByOwnerReference(deployment apps.Deployment, allRS []apps.ReplicaSet,
	allPods []v1.Pod) []v1.Pod

FilterPodsByControllerResource returns a subset of pods controlled by given deployment.

func FilterNamespacedServicesBySelector added in v1.1.1

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

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

func FilterPodsByControllerRef added in v1.7.0

func FilterPodsByControllerRef(owner metav1.Object, allPods []v1.Pod) []v1.Pod

FilterPodsByControllerRef returns a subset of pods controlled by given controller resource, excluding deployments.

func FilterPodsForJob added in v1.6.2

func FilterPodsForJob(job batch.Job, pods []v1.Pod) []v1.Pod

func GetContainerImages

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

GetContainerImages returns container image strings from the given pod spec.

func GetContainerNames added in v1.6.2

func GetContainerNames(podTemplate *v1.PodSpec) []string

GetContainerNames returns the container image name without the version number from the given pod spec.

func GetInitContainerImages added in v1.8.0

func GetInitContainerImages(podTemplate *v1.PodSpec) []string

GetInitContainerImages returns init container image strings from the given pod spec.

func GetInitContainerNames added in v1.8.0

func GetInitContainerNames(podTemplate *v1.PodSpec) []string

GetInitContainerNames returns the init container image name without the version number from the given pod spec.

Types

type ClusterRoleBindingListChannel added in v1.6.1

type ClusterRoleBindingListChannel struct {
	List  chan *rbac.ClusterRoleBindingList
	Error chan error
}

ClusterRoleBindingListChannel is a list and error channels to ClusterRoleBindings.

func GetClusterRoleBindingListChannel added in v1.6.1

func GetClusterRoleBindingListChannel(client client.Interface,
	numReads int) ClusterRoleBindingListChannel

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

type ClusterRoleListChannel added in v1.6.1

type ClusterRoleListChannel struct {
	List  chan *rbac.ClusterRoleList
	Error chan error
}

ClusterRoleListChannel is a list and error channels to ClusterRoles.

func GetClusterRoleListChannel added in v1.6.1

func GetClusterRoleListChannel(client client.Interface, numReads int) ClusterRoleListChannel

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

type Condition added in v1.5.0

type Condition struct {
	// Type of a condition.
	Type string `json:"type"`
	// Status of a condition.
	Status api.ConditionStatus `json:"status"`
	// Last probe time of a condition.
	LastProbeTime v1.Time `json:"lastProbeTime"`
	// Last transition time of a condition.
	LastTransitionTime v1.Time `json:"lastTransitionTime"`
	// Reason of a condition.
	Reason string `json:"reason"`
	// Message of a condition.
	Message string `json:"message"`
}

Condition represents a single condition of a pod or node.

type ConfigMapListChannel added in v1.1.1

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

ConfigMapListChannel is a list and error channels to ConfigMaps.

func GetConfigMapListChannel added in v1.1.1

func GetConfigMapListChannel(client client.Interface, 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 CronJobListChannel added in v1.8.0

type CronJobListChannel struct {
	List  chan *batch2.CronJobList
	Error chan error
}

CronJobListChannel is a list and error channels to Cron Jobs.

func GetCronJobListChannel added in v1.8.0

func GetCronJobListChannel(client client.Interface, nsQuery *NamespaceQuery, numReads int) CronJobListChannel

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

type DaemonSetListChannel

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

DaemonSetListChannel is a list and error channels to Nodes.

func GetDaemonSetListChannel

func GetDaemonSetListChannel(client client.Interface, 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 *apps.DeploymentList
	Error chan error
}

DeploymentListChannel is a list and error channels to Deployments.

func GetDeploymentListChannel

func GetDeploymentListChannel(client client.Interface,
	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 EndpointListChannel added in v1.7.0

type EndpointListChannel struct {
	List  chan *v1.EndpointsList
	Error chan error
}

EndpointListChannel is a list and error channels to Endpoints.

func GetEndpointListChannel added in v1.7.0

func GetEndpointListChannel(client client.Interface, nsQuery *NamespaceQuery, numReads int) EndpointListChannel

func GetEndpointListChannelWithOptions added in v1.7.0

func GetEndpointListChannelWithOptions(client client.Interface,
	nsQuery *NamespaceQuery, opt metaV1.ListOptions, numReads int) EndpointListChannel

GetEndpointListChannelWithOptions is GetEndpointListChannel plus list options.

type Event

type Event struct {
	ObjectMeta api.ObjectMeta `json:"objectMeta"`
	TypeMeta   api.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 v1.Time `json:"firstSeen"`

	// The time at which the most recent occurrence of this event was recorded.
	LastSeen v1.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 api.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 *v1.EventList
	Error chan error
}

EventListChannel is a list and error channels to Nodes.

func GetEventListChannel

func GetEventListChannel(client client.Interface,
	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.Interface,
	nsQuery *NamespaceQuery, options metaV1.ListOptions, numReads int) EventListChannel

GetEventListChannelWithOptions is GetEventListChannel plus list options.

type HorizontalPodAutoscalerListChannel added in v1.5.0

type HorizontalPodAutoscalerListChannel struct {
	List  chan *autoscaling.HorizontalPodAutoscalerList
	Error chan error
}

HorizontalPodAutoscalerListChannel is a list and error channels.

func GetHorizontalPodAutoscalerListChannel added in v1.5.0

func GetHorizontalPodAutoscalerListChannel(client client.Interface, nsQuery *NamespaceQuery,
	numReads int) HorizontalPodAutoscalerListChannel

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

type IngressListChannel added in v1.4.0

type IngressListChannel struct {
	List  chan *extensions.IngressList
	Error chan error
}

IngressListChannel is a list and error channels to Ingresss.

func GetIngressListChannel added in v1.4.0

func GetIngressListChannel(client client.Interface, nsQuery *NamespaceQuery,
	numReads int) IngressListChannel

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

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.Interface,
	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 LimitRangeListChannel added in v1.4.1

type LimitRangeListChannel struct {
	List  chan *v1.LimitRangeList
	Error chan error
}

LimitRangeListChannel is a list and error channels to LimitRanges.

func GetLimitRangeListChannel added in v1.4.1

func GetLimitRangeListChannel(client client.Interface, nsQuery *NamespaceQuery,
	numReads int) LimitRangeListChannel

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

type NamespaceListChannel added in v1.4.0

type NamespaceListChannel struct {
	List  chan *v1.NamespaceList
	Error chan error
}

NamespaceListChannel is a list and error channels to Namespaces.

func GetNamespaceListChannel added in v1.4.0

func GetNamespaceListChannel(client client.Interface, numReads int) NamespaceListChannel

GetNamespaceListChannel returns a pair of channels to a Namespace 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 *v1.NodeList
	Error chan error
}

NodeListChannel is a list and error channels to Nodes.

func GetNodeListChannel

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

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

type PersistentVolumeClaimListChannel added in v1.4.0

type PersistentVolumeClaimListChannel struct {
	List  chan *v1.PersistentVolumeClaimList
	Error chan error
}

PersistentVolumeClaimListChannel is a list and error channels to PersistentVolumeClaims.

func GetPersistentVolumeClaimListChannel added in v1.4.0

func GetPersistentVolumeClaimListChannel(client client.Interface, nsQuery *NamespaceQuery,
	numReads int) PersistentVolumeClaimListChannel

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

type PersistentVolumeListChannel added in v1.1.1

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

PersistentVolumeListChannel is a list and error channels to PersistentVolumes.

func GetPersistentVolumeListChannel added in v1.1.1

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

GetPersistentVolumeListChannel returns a pair of channels to a PersistentVolume 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,omitempty"`

	// 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 *v1.PodList
	Error chan error
}

PodListChannel is a list and error channels to Nodes.

func GetPodListChannel

func GetPodListChannel(client client.Interface,
	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.Interface, nsQuery *NamespaceQuery,
	options metaV1.ListOptions, numReads int) PodListChannel

GetPodListChannelWithOptions is GetPodListChannel plus listing options.

type ReplicaSetListChannel

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

ReplicaSetListChannel is a list and error channels to Replica Sets.

func GetReplicaSetListChannel

func GetReplicaSetListChannel(client client.Interface,
	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.Interface, nsQuery *NamespaceQuery,
	options metaV1.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 *v1.ReplicationControllerList
	Error chan error
}

ReplicationControllerListChannel is a list and error channels to Nodes.

func GetReplicationControllerListChannel

func GetReplicationControllerListChannel(client client.Interface,
	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 Cron Jobs.
	CronJobList CronJobListChannel

	// List and error channels to Services.
	ServiceList ServiceListChannel

	// List and error channels to Endpoints.
	EndpointList EndpointListChannel

	// List and error channels to Ingresses.
	IngressList IngressListChannel

	// List and error channels to Pods.
	PodList PodListChannel

	// List and error channels to Events.
	EventList EventListChannel

	// List and error channels to LimitRanges.
	LimitRangeList LimitRangeListChannel

	// List and error channels to Nodes.
	NodeList NodeListChannel

	// List and error channels to Namespaces.
	NamespaceList NamespaceListChannel

	// List and error channels to StatefulSets.
	StatefulSetList StatefulSetListChannel

	// List and error channels to ConfigMaps.
	ConfigMapList ConfigMapListChannel

	// List and error channels to Secrets.
	SecretList SecretListChannel

	// List and error channels to PersistentVolumes
	PersistentVolumeList PersistentVolumeListChannel

	// List and error channels to PersistentVolumeClaims
	PersistentVolumeClaimList PersistentVolumeClaimListChannel

	// List and error channels to ResourceQuotas
	ResourceQuotaList ResourceQuotaListChannel

	// List and error channels to HorizontalPodAutoscalers
	HorizontalPodAutoscalerList HorizontalPodAutoscalerListChannel

	// List and error channels to StorageClasses
	StorageClassList StorageClassListChannel

	// List and error channels to Roles
	RoleList RoleListChannel

	// List and error channels to ClusterRoles
	ClusterRoleList ClusterRoleListChannel

	// List and error channels to RoleBindings
	RoleBindingList RoleBindingListChannel

	// List and error channels to ClusterRoleBindings
	ClusterRoleBindingList ClusterRoleBindingListChannel
}

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 ResourceQuotaListChannel added in v1.4.0

type ResourceQuotaListChannel struct {
	List  chan *v1.ResourceQuotaList
	Error chan error
}

ResourceQuotaListChannel is a list and error channels to ResourceQuotas.

func GetResourceQuotaListChannel added in v1.4.0

func GetResourceQuotaListChannel(client client.Interface, nsQuery *NamespaceQuery,
	numReads int) ResourceQuotaListChannel

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

type ResourceStatus added in v1.8.0

type ResourceStatus struct {
	// Number of resources that are currently in running state.
	Running int `json:"running"`

	// Number of resources that are currently in pending state.
	Pending int `json:"pending"`

	// Number of resources that are in failed state.
	Failed int `json:"failed"`

	// Number of resources that are in succeeded state.
	Succeeded int `json:"succeeded"`
}

ResourceStatus provides basic information about resources status on the list.

type RoleBindingListChannel added in v1.6.1

type RoleBindingListChannel struct {
	List  chan *rbac.RoleBindingList
	Error chan error
}

RoleBindingListChannel is a list and error channels to RoleBindings.

func GetRoleBindingListChannel added in v1.6.1

func GetRoleBindingListChannel(client client.Interface, numReads int) RoleBindingListChannel

GetRoleBindingListChannel returns a pair of channels to a RoleBinding list for a namespace and errors that both must be read numReads times.

type RoleListChannel added in v1.6.1

type RoleListChannel struct {
	List  chan *rbac.RoleList
	Error chan error
}

RoleListChannel is a list and error channels to Roles.

func GetRoleListChannel added in v1.6.1

func GetRoleListChannel(client client.Interface, numReads int) RoleListChannel

GetRoleListChannel returns a pair of channels to a Role list for a namespace and errors that both must be read numReads times.

type SecretListChannel added in v1.4.0

type SecretListChannel struct {
	List  chan *v1.SecretList
	Error chan error
}

SecretListChannel is a list and error channels to Secrets.

func GetSecretListChannel added in v1.4.0

func GetSecretListChannel(client client.Interface, nsQuery *NamespaceQuery,
	numReads int) SecretListChannel

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

type ServiceListChannel

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

ServiceListChannel is a list and error channels to Services.

func GetServiceListChannel

func GetServiceListChannel(client client.Interface, 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 StatefulSetListChannel added in v1.5.0

type StatefulSetListChannel struct {
	List  chan *apps.StatefulSetList
	Error chan error
}

StatefulSetListChannel is a list and error channels to Nodes.

func GetStatefulSetListChannel added in v1.5.0

func GetStatefulSetListChannel(client client.Interface,
	nsQuery *NamespaceQuery, numReads int) StatefulSetListChannel

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

type StorageClassListChannel added in v1.6.0

type StorageClassListChannel struct {
	List  chan *storage.StorageClassList
	Error chan error
}

StorageClassListChannel is a list and error channels to storage classes.

func GetStorageClassListChannel added in v1.6.0

func GetStorageClassListChannel(client client.Interface, numReads int) StorageClassListChannel

GetStorageClassListChannel returns a pair of channels to a storage class list and errors that both must be read numReads times.

Jump to

Keyboard shortcuts

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