Documentation ¶
Index ¶
- Variables
- func GetGVR() schema.GroupVersionResource
- func StaticAnnotation(name string) *multus.NetworkSelectionElement
- func StaticIPAnnotation(name string, ipAddr []string) []*multus.NetworkSelectionElement
- func StaticIPAnnotationWithInterfaceAndNamespace(name, namespace, intName string, ipAddr []string) []*multus.NetworkSelectionElement
- func StaticIPAnnotationWithInterfaceMacAndNamespace(name, namespace, intName, macAddr string) []*multus.NetworkSelectionElement
- func StaticIPAnnotationWithMacAddress(name string, ipAddr []string, macAddr string) []*multus.NetworkSelectionElement
- func StaticIPAnnotationWithMacAndNamespace(name, namespace, macAddr string) []*multus.NetworkSelectionElement
- func StaticIPAnnotationWithNamespace(name, namespace string, ipAddr []string) []*multus.NetworkSelectionElement
- func StaticIPBondAnnotationWithInterface(bondNadName, bondIntName string, sriovNetworkNameList, ipAddrBond []string) []*multus.NetworkSelectionElement
- func StaticIPMultiNetDualStackAnnotation(sriovNets, ipAddr []string) ([]*multus.NetworkSelectionElement, error)
- func WaitForAllPodsInNamespaceRunning(apiClient *clients.Settings, nsname string, timeout time.Duration, ...) (bool, error)
- func WaitForAllPodsInNamespacesHealthy(apiClient *clients.Settings, nsNames []string, timeout time.Duration, ...) error
- type AdditionalOptions
- type Builder
- func List(apiClient *clients.Settings, nsname string, options ...metav1.ListOptions) ([]*Builder, error)
- func ListByNamePattern(apiClient *clients.Settings, namePattern, nsname string) ([]*Builder, error)
- func ListInAllNamespaces(apiClient *clients.Settings, options ...metav1.ListOptions) ([]*Builder, error)
- func NewBuilder(apiClient *clients.Settings, name, nsname, image string) *Builder
- func Pull(apiClient *clients.Settings, name, nsname string) (*Builder, error)
- func (builder *Builder) Copy(path, containerName string, tar bool) (bytes.Buffer, error)
- func (builder *Builder) Create() (*Builder, error)
- func (builder *Builder) CreateAndWaitUntilRunning(timeout time.Duration) (*Builder, error)
- func (builder *Builder) DefineOnNode(nodeName string) *Builder
- func (builder *Builder) Delete() (*Builder, error)
- func (builder *Builder) DeleteAndWait(timeout time.Duration) (*Builder, error)
- func (builder *Builder) DeleteImmediate() (*Builder, error)
- func (builder *Builder) ExecCommand(command []string, containerName ...string) (bytes.Buffer, error)
- func (builder *Builder) Exists() bool
- func (builder *Builder) GetFullLog(containerName string) (string, error)
- func (builder *Builder) GetLog(logStartTime time.Duration, containerName string) (string, error)
- func (builder *Builder) PullImage(timeout time.Duration, testCmd []string) error
- func (builder *Builder) RedefineDefaultCMD(command []string) *Builder
- func (builder *Builder) RedefineDefaultContainer(container corev1.Container) *Builder
- func (builder *Builder) WaitUntilCondition(condition corev1.PodConditionType, timeout time.Duration) error
- func (builder *Builder) WaitUntilDeleted(timeout time.Duration) error
- func (builder *Builder) WaitUntilHealthy(timeout time.Duration, ...) error
- func (builder *Builder) WaitUntilInOneOfStatuses(statuses []corev1.PodPhase, timeout time.Duration) (*corev1.PodPhase, error)
- func (builder *Builder) WaitUntilInStatus(status corev1.PodPhase, timeout time.Duration) error
- func (builder *Builder) WaitUntilReady(timeout time.Duration) error
- func (builder *Builder) WaitUntilRunning(timeout time.Duration) error
- func (builder *Builder) WithAdditionalContainer(container *corev1.Container) *Builder
- func (builder *Builder) WithAdditionalInitContainer(container *corev1.Container) *Builder
- func (builder *Builder) WithHostNetwork() *Builder
- func (builder *Builder) WithHostPid(hostPid bool) *Builder
- func (builder *Builder) WithHugePages() *Builder
- func (builder *Builder) WithLabel(labelKey, labelValue string) *Builder
- func (builder *Builder) WithLabels(labels map[string]string) *Builder
- func (builder *Builder) WithLocalVolume(volumeName, mountPath string) *Builder
- func (builder *Builder) WithNodeSelector(nodeSelector map[string]string) *Builder
- func (builder *Builder) WithOptions(options ...AdditionalOptions) *Builder
- func (builder *Builder) WithPrivilegedFlag() *Builder
- func (builder *Builder) WithRestartPolicy(restartPolicy corev1.RestartPolicy) *Builder
- func (builder *Builder) WithSecondaryNetwork(network []*multus.NetworkSelectionElement) *Builder
- func (builder *Builder) WithSecurityContext(securityContext *corev1.PodSecurityContext) *Builder
- func (builder *Builder) WithTerminationGracePeriodSeconds(terminationGracePeriodSeconds int64) *Builder
- func (builder *Builder) WithToleration(toleration corev1.Toleration) *Builder
- func (builder *Builder) WithTolerationToControlPlane() *Builder
- func (builder *Builder) WithTolerationToMaster() *Builder
- func (builder *Builder) WithVolume(volume corev1.Volume) *Builder
- type ContainerBuilder
- func (builder *ContainerBuilder) GetContainerCfg() (*corev1.Container, error)
- func (builder *ContainerBuilder) WithCustomResourcesLimits(resourceList corev1.ResourceList) *ContainerBuilder
- func (builder *ContainerBuilder) WithCustomResourcesRequests(resourceList corev1.ResourceList) *ContainerBuilder
- func (builder *ContainerBuilder) WithDropSecurityCapabilities(sCapabilities []string, redefine bool) *ContainerBuilder
- func (builder *ContainerBuilder) WithEnvVar(name, value string) *ContainerBuilder
- func (builder *ContainerBuilder) WithImagePullPolicy(pullPolicy corev1.PullPolicy) *ContainerBuilder
- func (builder *ContainerBuilder) WithPorts(ports []corev1.ContainerPort) *ContainerBuilder
- func (builder *ContainerBuilder) WithReadinessProbe(readinessProbe *corev1.Probe) *ContainerBuilder
- func (builder *ContainerBuilder) WithResourceLimit(hugePages, memory string, cpu int64) *ContainerBuilder
- func (builder *ContainerBuilder) WithResourceRequest(hugePages, memory string, cpu int64) *ContainerBuilder
- func (builder *ContainerBuilder) WithSecurityCapabilities(sCapabilities []string, redefine bool) *ContainerBuilder
- func (builder *ContainerBuilder) WithSecurityContext(securityContext *corev1.SecurityContext) *ContainerBuilder
- func (builder *ContainerBuilder) WithStdin(enableStdin bool) *ContainerBuilder
- func (builder *ContainerBuilder) WithTTY(enableTTY bool) *ContainerBuilder
- func (builder *ContainerBuilder) WithVolumeMount(volMount corev1.VolumeMount) *ContainerBuilder
Constants ¶
This section is empty.
Variables ¶
var ( // AllowedSCList list of allowed SecurityCapabilities. AllowedSCList = []string{"NET_RAW", "NET_ADMIN", "SYS_ADMIN", "IPC_LOCK", "ALL", "SETFCAP", "CAP_NET_RAW", "CAP_NET_ADMIN"} )
Functions ¶
func GetGVR ¶
func GetGVR() schema.GroupVersionResource
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 ...metav1.ListOptions) (bool, error)
WaitForAllPodsInNamespaceRunning wait until all pods in namespace that match options are in running state.
func WaitForAllPodsInNamespacesHealthy ¶
func WaitForAllPodsInNamespacesHealthy( apiClient *clients.Settings, nsNames []string, timeout time.Duration, includeSucceeded bool, skipReadinessCheck bool, ignoreRestartPolicyNever bool, ignoreNamespaces []string, options ...metav1.ListOptions, ) error
WaitForAllPodsInNamespacesHealthy waits until: - all pods in a list of namespaces that match options are in healthy state. - a pod in a healthy state is in running phase and optionally in ready condition.
nsNames passes the list of namespaces to monitor. Monitors all namespaces when empty. timeout is the duration in seconds to wait for the pods to be healthy includeSucceeded when true, considers that pods in succeeded phase are healthy. skipReadiness when false, checks that the podCondition is ready. ignoreRestartPolicyNever when true, ignores failed pods with restart policy set to never. ignoreNamespaces is a list of namespaces to ignore. options reduces the list of namespace to only the ones matching options.
Types ¶
type AdditionalOptions ¶
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 ...metav1.ListOptions) ([]*Builder, error)
List returns pod inventory in the given namespace.
func ListByNamePattern ¶
ListByNamePattern returns pod inventory in the given namespace filtered by name pattern.
func ListInAllNamespaces ¶
func ListInAllNamespaces(apiClient *clients.Settings, options ...metav1.ListOptions) ([]*Builder, error)
ListInAllNamespaces returns a cluster-wide pod inventory.
func NewBuilder ¶
NewBuilder creates a new instance of Builder.
func (*Builder) Copy ¶
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 ¶
Create makes a pod according to the pod definition and stores the created object in the pod builder.
func (*Builder) CreateAndWaitUntilRunning ¶
CreateAndWaitUntilRunning creates the pod object and waits until the pod is running.
func (*Builder) DefineOnNode ¶
DefineOnNode adds nodeName to the pod's definition.
func (*Builder) DeleteAndWait ¶
DeleteAndWait deletes the pod object and waits until the pod is deleted.
func (*Builder) DeleteImmediate ¶
DeleteImmediate removes the pod immediately and resets the builder object.
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) GetFullLog ¶
GetFullLog connects to a pod and fetches the full log since pod creation.
func (*Builder) RedefineDefaultCMD ¶
RedefineDefaultCMD redefines default command in pod's definition.
func (*Builder) RedefineDefaultContainer ¶
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 ¶
WaitUntilDeleted waits for the duration of the defined timeout or until the pod is deleted.
func (*Builder) WaitUntilHealthy ¶
func (builder *Builder) WaitUntilHealthy(timeout time.Duration, includeSucceeded, skipReadinessCheck, ignoreRestartPolicyNever bool) error
WaitUntilHealthy waits for the duration of the defined timeout or until the pod is healthy. A healthy pod is in running phase and optionally in ready condition.
timeout is the duration to wait for the pod to be healthy includeSucceeded when true, implies that pod in succeeded phase is running. skipReadinessCheck when false, checks that the podCondition is ready. ignoreRestartPolicyNever when true, Ignores failed pods with restart policy set to never.
func (*Builder) WaitUntilInOneOfStatuses ¶
func (builder *Builder) WaitUntilInOneOfStatuses(statuses []corev1.PodPhase, timeout time.Duration) (*corev1.PodPhase, error)
WaitUntilInOneOfStatuses waits for the duration of the defined timeout or until the pod gets to any specific status in a list of statues.
func (*Builder) WaitUntilInStatus ¶
WaitUntilInStatus waits for the duration of the defined timeout or until the pod gets to a specific status.
func (*Builder) WaitUntilReady ¶
WaitUntilReady waits for the duration of the defined timeout or until the pod reaches the Ready condition.
func (*Builder) WaitUntilRunning ¶
WaitUntilRunning waits for the duration of the defined timeout or until the pod is running.
func (*Builder) WithAdditionalContainer ¶
WithAdditionalContainer appends additional container to pod.
func (*Builder) WithAdditionalInitContainer ¶
WithAdditionalInitContainer appends additional init container to pod.
func (*Builder) WithHostNetwork ¶
WithHostNetwork applies HostNetwork to pod's definition.
func (*Builder) WithHostPid ¶
WithHostPid configures a pod's access to the host process ID namespace based on a boolean parameter.
func (*Builder) WithHugePages ¶
WithHugePages sets hugePages on all containers inside the pod.
func (*Builder) WithLabels ¶
WithLabels applies a set of labels to a Pod's definition.
func (*Builder) WithLocalVolume ¶
WithLocalVolume attaches given volume to all pod's containers.
func (*Builder) WithNodeSelector ¶
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 ¶
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) WithTerminationGracePeriodSeconds ¶
func (builder *Builder) WithTerminationGracePeriodSeconds(terminationGracePeriodSeconds int64) *Builder
WithTerminationGracePeriodSeconds configures TerminationGracePeriodSeconds on the pod.
func (*Builder) WithToleration ¶
func (builder *Builder) WithToleration(toleration corev1.Toleration) *Builder
WithToleration adds a toleration configuration inside the pod.
func (*Builder) WithTolerationToControlPlane ¶
WithTolerationToControlPlane sets toleration policy which allows pod to be running on control plane node.
func (*Builder) WithTolerationToMaster ¶
WithTolerationToMaster sets toleration policy which allows pod to be running on master node.
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) WithPorts ¶
func (builder *ContainerBuilder) WithPorts(ports []corev1.ContainerPort) *ContainerBuilder
WithPorts adds a list of ports to expose from the container.
func (*ContainerBuilder) WithReadinessProbe ¶
func (builder *ContainerBuilder) WithReadinessProbe(readinessProbe *corev1.Probe) *ContainerBuilder
WithReadinessProbe adds a readinessProbe to the 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) WithStdin ¶
func (builder *ContainerBuilder) WithStdin(enableStdin bool) *ContainerBuilder
WithStdin applies Stdin value on container.
func (*ContainerBuilder) WithTTY ¶
func (builder *ContainerBuilder) WithTTY(enableTTY bool) *ContainerBuilder
WithTTY applies TTY value on container.
func (*ContainerBuilder) WithVolumeMount ¶
func (builder *ContainerBuilder) WithVolumeMount(volMount corev1.VolumeMount) *ContainerBuilder
WithVolumeMount adds a pod volume mount inside the container.