controllerfinder

package
v1.4.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ControllerKindRS       = apps.SchemeGroupVersion.WithKind("ReplicaSet")
	ControllerKindSS       = apps.SchemeGroupVersion.WithKind("StatefulSet")
	ControllerKindRC       = corev1.SchemeGroupVersion.WithKind("ReplicationController")
	ControllerKindDep      = apps.SchemeGroupVersion.WithKind("Deployment")
	ControllerKruiseKindCS = appsv1alpha1.SchemeGroupVersion.WithKind("CloneSet")
	ControllerKruiseKindSS = appsv1beta1.SchemeGroupVersion.WithKind("StatefulSet")
)
View Source
var New = func(manager manager.Manager) (Interface, error) {
	finder := &ControllerFinder{
		Client: manager.GetClient(),
		mapper: manager.GetRESTMapper(),
	}
	cfg := manager.GetConfig()
	if cfg.GroupVersion == nil {
		cfg.GroupVersion = &schema.GroupVersion{}
	}
	codecs := serializer.NewCodecFactory(manager.GetScheme())
	cfg.NegotiatedSerializer = codecs.WithoutConversion()
	restClient, err := rest.RESTClientFor(cfg)
	if err != nil {
		return nil, err
	}
	k8sClient, err := clientset.NewForConfig(manager.GetConfig())
	if err != nil {
		return nil, err
	}
	finder.discoveryClient = k8sClient.Discovery()
	scaleKindResolver := scaleclient.NewDiscoveryScaleKindResolver(finder.discoveryClient)
	finder.scaleNamespacer = scaleclient.New(restClient, finder.mapper, dynamic.LegacyAPIPathResolverFunc, scaleKindResolver)
	return finder, nil
}

Functions

This section is empty.

Types

type ControllerFinder

type ControllerFinder struct {
	client.Client
	// contains filtered or unexported fields
}

func (*ControllerFinder) Finders

func (r *ControllerFinder) Finders() []PodControllerFinder

func (*ControllerFinder) GetExpectedScaleForPod added in v1.2.0

func (r *ControllerFinder) GetExpectedScaleForPod(pod *corev1.Pod) (int32, error)

func (*ControllerFinder) GetPodsForRef

func (r *ControllerFinder) GetPodsForRef(ownerReference *metav1.OwnerReference, ns string, labelSelector *metav1.LabelSelector, active bool) ([]*corev1.Pod, int32, error)

GetPodsForRef return target workload's podList and spec.replicas.

func (*ControllerFinder) GetScaleAndSelectorForRef

func (r *ControllerFinder) GetScaleAndSelectorForRef(apiVersion, kind, ns, name string, uid types.UID) (*ScaleAndSelector, error)

func (*ControllerFinder) ListPodsByWorkloads added in v1.2.0

func (r *ControllerFinder) ListPodsByWorkloads(workloadUIDs []types.UID, ns string, labelSelector *metav1.LabelSelector, active bool) ([]*corev1.Pod, error)

type ControllerReference

type ControllerReference struct {
	// API version of the referent.
	APIVersion string `json:"apiVersion" protobuf:"bytes,5,opt,name=apiVersion"`
	// Kind of the referent.
	Kind string `json:"kind" protobuf:"bytes,1,opt,name=kind"`
	// Name of the referent.
	Name string `json:"name" protobuf:"bytes,3,opt,name=name"`
	// UID of the referent.
	UID types.UID `json:"uid" protobuf:"bytes,4,opt,name=uid,casttype=k8s.io/apimachinery/pkg/types.UID"`
}

type Interface added in v1.1.1

type Interface interface {
	GetPodsForRef(ownerReference *metav1.OwnerReference, ns string, labelSelector *metav1.LabelSelector, active bool) ([]*corev1.Pod, int32, error)
	GetExpectedScaleForPod(pods *corev1.Pod) (int32, error)
	ListPodsByWorkloads(workloadUIDs []types.UID, ns string, labelSelector *metav1.LabelSelector, active bool) ([]*corev1.Pod, error)
}

type PodControllerFinder

type PodControllerFinder func(ref ControllerReference, namespace string) (*ScaleAndSelector, error)

PodControllerFinder is a function type that maps a pod to a list of controllers and their scale.

type ScaleAndSelector

type ScaleAndSelector struct {
	ControllerReference
	// controller.spec.Replicas
	Scale int32
	// kruise statefulSet.spec.ReserveOrdinals
	ReserveOrdinals []int
	// controller.spec.Selector
	Selector *metav1.LabelSelector
	// metadata
	Metadata metav1.ObjectMeta
}

ScaleAndSelector is used to return (controller, scale, selector) fields from the controller finder functions.

Jump to

Keyboard shortcuts

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