common

package
v0.0.0-...-1dfee00 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Condition

type Condition struct {
	// Type of a condition.
	Type string `json:"type"`
	// Status of a condition.
	Status v1.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 *batch2.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 GetEndpointListChannel

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

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

func GetEventListChannel

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

GetEventListChannelWithOptions is GetEventListChannel plus list options.

type IngressListChannel

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

IngressListChannel is a list and error channels to Ingresss.

func GetIngressListChannel

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

type NamespaceQuery struct {
	Namespaces []string
}

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 PersistentVolumeClaimListChannel

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

PersistentVolumeClaimListChannel is a list and error channels to PersistentVolumeClaims.

func GetPersistentVolumeClaimListChannel

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

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

PersistentVolumeListChannel is a list and error channels to PersistentVolumes.

func GetPersistentVolumeListChannel

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

type ResourceChannels struct {

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

	// List and error channels to Deployments.
	DeploymentList DeploymentListChannel

	// List and error channels to Pods.
	PodList PodListChannel

	// List and error channels to Events.
	EventList EventListChannel

	// 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 StatefulSets.
	StatefulSetList StatefulSetListChannel

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

	// List and error channels to Services.
	ServiceList ServiceListChannel

	// List and error channels to Jobs.
	JobList JobListChannel

	// List and error channels to Cron Jobs.
	CronJobList CronJobListChannel

	// List and error channels to StorageClasses
	StorageClassList StorageClassListChannel

	// List and error channels to Endpoints.
	EndpointList EndpointListChannel
}

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 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 unknown state.
	Unknown int `json:"unknown"`

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

ResourceStatus provides basic information about resources status on the list.

type SecretListChannel

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

SecretListChannel is a list and error channels to Secrets.

func GetSecretListChannel

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

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.

func GetStorageClassListChannel

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