kubernetes

package
v0.0.0-...-e4898a9 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 26 Imported by: 149

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEventRecorder

func CreateEventRecorder(kubeClient clientset.Interface, recordDuplicatedEvents bool) kube_record.EventRecorder

CreateEventRecorder creates an event recorder to send custom events to Kubernetes to be recorded for targeted Kubernetes objects

func CreateKubeClient

func CreateKubeClient(opts config.KubeClientOptions) kube_client.Interface

CreateKubeClient creates kube client based on AutoscalingOptions.KubeClientOptions

func GetKubeConfig

func GetKubeConfig(opts config.KubeClientOptions) *rest.Config

GetKubeConfig returns the rest config from AutoscalingOptions.KubeClientOptions.

func GetReadinessState deprecated

func GetReadinessState(node *apiv1.Node) (isNodeReady bool, lastTransitionTime time.Time, err error)

GetReadinessState gets readiness state for the node

Deprecated: Use GetNodeReadiness instead.

func GetUnreadyNodeCopy

func GetUnreadyNodeCopy(node *apiv1.Node, reason NodeNotReadyReason) *apiv1.Node

GetUnreadyNodeCopy create a copy of the given node and override its NodeReady condition to False

func IsNodeReadyAndSchedulable

func IsNodeReadyAndSchedulable(node *apiv1.Node) bool

IsNodeReadyAndSchedulable returns true if the node is ready and schedulable.

func NewConfigMapListerForNamespace

func NewConfigMapListerForNamespace(kubeClient client.Interface, stopchannel <-chan struct{},
	namespace string) v1lister.ConfigMapLister

NewConfigMapListerForNamespace builds a configmap lister for the passed namespace (including all).

func NewTestConfigMapLister

func NewTestConfigMapLister(cms []*apiv1.ConfigMap) (v1lister.ConfigMapLister, error)

NewTestConfigMapLister returns a lister that returns provided ConfigMaps

func NewTestDaemonSetLister

func NewTestDaemonSetLister(dss []*appsv1.DaemonSet) (v1appslister.DaemonSetLister, error)

NewTestDaemonSetLister returns a lister that returns provided DaemonSets

func NewTestJobLister

func NewTestJobLister(jobs []*batchv1.Job) (v1batchlister.JobLister, error)

NewTestJobLister returns a lister that returns provided Jobs

func NewTestReplicaSetLister

func NewTestReplicaSetLister(rss []*appsv1.ReplicaSet) (v1appslister.ReplicaSetLister, error)

NewTestReplicaSetLister returns a lister that returns provided ReplicaSets

func NewTestReplicationControllerLister

func NewTestReplicationControllerLister(rcs []*apiv1.ReplicationController) (v1lister.ReplicationControllerLister, error)

NewTestReplicationControllerLister returns a lister that returns provided ReplicationControllers

func NewTestStatefulSetLister

func NewTestStatefulSetLister(sss []*appsv1.StatefulSet) (v1appslister.StatefulSetLister, error)

NewTestStatefulSetLister returns a lister that returns provided StatefulSets

func ScheduledPods

func ScheduledPods(allPods []*apiv1.Pod) []*apiv1.Pod

ScheduledPods is a helper method that returns all scheduled pods from given pod list.

func SchedulerUnprocessedPods

func SchedulerUnprocessedPods(allPods []*apiv1.Pod, bypassedSchedulers map[string]bool) []*apiv1.Pod

SchedulerUnprocessedPods is a helper method that returns all pods which are not yet processed by the specified bypassed schedulers

func UnschedulablePods

func UnschedulablePods(allPods []*apiv1.Pod) []*apiv1.Pod

UnschedulablePods is a helper method that returns all unschedulable pods from given pod list.

func WrapEventSinkWithLogging

func WrapEventSinkWithLogging(sink record.EventSink) record.EventSink

WrapEventSinkWithLogging adds logging each event via klog to an existing event sink.

Types

type AllPodLister

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

AllPodLister lists all pods.

func (*AllPodLister) List

func (lister *AllPodLister) List() ([]*apiv1.Pod, error)

List returns all scheduled pods.

type ListerRegistry

type ListerRegistry interface {
	AllNodeLister() NodeLister
	ReadyNodeLister() NodeLister
	AllPodLister() PodLister
	PodDisruptionBudgetLister() PodDisruptionBudgetLister
	DaemonSetLister() v1appslister.DaemonSetLister
	ReplicationControllerLister() v1lister.ReplicationControllerLister
	JobLister() v1batchlister.JobLister
	ReplicaSetLister() v1appslister.ReplicaSetLister
	StatefulSetLister() v1appslister.StatefulSetLister
}

ListerRegistry is a registry providing various listers to list pods or nodes matching conditions

func NewListerRegistry

func NewListerRegistry(allNode NodeLister, readyNode NodeLister, allPodLister PodLister, podDisruptionBudgetLister PodDisruptionBudgetLister,
	daemonSetLister v1appslister.DaemonSetLister, replicationControllerLister v1lister.ReplicationControllerLister,
	jobLister v1batchlister.JobLister, replicaSetLister v1appslister.ReplicaSetLister,
	statefulSetLister v1appslister.StatefulSetLister) ListerRegistry

NewListerRegistry returns a registry providing various listers to list pods or nodes matching conditions

func NewListerRegistryWithDefaultListers

func NewListerRegistryWithDefaultListers(informerFactory informers.SharedInformerFactory) ListerRegistry

NewListerRegistryWithDefaultListers returns a registry filled with listers of the default implementations

type NodeLister

type NodeLister interface {
	List() ([]*apiv1.Node, error)
	Get(name string) (*apiv1.Node, error)
}

NodeLister lists nodes.

func NewAllNodeLister

func NewAllNodeLister(nl v1lister.NodeLister) NodeLister

NewAllNodeLister builds a node lister that returns all nodes (ready and unready).

func NewNodeLister

func NewNodeLister(nl v1lister.NodeLister, filter func(*apiv1.Node) bool) NodeLister

NewNodeLister builds a node lister.

func NewReadyNodeLister

func NewReadyNodeLister(nl v1lister.NodeLister) NodeLister

NewReadyNodeLister builds a node lister that returns only ready nodes.

type NodeNotReadyReason

type NodeNotReadyReason string

NodeNotReadyReason reprents a reason for node to be unready. While it is simply a string on the node object, custom type ensures no one accidentally performs any string operation on variables of this type and allows them to be treated as enums.

const (
	// ResourceUnready is a fake identifier used internally by Cluster Autoscaler
	// to indicate nodes that appear Ready in the API, but are treated as
	// still upcoming due to a missing resource (e.g. GPU).
	ResourceUnready NodeNotReadyReason = "cluster-autoscaler.kubernetes.io/resource-not-ready"

	// StartupNodes is a fake identifier used internally by Cluster Autoscaler
	// to indicate nodes that appear Ready in the API, but are treated as
	// still upcoming due to applied startup taint.
	StartupNodes NodeNotReadyReason = "cluster-autoscaler.kubernetes.io/startup-taint"
)

type NodeReadiness

type NodeReadiness struct {
	// Is the node ready or not.
	Ready bool
	// Time of the last state transition related to readiness.
	LastTransitionTime time.Time
	// Reason for the node to be unready. Defined only when Ready is false.
	Reason NodeNotReadyReason
}

NodeReadiness represents the last known node readiness.

func GetNodeReadiness

func GetNodeReadiness(node *apiv1.Node) (NodeReadiness, error)

GetNodeReadiness gets readiness for the node

type PodDisruptionBudgetLister

type PodDisruptionBudgetLister interface {
	List() ([]*policyv1.PodDisruptionBudget, error)
}

PodDisruptionBudgetLister lists pod disruption budgets.

func NewPodDisruptionBudgetLister

func NewPodDisruptionBudgetLister(pdbLister v1policylister.PodDisruptionBudgetLister) PodDisruptionBudgetLister

NewPodDisruptionBudgetLister builds a pod disruption budget lister.

func NewTestPodDisruptionBudgetLister

func NewTestPodDisruptionBudgetLister(pdbs []*policyv1.PodDisruptionBudget) PodDisruptionBudgetLister

NewTestPodDisruptionBudgetLister returns a lister that returns provided pod disruption budgets

type PodDisruptionBudgetListerImpl

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

PodDisruptionBudgetListerImpl lists pod disruption budgets

func (*PodDisruptionBudgetListerImpl) List

List returns all pdbs

type PodLister

type PodLister interface {
	List() ([]*apiv1.Pod, error)
}

PodLister lists all pods. To filter out the scheduled or unschedulable pods the helper methods ScheduledPods and UnschedulablePods should be used.

func NewAllPodLister

func NewAllPodLister(pl v1lister.PodLister) PodLister

NewAllPodLister builds AllPodLister

func NewTestPodLister

func NewTestPodLister(pods []*apiv1.Pod) PodLister

NewTestPodLister returns a lister that returns provided pods

type TestNodeLister

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

TestNodeLister is used in tests involving listers

func NewTestNodeLister

func NewTestNodeLister(nodes []*apiv1.Node) *TestNodeLister

NewTestNodeLister returns a lister that returns provided nodes

func (*TestNodeLister) Get

func (l *TestNodeLister) Get(name string) (*apiv1.Node, error)

Get returns node from test lister.

func (*TestNodeLister) List

func (l *TestNodeLister) List() ([]*apiv1.Node, error)

List returns all nodes in test lister.

func (*TestNodeLister) SetNodes

func (l *TestNodeLister) SetNodes(nodes []*apiv1.Node)

SetNodes sets nodes in test lister.

type TestPodDisruptionBudgetLister

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

TestPodDisruptionBudgetLister is used in tests involving listers

func (TestPodDisruptionBudgetLister) List

List returns all pdbs in test lister.

type TestPodLister

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

TestPodLister is used in tests involving listers

func (TestPodLister) List

func (lister TestPodLister) List() ([]*apiv1.Pod, error)

List returns all pods in test lister.

Jump to

Keyboard shortcuts

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