kubeclient

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteConfigMap

func DeleteConfigMap(client client.Client, name, namespace string) (err error)

DeleteConfigMap deletes the configmap given its name and namespace if the configmap exists.

func DeletePersistentVolume

func DeletePersistentVolume(client client.Client, name string) (err error)

DeletePersistentVolume deletes volume

func DeletePersistentVolumeClaim

func DeletePersistentVolumeClaim(client client.Client, name, namespace string) (err error)

DeletePersistentVolumeClaim deletes volume claim

func EnsureNamespace

func EnsureNamespace(client client.Client, namespace string) (err error)

EnsureNamespace makes sure the namespace exist.

func ExecCommandInContainer

func ExecCommandInContainer(podName string, containerName string, namespace string, cmd []string) (stdout string, stderr string, err error)

A wrapper function of ExecCommandInContainerWithFullOutput

func ExecCommandInContainerWithFullOutput

func ExecCommandInContainerWithFullOutput(podName string, containerName string, namespace string, cmd []string) (stdout string, stderr string, err error)

ExecCommandInContainerWithFullOutput executes a command in the specified container and return stdout, stderr and error

func ExecCommandInPod

func ExecCommandInPod(podName string, namespace string, cmd []string) (stdout string, stderr string, err error)

ExecCommandInPod finds the first container in the given pod, executes command in that container, and return stdout, stderr and error.

func ExecShellInContainer

func ExecShellInContainer(podName string, containerName string, namespace string, cmd string) (stdout string, stderr string, err error)

ExecShellInContainer executes shell command or script in the specified container and return stdout, stderr and error

func ExecWithOptions

func ExecWithOptions(options ExecOptions) (string, string, error)

ExecWithOptions executes a command in the specified container, returning stdout, stderr and error. `options` allowed for additional parameters to be passed.

func GetConfigmapByName added in v0.5.0

func GetConfigmapByName(client client.Client, name, namespace string) (configmap *v1.ConfigMap, err error)

GetConfigmapByName gets configmap with given name and namespace of the configmap.

func GetNode

func GetNode(client client.Client, name string) (node *v1.Node, err error)

GetNode gets the latest node info

func GetPVCNamesFromPod added in v0.6.0

func GetPVCNamesFromPod(pod *v1.Pod) (pvcNames []string)

GetPVCNamesFromPod get names of pvc mounted by Pod

func GetPVCsFromPod added in v0.6.0

func GetPVCsFromPod(pod v1.Pod) (pvcs []v1.Volume)

GetPVCsFromPod get PersistVolumeClaims of pod

func GetPodByName

func GetPodByName(client client.Client, name, namespace string) (pod *v1.Pod, err error)

GetPodByName gets pod with given name and namespace of the pod.

func GetPvcMountNodes added in v0.5.0

func GetPvcMountNodes(e client.Client, pvcName, namespace string) (map[string]int64, error)

GetPvcMountNodes get nodes which have pods mounted the specific pvc for a given namespace it will only return a map of nodeName and amount of PvcMountPods on it if the Pvc mount Pod has completed, it will be ignored if fail to get pvc mount Nodes, treat every nodes as with no PVC mount Pods

func GetPvcMountPods

func GetPvcMountPods(e client.Client, pvcName, namespace string) ([]v1.Pod, error)

GetPvcMountPods get pods that mounted the specific pvc for a given namespace

func GetServiceByName added in v0.4.0

func GetServiceByName(client client.Client, name, namespace string) (service *corev1.Service, err error)

get service given name and namespace of the service.

func IsCompletePod

func IsCompletePod(pod *v1.Pod) bool

IsCompletePod determines if the pod is complete

func IsConfigMapExist

func IsConfigMapExist(client client.Client, name, namespace string) (found bool, err error)

IsConfigMapExist checks if the configMap exists given its name and namespace.

func IsDatasetPVC added in v0.6.0

func IsDatasetPVC(client client.Client, name string, namespace string) (find bool, err error)

IsDatasetPVC check whether the PVC is a dataset PVC

func IsFailedPod

func IsFailedPod(pod *v1.Pod) bool

IsFailedPod determines if the pod is failed

func IsPersistentVolumeClaimExist

func IsPersistentVolumeClaimExist(client client.Client, name, namespace string, annotations map[string]string) (found bool, err error)

IsPersistentVolumeClaimExist checks if the persistent volume claim exists given name, namespace and annotations of the PVC.

func IsPersistentVolumeExist

func IsPersistentVolumeExist(client client.Client, name string, annotations map[string]string) (found bool, err error)

IsPersistentVolumeExist checks if the persistent volume exists given name and annotations of the PV.

func IsReady

func IsReady(node v1.Node) (ready bool)

IsReady checks if the node is ready If the node is ready,it returns True.Otherwise,it returns False.

func IsSucceededPod added in v0.5.0

func IsSucceededPod(pod *v1.Pod) bool

IsSucceededPod determines if the pod is Succeeded

func RemoveProtectionFinalizer

func RemoveProtectionFinalizer(client client.Client, name, namespace string) (err error)

RemoveProtectionFinalizer remove finalizers of PersistentVolumeClaim if all owners that this PVC is mounted by are inactive (Succeed or Failed)

func ShouldDeleteDataset added in v0.5.0

func ShouldDeleteDataset(client client.Client, name, namespace string) (err error)

ShouldDeleteDataset return no err when no pod is using the volume If cannot get PVC, cannot get PvcMountPods, or running pod is using the volume, return corresponding error

func ShouldRemoveProtectionFinalizer

func ShouldRemoveProtectionFinalizer(client client.Client, name, namespace string) (should bool, err error)

ShouldRemoveProtectionFinalizer should remove pvc-protection finalizer when linked pods are inactive and timeout

Types

type ExecOptions

type ExecOptions struct {
	Command []string

	Namespace     string
	PodName       string
	ContainerName string

	Stdin         io.Reader
	CaptureStdout bool
	CaptureStderr bool
	// If false, whitespace in std{err,out} will be removed.
	PreserveWhitespace bool
}

ExecOptions passed to ExecWithOptions

Jump to

Keyboard shortcuts

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