pod

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder is the builder object for Pod

func NewBuilder

func NewBuilder() *Builder

NewBuilder returns new instance of Builder

func (*Builder) Build

func (b *Builder) Build() (*corev1.Pod, error)

Build returns the Pod API instance

func (*Builder) WithContainer

func (b *Builder) WithContainer(container corev1.Container) *Builder

WithContainer sets the Containers field in Pod with provided arguments

func (*Builder) WithContainerBuilder

func (b *Builder) WithContainerBuilder(
	containerBuilder *container.Builder,
) *Builder

WithContainerBuilder adds a container to this pod object.

NOTE:

container details are present in the provided container

builder object

func (*Builder) WithContainers

func (b *Builder) WithContainers(containers []corev1.Container) *Builder

WithContainers sets the Containers field in Pod with provided arguments

func (*Builder) WithName

func (b *Builder) WithName(name string) *Builder

WithName sets the Name field of Pod with provided value.

func (*Builder) WithNamespace

func (b *Builder) WithNamespace(namespace string) *Builder

WithNamespace sets the Namespace field of Pod with provided value.

func (*Builder) WithNodeName

func (b *Builder) WithNodeName(nodeName string) *Builder

WithNodeName sets the NodeName field of Pod with provided value.

func (*Builder) WithNodeSelectorHostnameNew

func (b *Builder) WithNodeSelectorHostnameNew(hostname string) *Builder

WithNodeSelectorHostnameNew sets the Pod NodeSelector to the provided hostname value This function replaces (resets) the NodeSelector to use only hostname selector

func (*Builder) WithRestartPolicy

func (b *Builder) WithRestartPolicy(
	restartPolicy corev1.RestartPolicy,
) *Builder

WithRestartPolicy sets the RestartPolicy field in Pod with provided arguments

func (*Builder) WithVolume

func (b *Builder) WithVolume(volume corev1.Volume) *Builder

WithVolume sets the Volumes field in Pod with provided arguments

func (*Builder) WithVolumeBuilder

func (b *Builder) WithVolumeBuilder(volumeBuilder *volume.Builder) *Builder

WithVolumeBuilder sets Volumes field of deployment.

func (*Builder) WithVolumes

func (b *Builder) WithVolumes(volumes []corev1.Volume) *Builder

WithVolumes sets the Volumes field in Pod with provided arguments

type ExecOutput

type ExecOutput struct {
	Stdout string `json:"stdout"`
	Stderr string `json:"stderr"`
}

ExecOutput struct contains stdout and stderr

type KubeClient

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

KubeClient enables kubernetes API operations on pod instance

func NewKubeClient

func NewKubeClient(opts ...KubeClientBuildOption) *KubeClient

NewKubeClient returns a new instance of KubeClient meant for zfs volume replica operations

func (*KubeClient) Create

func (k *KubeClient) Create(pod *corev1.Pod) (*corev1.Pod, error)

Create creates a pod in specified namespace in kubernetes cluster

func (*KubeClient) Delete

func (k *KubeClient) Delete(name string, opts *metav1.DeleteOptions) error

Delete deletes a pod instance present in kubernetes cluster

func (*KubeClient) DeleteCollection

func (k *KubeClient) DeleteCollection(listOpts metav1.ListOptions, deleteOpts *metav1.DeleteOptions) error

DeleteCollection deletes a collection of pod objects.

func (*KubeClient) Exec

func (k *KubeClient) Exec(name string,
	opts *corev1.PodExecOptions) (*ExecOutput, error)

Exec runs a command remotely in a container of a pod

func (*KubeClient) ExecRaw

func (k *KubeClient) ExecRaw(name string,
	opts *corev1.PodExecOptions) ([]byte, error)

ExecRaw runs a command remotely in a container of a pod and returns raw output

func (*KubeClient) Get

func (k *KubeClient) Get(name string,
	opts metav1.GetOptions) (*corev1.Pod, error)

Get gets a pod object present in kubernetes cluster

func (*KubeClient) GetRaw

func (k *KubeClient) GetRaw(name string,
	opts metav1.GetOptions) ([]byte, error)

GetRaw gets pod object for a given name and namespace present in kubernetes cluster and returns result in raw byte.

func (*KubeClient) List

func (k *KubeClient) List(opts metav1.ListOptions) (*corev1.PodList, error)

List returns a list of pod instances present in kubernetes cluster

func (*KubeClient) WithKubeConfig

func (k *KubeClient) WithKubeConfig(config *rest.Config) *KubeClient

WithKubeConfig sets the kubernetes config against the KubeClient instance

func (*KubeClient) WithNamespace

func (k *KubeClient) WithNamespace(namespace string) *KubeClient

WithNamespace sets the kubernetes namespace against the provided namespace

type KubeClientBuildOption

type KubeClientBuildOption func(*KubeClient)

KubeClientBuildOption defines the abstraction to build a KubeClient instance

func WithClientSet

func WithClientSet(c *clientset.Clientset) KubeClientBuildOption

WithClientSet sets the kubernetes client against the KubeClient instance

func WithKubeConfigPath

func WithKubeConfigPath(path string) KubeClientBuildOption

WithKubeConfigPath sets the kubeConfig path against client instance

type List added in v0.9.0

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

List holds the list of API pod instances

func FromList

func FromList(pods *corev1.PodList) *List

FromList created a List with provided api List

func (*List) GetScheduledNodes added in v0.9.0

func (pl *List) GetScheduledNodes() map[string]int

GetScheduledNodes returns the nodes on which pods are scheduled

func (*List) IsMatchNodeAny added in v0.9.0

func (pl *List) IsMatchNodeAny(nodes map[string]int) bool

IsMatchNodeAny checks the List is running on the provided nodes

func (*List) Len added in v0.9.0

func (pl *List) Len() int

Len returns the number of items present in the List

func (*List) ToAPIList added in v0.9.0

func (pl *List) ToAPIList() *corev1.PodList

ToAPIList converts List to API List

type ListBuilder

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

ListBuilder enables building an instance of List

func ListBuilderForAPIList

func ListBuilderForAPIList(pods *corev1.PodList) *ListBuilder

ListBuilderForAPIList returns a instance of ListBuilder from API List

func ListBuilderForObjectList

func ListBuilderForObjectList(pods ...*Pod) *ListBuilder

ListBuilderForObjectList returns a instance of ListBuilder from API Pods

func NewListBuilder

func NewListBuilder() *ListBuilder

NewListBuilder returns a instance of ListBuilder

func (*ListBuilder) List

func (b *ListBuilder) List() *List

List returns the list of pod instances that was built by this builder

func (*ListBuilder) WithFilter

func (b *ListBuilder) WithFilter(pred ...Predicate) *ListBuilder

WithFilter add filters on which the pod has to be filtered

type Pod

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

Pod holds the api's pod objects

func NewForAPIObject

func NewForAPIObject(obj *corev1.Pod, opts ...podBuildOption) *Pod

NewForAPIObject returns a new instance of Pod

func (*Pod) GetAPIObject

func (p *Pod) GetAPIObject() *corev1.Pod

GetAPIObject returns a API's Pod

func (*Pod) HasLabel

func (p *Pod) HasLabel(key, value string) bool

HasLabel return true if provided lable key and value are present in the the provided List instance

func (*Pod) IsCompleted

func (p *Pod) IsCompleted() bool

IsCompleted returns true if the pod is in completed state

func (*Pod) IsNil

func (p *Pod) IsNil() bool

IsNil returns true if the pod instance is nil

func (*Pod) IsRunning

func (p *Pod) IsRunning() bool

IsRunning returns true if the pod is in running state

type Predicate

type Predicate func(*Pod) bool

Predicate defines an abstraction to determine conditional checks against the provided pod instance

func HasLabel

func HasLabel(key, value string) Predicate

HasLabel is predicate to filter out labeled pod instances

func HasLabels

func HasLabels(keyValuePair map[string]string) Predicate

HasLabels returns true if provided labels map[key]value are present in the provided List instance

func IsCompleted

func IsCompleted() Predicate

IsCompleted is a predicate to filter out pods which in completed state

func IsNil

func IsNil() Predicate

IsNil is predicate to filter out nil pod instances

func IsRunning

func IsRunning() Predicate

IsRunning is a predicate to filter out pods which in running state

Jump to

Keyboard shortcuts

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