common

package
v0.0.0-...-062da64 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualIgnoreHash

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

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

FilterDeploymentPodsByOwnerReference returns a subset of pods controlled by given deployment.

func FilterPodsByControllerRef

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

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

FilterPodsForJob returns a list of pods that matches to a job controller's selector

func GetContainerImages

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

GetContainerImages returns container image strings from the given pod spec.

func GetContainerNames

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

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

func GetInitContainerImages

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

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

func GetInitContainerNames

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

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

func GetNonduplicateContainerImages

func GetNonduplicateContainerImages(podList []v1.Pod) []string

GetNonduplicateContainerImages returns list of container image strings without duplicates

func GetNonduplicateContainerNames

func GetNonduplicateContainerNames(podList []v1.Pod) []string

GetNonduplicateContainerNames returns list of container names strings without duplicates

func GetNonduplicateInitContainerImages

func GetNonduplicateInitContainerImages(podList []v1.Pod) []string

GetNonduplicateInitContainerImages returns list of init container image strings without duplicates

func GetNonduplicateInitContainerNames

func GetNonduplicateInitContainerNames(podList []v1.Pod) []string

GetNonduplicateInitContainerNames returns list of init container names strings without duplicates

Types

type ClusterRoleBindingListChannel

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

ClusterRoleBindingListChannel is a list and error channels to ClusterRoleBindings.

type ClusterRoleListChannel

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

ClusterRoleListChannel is a list and error channels to ClusterRoles.

type Condition

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

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

ConfigMapListChannel is a list and error channels to ConfigMaps.

func GetConfigMapListChannel

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

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

CronJobListChannel is a list and error channels to Cron Jobs.

func GetCronJobListChannel

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 Daemon Sets.

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

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

EndpointListChannel is a list and error channels to Endpoints.

func GetEndpointListChannelWithOptions

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 types.ObjectMeta `json:"objectMeta"`
	TypeMeta   types.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"`

	// Kind of the referent.
	// +optional
	SubObjectKind string `json:"objectKind,omitempty"`

	// Name of the referent.
	// +optional
	SubObjectName string `json:"objectName,omitempty"`

	// Namespace of the referent.
	// +optional
	SubObjectNamespace string `json:"objectNamespace,omitempty"`

	// 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 types.ListMeta `json:"listMeta"`

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

	// List of non-critical errors, that occurred during resource retrieval.
	Errors []error `json:"errors"`
}

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

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

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

HorizontalPodAutoscalerListChannel is a list and error channels.

type IngressClassListChannel

type IngressClassListChannel struct {
	List  chan *networkingv1.IngressClassList
	Error chan error
}

IngressClassListChannel is a list and error channels to ingress classes.

type IngressListChannel

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

IngressListChannel is a list and error channels to Ingresss.

type JobListChannel

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

JobListChannel is a list and error channels to Jobs.

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

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

LimitRangeListChannel is a list and error channels to LimitRanges.

type NamespaceListChannel

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

NamespaceListChannel is a list and error channels to Namespaces.

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

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

PersistentVolumeClaimListChannel is a list and error channels to PersistentVolumeClaims.

type PersistentVolumeListChannel

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

PersistentVolumeListChannel is a list and error channels to PersistentVolumes.

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

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 Replication Controllers.

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 IngressClasses
	IngressClassList IngressClassListChannel

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

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

ResourceQuotaListChannel is a list and error channels to ResourceQuotas.

type ResourceStatus

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

	// Number of resources that are in terminating state.
	Terminating int `json:"terminating"`
}

ResourceStatus provides basic information about resources status on the list.

type RoleBindingListChannel

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

RoleBindingListChannel is a list and error channels to RoleBindings.

type RoleListChannel

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

RoleListChannel is a list and error channels to Roles.

type SecretListChannel

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

SecretListChannel is a list and error channels to Secrets.

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

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

StatefulSetListChannel is a list and error channels to StatefulSets.

func GetStatefulSetListChannel

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

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

StorageClassListChannel is a list and error channels to storage classes.

Jump to

Keyboard shortcuts

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