k8sutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const RecommendedConfigPathEnvVar = "KUBECONFIG"

RecommendedConfigPathEnvVar is a environment variable for path configuration

Variables

This section is empty.

Functions

func CascadeDeleteOptions

func CascadeDeleteOptions(gracePeriodSeconds int64) *metav1.DeleteOptions

TODO(jlewi): CascadeDeletOptions are part of garbage collection policy. CascadeDeleteOptions deletes the workload after the grace period Do we want to use this? See https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/

func FilterActivePods

func FilterActivePods(pods []*v1.Pod) []*v1.Pod

FilterActivePods returns pods that have not terminated.

func FilterPodCount

func FilterPodCount(pods []*v1.Pod, phase v1.PodPhase) int32

filterPodCount returns pods based on their phase.

func FilterStalePodsByReplicaType added in v0.4.3

func FilterStalePodsByReplicaType(pods []*v1.Pod, generation int64, excludes ...string) (total int, result map[string][]*v1.Pod)

func GetClusterConfig

func GetClusterConfig() (*rest.Config, error)

GetClusterConfig obtain the config from the Kube configuration used by kubeconfig, or from k8s cluster.

func GetNumReplicasForLatestGeneration added in v0.4.3

func GetNumReplicasForLatestGeneration(pods []*v1.Pod, generation int64) int32

func GetReplicaType

func GetReplicaType(pod *v1.Pod) (rtype string, ok bool)

func GetTotalAvtiveReplicas

func GetTotalAvtiveReplicas(replicas map[apiv1.ReplicaType]*apiv1.ReplicaStatus) int32

func GetTotalExcludedReplicas added in v0.4.3

func GetTotalExcludedReplicas(replicas map[apiv1.ReplicaType]*apiv1.ReplicaSpec, excludes ...apiv1.ReplicaType) int32

func GetTotalFailedReplicas

func GetTotalFailedReplicas(replicas map[apiv1.ReplicaType]*apiv1.ReplicaStatus) int32

func GetTotalReplicas

func GetTotalReplicas(replicas map[apiv1.ReplicaType]*apiv1.ReplicaSpec) int32

func HasFinalizer added in v0.4.3

func HasFinalizer(finalizers []string, target string) bool

func IsKubernetesResourceAlreadyExistError

func IsKubernetesResourceAlreadyExistError(err error) bool

IsKubernetesResourceAlreadyExistError throws error when kubernetes resources already exist.

func IsKubernetesResourceNotFoundError

func IsKubernetesResourceNotFoundError(err error) bool

IsKubernetesResourceNotFoundError throws error when there is no kubernetes resource found.

func IsPodActive

func IsPodActive(p *v1.Pod) bool

func IsPodStartedBefore added in v0.4.3

func IsPodStartedBefore(p *v1.Pod, ts *metav1.Time) bool

func IsStalePod added in v0.4.3

func IsStalePod(pod *v1.Pod, generation int64) bool

func IsVictimCandidatePod added in v0.4.3

func IsVictimCandidatePod(p *v1.Pod) bool

func MustNewKubeClient

func MustNewKubeClient() kubernetes.Interface

MustNewKubeClient returns new kubernetes client for cluster configuration

func ResolveDependentOwner

func ResolveDependentOwner(metaObj metav1.Object) (id, name string)

Types

type CRDClient

type CRDClient interface {
	// Update a Job.
	Update(obj *metav1unstructured.Unstructured) error
}

CRDRestClient defines an interface for working with CRDs using the REST client. In most cases we want to use the auto-generated clientset for specific CRDs. The only exception is when the CRD spec is invalid and we can't parse the type into the corresponding go struct.

type CRDRestClient

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

CRDRestClient uses the Kubernetes rest interface to talk to the CRD.

func NewCRDRestClient

func NewCRDRestClient(version *schema.GroupVersion) (*CRDRestClient, error)

func (*CRDRestClient) Client

func (c *CRDRestClient) Client() *http.Client

HttpClient returns the http client used.

func (*CRDRestClient) Update

func (c *CRDRestClient) Update(obj *metav1unstructured.Unstructured, plural string) error

func (*CRDRestClient) UpdateStatus

func (c *CRDRestClient) UpdateStatus(obj *metav1unstructured.Unstructured, plural string) error

Jump to

Keyboard shortcuts

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