pod

package
v0.0.0-...-96aca75 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeletePod

func DeletePod(ctx context.Context, podName, podNamespace, kubeconfigPath string, opts metav1.DeleteOptions) error

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

func DeletePodWithCheck

func DeletePodWithCheck(ctx context.Context, podName, podNamespace, kubeconfigPath string, opts metav1.DeleteOptions) error

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

func GetLog

func GetLog(ctx context.Context, 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 container images for the given Pod in a string array.

func IsCompleted

func IsCompleted(pod *corev1.Pod) bool

IsCompleted retruns true if for each container 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.

func ListPods

func ListPods(ctx context.Context, podNamespace, kubeconfigPath string, opts metav1.ListOptions) (*corev1.PodList, error)

ListPods list a list of Pods.

Types

type Client

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

Client helps talk to Kubernetes objects.

func New

func New(ctx context.Context, 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) CreatePod

func (c *Client) CreatePod(spec *corev1.Pod, namespace string, opts metav1.CreateOptions) (*corev1.Pod, error)

CreatePod creates a Pod.

func (*Client) CreatePodWithRetry

func (c *Client) CreatePodWithRetry(spec *corev1.Pod, namespace string, opts metav1.CreateOptions) (*corev1.Pod, error)

CreatePodWithRetry creates a Pod with retry.

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) GetContext

func (c *Client) GetContext() context.Context

GetContext returns the context of client.

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 namespace, Pod name and get 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) ListPods

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

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

func (*Client) UpdatePod

func (c *Client) UpdatePod(pod *corev1.Pod, namespace string, opts metav1.UpdateOptions) (*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