pod

package
v0.0.0-...-e93c85d Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeletePod

func DeletePod(podName, podNamespace, kubeconfigPath string, opts *metav1.DeleteOptions) error

DeletePod deletes Pod. It accepts Pod name, namespace and delete options.

func DeletePodWithCheck

func DeletePodWithCheck(podName, podNamespace, kubeconfigPath string, opts *metav1.DeleteOptions) error

DeletePodWithCheck delets Pod and starts a goroutine in background to check the delete operation.

func GetLog

func GetLog(podName, podNamespace, kubeconfigPath string) (string, error)

GetLog returns Pod's log in string. This method is the wrapper of kube client creation and GetLogString.

func GetPodCommands

func GetPodCommands(pod *corev1.Pod) []string

GetPodCommands returns all container commands for the given Pod in a string array.

func GetPodImages

func GetPodImages(pod *corev1.Pod) []string

GetPodImages returns all contariner images for the given Pod in a string array.

func GetPods

func GetPods(podNamespace, kubeconfigPath string, opts *metav1.ListOptions) (*corev1.PodList, error)

func IsCompleted

func IsCompleted(pod *corev1.Pod) bool

IsCompleted retruns true if for each contaniner of the pod, its State is Terminated and Reason is Completed. Although Pod is in Succeeded status, it sometimes doesn't mean all containers were run as expected. For example, container may be end by OOMKilled but its Status is Succeeded and the container's State is Terminated.

Types

type Client

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

Client helps talk to Kubernetes objects.

func New

func New(masterURL, kubeconfigPath string) (*Client, error)

New returns a pointer to Client object. If neither masterUrl or kubeconfigPath are passed in we fallback to inClusterConfig. If inClusterConfig fails, we fallback to the default config.

func (*Client) AddAnnotation

func (c *Client) AddAnnotation(pod *corev1.Pod, key, value string) (*corev1.Pod, error)

AddAnnotation adds a new key-value pair into Pod annotation field.

func (*Client) AddPodLabel

func (c *Client) AddPodLabel(pod *corev1.Pod, key string, value string) (*corev1.Pod, error)

AddPodLabel adds a label field into Pod. If the key already exists, it'll overwrite it.

func (*Client) DeletePod

func (c *Client) DeletePod(namespace, podName string, opts *metav1.DeleteOptions) error

DeletePod talks to Kubernetes to delete a Pod by given delete options.

func (*Client) DeletePodWithCheck

func (c *Client) DeletePodWithCheck(namespace, podName string, opts *metav1.DeleteOptions) error

DeletePodWithCheck deletes the Pod and will start a goroutine in background to confirm whether the Pod is successfully deleted.

func (*Client) GetEvents

func (c *Client) GetEvents(namespace, podName string, opts *metav1.ListOptions) (*corev1.EventList, error)

GetEvents returns a EventList object for the given Pod name and list options.

func (*Client) GetLogString

func (c *Client) GetLogString(namespace, podName string, opts *corev1.PodLogOptions) (string, error)

GetLogString returns the log of Pod in string.

func (*Client) GetPod

func (c *Client) GetPod(namespace, podName string, opts *metav1.GetOptions) (*corev1.Pod, error)

GetPod returns the Pod instance by namesapce, Pod name and get options.

func (*Client) GetPods

func (c *Client) GetPods(namespace string, opts *metav1.ListOptions) (*corev1.PodList, error)

GetPods returns a list of Pods by namespace and list options.

func (*Client) GetVersion

func (c *Client) GetVersion() schema.GroupVersion

GetVersion returns the version of the the current REST client

func (*Client) IsExist

func (c *Client) IsExist(namespace, podName string) (bool, error)

IsExist returns false if the Pod doesn't exist in the specific namespace.

func (*Client) UpdatePod

func (c *Client) UpdatePod(pod *corev1.Pod, namespace string) (*corev1.Pod, error)

UpdatePod accepts a context, pod and namespace. It returns a pointer to pod and error.

func (*Client) WaitForDeletion

func (c *Client) WaitForDeletion(namespace, podName string, period *int64) error

WaitForDeletion will wait for a period to check if Pod is deleted.

Jump to

Keyboard shortcuts

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