pod

package
v0.0.0-...-e224ba4 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 25 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AllowedSCList list of allowed SecurityCapabilities.
	AllowedSCList = []string{"NET_RAW", "NET_ADMIN", "SYS_ADMIN", "IPC_LOCK", "ALL"}
)

Functions

func GetGVR

GetGVR returns pod's GroupVersionResource which could be used for Clean function.

func StaticAnnotation

func StaticAnnotation(name string) *multus.NetworkSelectionElement

StaticAnnotation defines network annotation for pod object.

func StaticIPAnnotation

func StaticIPAnnotation(name string, ipAddr []string) []*multus.NetworkSelectionElement

StaticIPAnnotation defines static ip address network annotation for pod object.

func StaticIPAnnotationWithInterfaceAndNamespace

func StaticIPAnnotationWithInterfaceAndNamespace(
	name, namespace, intName string, ipAddr []string) []*multus.NetworkSelectionElement

StaticIPAnnotationWithInterfaceAndNamespace defines static ip address, interface name and namespace network annotation for pod object.

func StaticIPAnnotationWithInterfaceMacAndNamespace

func StaticIPAnnotationWithInterfaceMacAndNamespace(
	name, namespace, intName, macAddr string) []*multus.NetworkSelectionElement

StaticIPAnnotationWithInterfaceMacAndNamespace defines static ip address and namespace, interface name, mac address network annotation for pod object.

func StaticIPAnnotationWithMacAddress

func StaticIPAnnotationWithMacAddress(name string, ipAddr []string, macAddr string) []*multus.NetworkSelectionElement

StaticIPAnnotationWithMacAddress defines static ip address and static macaddress network annotation for pod object.

func StaticIPAnnotationWithMacAndNamespace

func StaticIPAnnotationWithMacAndNamespace(name, namespace, macAddr string) []*multus.NetworkSelectionElement

StaticIPAnnotationWithMacAndNamespace defines static ip address and namespace, mac address network annotation for pod object.

func StaticIPAnnotationWithNamespace

func StaticIPAnnotationWithNamespace(name, namespace string, ipAddr []string) []*multus.NetworkSelectionElement

StaticIPAnnotationWithNamespace defines static ip address and namespace network annotation for pod object.

func StaticIPBondAnnotationWithInterface

func StaticIPBondAnnotationWithInterface(
	bondNadName, bondIntName string, sriovNetworkNameList, ipAddrBond []string) []*multus.NetworkSelectionElement

StaticIPBondAnnotationWithInterface defines static name for bonded interfaces and name, interface and IP for the main bond int.

func StaticIPMultiNetDualStackAnnotation

func StaticIPMultiNetDualStackAnnotation(sriovNets, ipAddr []string) ([]*multus.NetworkSelectionElement, error)

StaticIPMultiNetDualStackAnnotation defines network annotation for multiple interfaces with dual stack addresses.

func WaitForAllPodsInNamespaceRunning

func WaitForAllPodsInNamespaceRunning(
	apiClient *clients.Settings,
	nsname string,
	timeout time.Duration,
	options ...v1.ListOptions) (bool, error)

WaitForAllPodsInNamespaceRunning wait until all pods in namespace that match options are in running state.

Types

type AdditionalOptions

type AdditionalOptions func(builder *Builder) (*Builder, error)

AdditionalOptions additional options for pod object.

type Builder

type Builder struct {
	// Pod definition, used to create the pod object.
	Definition *corev1.Pod
	// Created pod object.
	Object *corev1.Pod
	// contains filtered or unexported fields
}

Builder provides a struct for pod object from the cluster and a pod definition.

func List

func List(apiClient *clients.Settings, nsname string, options ...v1.ListOptions) ([]*Builder, error)

List returns pod inventory in the given namespace.

func ListByNamePattern

func ListByNamePattern(apiClient *clients.Settings, namePattern, nsname string) ([]*Builder, error)

ListByNamePattern returns pod inventory in the given namespace filtered by name pattern.

func ListInAllNamespaces

func ListInAllNamespaces(apiClient *clients.Settings, options ...v1.ListOptions) ([]*Builder, error)

ListInAllNamespaces returns a cluster-wide pod inventory.

func NewBuilder

func NewBuilder(apiClient *clients.Settings, name, nsname, image string) *Builder

NewBuilder creates a new instance of Builder.

func Pull

func Pull(apiClient *clients.Settings, name, nsname string) (*Builder, error)

Pull loads an existing pod into the Builder struct.

func (*Builder) Copy

func (builder *Builder) Copy(path, containerName string, tar bool) (bytes.Buffer, error)

Copy returns the contents of a file or path from a specified container into a buffer. Setting the tar option returns a tar archive of the specified path.

func (*Builder) Create

func (builder *Builder) Create() (*Builder, error)

Create makes a pod according to the pod definition and stores the created object in the pod builder.

func (*Builder) CreateAndWaitUntilRunning

func (builder *Builder) CreateAndWaitUntilRunning(timeout time.Duration) (*Builder, error)

CreateAndWaitUntilRunning creates the pod object and waits until the pod is running.

func (*Builder) DefineOnNode

func (builder *Builder) DefineOnNode(nodeName string) *Builder

DefineOnNode adds nodeName to the pod's definition.

func (*Builder) Delete

func (builder *Builder) Delete() (*Builder, error)

Delete removes the pod object and resets the builder object.

func (*Builder) DeleteAndWait

func (builder *Builder) DeleteAndWait(timeout time.Duration) (*Builder, error)

DeleteAndWait deletes the pod object and waits until the pod is deleted.

func (*Builder) ExecCommand

func (builder *Builder) ExecCommand(command []string, containerName ...string) (bytes.Buffer, error)

ExecCommand runs command in the pod and returns the buffer output.

func (*Builder) Exists

func (builder *Builder) Exists() bool

Exists checks whether the given pod exists.

func (*Builder) GetFullLog

func (builder *Builder) GetFullLog(containerName string) (string, error)

GetFullLog connects to a pod and fetches the full log since pod creation.

func (*Builder) GetLog

func (builder *Builder) GetLog(logStartTime time.Duration, containerName string) (string, error)

GetLog connects to a pod and fetches log.

func (*Builder) PullImage

func (builder *Builder) PullImage(timeout time.Duration, testCmd []string) error

PullImage pulls image for given pod's container and removes it.

func (*Builder) RedefineDefaultCMD

func (builder *Builder) RedefineDefaultCMD(command []string) *Builder

RedefineDefaultCMD redefines default command in pod's definition.

func (*Builder) RedefineDefaultContainer

func (builder *Builder) RedefineDefaultContainer(container corev1.Container) *Builder

RedefineDefaultContainer redefines default container with the new one.

func (*Builder) WaitUntilCondition

func (builder *Builder) WaitUntilCondition(condition corev1.PodConditionType, timeout time.Duration) error

WaitUntilCondition waits for the duration of the defined timeout or until the pod gets to a specific condition.

func (*Builder) WaitUntilDeleted

func (builder *Builder) WaitUntilDeleted(timeout time.Duration) error

WaitUntilDeleted waits for the duration of the defined timeout or until the pod is deleted.

func (*Builder) WaitUntilInStatus

func (builder *Builder) WaitUntilInStatus(status corev1.PodPhase, timeout time.Duration) error

WaitUntilInStatus waits for the duration of the defined timeout or until the pod gets to a specific status.

func (*Builder) WaitUntilReady

func (builder *Builder) WaitUntilReady(timeout time.Duration) error

WaitUntilReady waits for the duration of the defined timeout or until the pod reaches the Ready condition.

func (*Builder) WaitUntilRunning

func (builder *Builder) WaitUntilRunning(timeout time.Duration) error

WaitUntilRunning waits for the duration of the defined timeout or until the pod is running.

func (*Builder) WithAdditionalContainer

func (builder *Builder) WithAdditionalContainer(container *corev1.Container) *Builder

WithAdditionalContainer appends additional container to pod.

func (*Builder) WithAdditionalInitContainer

func (builder *Builder) WithAdditionalInitContainer(container *corev1.Container) *Builder

WithAdditionalInitContainer appends additional init container to pod.

func (*Builder) WithHostNetwork

func (builder *Builder) WithHostNetwork() *Builder

WithHostNetwork applies HostNetwork to pod's definition.

func (*Builder) WithHostPid

func (builder *Builder) WithHostPid(hostPid bool) *Builder

WithHostPid configures a pod's access to the host process ID namespace based on a boolean parameter.

func (*Builder) WithHugePages

func (builder *Builder) WithHugePages() *Builder

WithHugePages sets hugePages on all containers inside the pod.

func (*Builder) WithLabel

func (builder *Builder) WithLabel(labelKey, labelValue string) *Builder

WithLabel applies label to pod's definition.

func (*Builder) WithLabels

func (builder *Builder) WithLabels(labels map[string]string) *Builder

WithLabels applies a set of labels to a Pod's definition.

func (*Builder) WithLocalVolume

func (builder *Builder) WithLocalVolume(volumeName, mountPath string) *Builder

WithLocalVolume attaches given volume to all pod's containers.

func (*Builder) WithNodeSelector

func (builder *Builder) WithNodeSelector(nodeSelector map[string]string) *Builder

WithNodeSelector adds a nodeSelector configuration inside the pod.

func (*Builder) WithOptions

func (builder *Builder) WithOptions(options ...AdditionalOptions) *Builder

WithOptions creates pod with generic mutation options.

func (*Builder) WithPrivilegedFlag

func (builder *Builder) WithPrivilegedFlag() *Builder

WithPrivilegedFlag sets privileged flag on all containers.

func (*Builder) WithRestartPolicy

func (builder *Builder) WithRestartPolicy(restartPolicy corev1.RestartPolicy) *Builder

WithRestartPolicy applies restart policy to pod's definition.

func (*Builder) WithSecondaryNetwork

func (builder *Builder) WithSecondaryNetwork(network []*multus.NetworkSelectionElement) *Builder

WithSecondaryNetwork applies Multus secondary network on pod definition.

func (*Builder) WithSecurityContext

func (builder *Builder) WithSecurityContext(securityContext *corev1.PodSecurityContext) *Builder

WithSecurityContext sets SecurityContext on pod definition.

func (*Builder) WithToleration

func (builder *Builder) WithToleration(toleration corev1.Toleration) *Builder

WithToleration adds a toleration configuration inside the pod.

func (*Builder) WithTolerationToControlPlane

func (builder *Builder) WithTolerationToControlPlane() *Builder

WithTolerationToControlPlane sets toleration policy which allows pod to be running on control plane node.

func (*Builder) WithTolerationToMaster

func (builder *Builder) WithTolerationToMaster() *Builder

WithTolerationToMaster sets toleration policy which allows pod to be running on master node.

func (*Builder) WithVolume

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

WithVolume attaches given volume to a pod.

type ContainerBuilder

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

ContainerBuilder provides a struct for container's object definition.

func NewContainerBuilder

func NewContainerBuilder(name, image string, cmd []string) *ContainerBuilder

NewContainerBuilder creates a new instance of ContainerBuilder.

func (*ContainerBuilder) GetContainerCfg

func (builder *ContainerBuilder) GetContainerCfg() (*corev1.Container, error)

GetContainerCfg returns Container struct.

func (*ContainerBuilder) WithCustomResourcesLimits

func (builder *ContainerBuilder) WithCustomResourcesLimits(resourceList corev1.ResourceList) *ContainerBuilder

WithCustomResourcesLimits applies custom resource limit struct on container.

func (*ContainerBuilder) WithCustomResourcesRequests

func (builder *ContainerBuilder) WithCustomResourcesRequests(resourceList corev1.ResourceList) *ContainerBuilder

WithCustomResourcesRequests applies custom resource requests struct on container.

func (*ContainerBuilder) WithDropSecurityCapabilities

func (builder *ContainerBuilder) WithDropSecurityCapabilities(sCapabilities []string, redefine bool) *ContainerBuilder

WithDropSecurityCapabilities drops SecurityCapabilities from the container definition.

func (*ContainerBuilder) WithEnvVar

func (builder *ContainerBuilder) WithEnvVar(name, value string) *ContainerBuilder

WithEnvVar adds environment variables to container.

func (*ContainerBuilder) WithImagePullPolicy

func (builder *ContainerBuilder) WithImagePullPolicy(pullPolicy corev1.PullPolicy) *ContainerBuilder

WithImagePullPolicy applies specific image pull policy on container.

func (*ContainerBuilder) WithResourceLimit

func (builder *ContainerBuilder) WithResourceLimit(hugePages, memory string, cpu int64) *ContainerBuilder

WithResourceLimit applies resource limit on container.

func (*ContainerBuilder) WithResourceRequest

func (builder *ContainerBuilder) WithResourceRequest(hugePages, memory string, cpu int64) *ContainerBuilder

WithResourceRequest applies resource request on container.

func (*ContainerBuilder) WithSecurityCapabilities

func (builder *ContainerBuilder) WithSecurityCapabilities(sCapabilities []string, redefine bool) *ContainerBuilder

WithSecurityCapabilities applies SecurityCapabilities to the container definition.

func (*ContainerBuilder) WithSecurityContext

func (builder *ContainerBuilder) WithSecurityContext(securityContext *corev1.SecurityContext) *ContainerBuilder

WithSecurityContext applies security Context on container.

func (*ContainerBuilder) WithVolumeMount

func (builder *ContainerBuilder) WithVolumeMount(volMount corev1.VolumeMount) *ContainerBuilder

WithVolumeMount adds a pod volume mount inside the container.

Jump to

Keyboard shortcuts

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