Documentation
¶
Index ¶
- func DeletePod(ctx context.Context, podName, podNamespace, kubeconfigPath string, ...) error
- func DeletePodWithCheck(ctx context.Context, podName, podNamespace, kubeconfigPath string, ...) error
- func GetLog(ctx context.Context, podName, podNamespace, kubeconfigPath string) (string, error)
- func GetPodCommands(pod *corev1.Pod) []string
- func GetPodImages(pod *corev1.Pod) []string
- func IsCompleted(pod *corev1.Pod) bool
- func ListPods(ctx context.Context, podNamespace, kubeconfigPath string, ...) (*corev1.PodList, error)
- type Client
- func (c *Client) AddAnnotation(pod *corev1.Pod, key, value string) (*corev1.Pod, error)
- func (c *Client) AddPodLabel(pod *corev1.Pod, key string, value string) (*corev1.Pod, error)
- func (c *Client) CreatePod(spec *corev1.Pod, namespace string, opts metav1.CreateOptions) (*corev1.Pod, error)
- func (c *Client) CreatePodWithRetry(spec *corev1.Pod, namespace string, opts metav1.CreateOptions) (*corev1.Pod, error)
- func (c *Client) DeletePod(namespace, podName string, opts metav1.DeleteOptions) error
- func (c *Client) DeletePodWithCheck(namespace, podName string, opts metav1.DeleteOptions) error
- func (c *Client) GetContext() context.Context
- func (c *Client) GetEvents(namespace, podName string, opts metav1.ListOptions) (*corev1.EventList, error)
- func (c *Client) GetLogString(namespace, podName string, opts *corev1.PodLogOptions) (string, error)
- func (c *Client) GetPod(namespace, podName string, opts metav1.GetOptions) (*corev1.Pod, error)
- func (c *Client) GetVersion() schema.GroupVersion
- func (c *Client) IsExist(namespace, podName string) (bool, error)
- func (c *Client) ListPods(namespace string, opts metav1.ListOptions) (*corev1.PodList, error)
- func (c *Client) UpdatePod(pod *corev1.Pod, namespace string, opts metav1.UpdateOptions) (*corev1.Pod, error)
- func (c *Client) WaitForDeletion(namespace, podName string, period *int64) error
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 ¶
GetLog returns Pod's log in string. This method is the wrapper of kube client creation and GetLogString.
func GetPodCommands ¶
GetPodCommands returns all container commands for the given Pod in a string array.
func GetPodImages ¶
GetPodImages returns all container images for the given Pod in a string array.
func IsCompleted ¶
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.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client helps talk to Kubernetes objects.
func New ¶
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 ¶
AddAnnotation adds a new key-value pair into Pod annotation field.
func (*Client) AddPodLabel ¶
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 ¶
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) GetVersion ¶
func (c *Client) GetVersion() schema.GroupVersion
GetVersion returns the version of the the current REST client