pod

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreAllPodsRunning

func AreAllPodsRunning(podPrefix, namespace string) (bool, error)

AreAllPodsRunning will return true if all pods in a given namespace are in a Running State

func AreAllPodsSucceeded

func AreAllPodsSucceeded(podPrefix, namespace string) (bool, bool, error)

AreAllPodsSucceeded returns true, false if all pods in a given namespace are in a Running State returns false, true if any one pod is in a Failed state

func PrintPodsLogs added in v0.41.0

func PrintPodsLogs(podPrefix, namespace string)

PrintPodsLogs prints logs for all pods whose name matches a substring

func ReplaceContainerImageFromFile

func ReplaceContainerImageFromFile(filename, containerImage string) (string, error)

ReplaceContainerImageFromFile loads in a YAML, finds the image: line, and replaces it with the value of containerImage

func RunCommandMultipleTimes

func RunCommandMultipleTimes(podRunnerCmd podRunnerCmd, image, name, command string, desiredAttempts int, sleep, commandTimeout, timeout time.Duration) (int, error)

RunCommandMultipleTimes runs the same command 'desiredAttempts' times

func WaitOnReady

func WaitOnReady(podPrefix, namespace string, successesNeeded int, sleep, timeout time.Duration) (bool, error)

WaitOnReady returns true if all pods matching a prefix substring are in a succeeded state within a period of time successesNeeded is used to make sure we return the correct value even if the pod is in a CrashLoop

func WaitOnSucceeded

func WaitOnSucceeded(name, namespace string, sleep, timeout time.Duration) (bool, error)

WaitOnSucceeded will return true if a pod is in a Succeeded State

func WaitOnTerminated added in v0.41.0

func WaitOnTerminated(name, namespace, containerName string, sleep, containerExecutionTimeout, timeout time.Duration) (bool, error)

WaitOnTerminated will return true if a pod's container is in a successful (0 exit code) Terminated State and completed prior to the passed in containerExecutionTimeout

Types

type AreAllPodsRunningResult added in v0.41.0

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

AreAllPodsRunningResult is a return struct for AreAllPodsRunningAsync

func AreAllPodsRunningAsync added in v0.41.0

func AreAllPodsRunningAsync(podPrefix, namespace string) AreAllPodsRunningResult

AreAllPodsRunningAsync wraps AreAllPodsRunning with a struct response for goroutine + channel usage

type AreAllPodsSucceededResult added in v0.41.0

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

AreAllPodsSucceededResult is a return struct for AreAllPodsSucceeded

func AreAllPodsSucceededAsync added in v0.41.0

func AreAllPodsSucceededAsync(podPrefix, namespace string) AreAllPodsSucceededResult

AreAllPodsSucceededAsync wraps AreAllPodsSucceeded with a struct response for goroutine + channel usage

type Container

type Container struct {
	Image     string    `json:"image"`
	Ports     []Port    `json:"ports"`
	Env       []EnvVar  `json:"env"`
	Resources Resources `json:"resources"`
	Name      string    `json:"name"`
	Args      []string  `json:"args"`
}

Container holds information like image and ports

func (*Container) GetArg added in v0.30.0

func (c *Container) GetArg(argKey string) (string, error)

GetArg returns an arg's value from a container within a pod

func (*Container) GetEnvironmentVariable

func (c *Container) GetEnvironmentVariable(varName string) (string, error)

GetEnvironmentVariable returns an environment variable value from a container within a pod

func (*Container) ValidateResources

func (c *Container) ValidateResources(a api.KubernetesContainerSpec) error

ValidateResources checks that an addon has the expected memory/cpu limits and requests

type ContainerState

type ContainerState struct {
	Terminated TerminatedContainerState `json:"terminated"`
}

ContainerState has state of a container

type ContainerStatus

type ContainerStatus struct {
	ContainerID  string         `json:"containerID"`
	Image        string         `json:"image"`
	ImageID      string         `json:"imageID"`
	Name         string         `json:"name"`
	Ready        bool           `json:"ready"`
	RestartCount int            `json:"restartCount"`
	State        ContainerState `json:"state"`
	LastState    ContainerState `json:"lastState"`
}

ContainerStatus has status of a container

func (*ContainerStatus) EndTime added in v0.41.0

func (c *ContainerStatus) EndTime() string

EndTime returns a ContainerStatus's terminal "finished at" RFC3339 time

func (*ContainerStatus) ExitCode added in v0.41.0

func (c *ContainerStatus) ExitCode() int

ExitCode returns a ContainerStatus's terminal exit code

func (*ContainerStatus) StartTime added in v0.41.0

func (c *ContainerStatus) StartTime() string

StartTime returns a terminal ContainerStatus's terminal "started at" RFC3339 time

type EnvVar

type EnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

EnvVar holds environment variables

type ExecResult added in v0.41.0

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

ExecResult is a return struct for ExecAsync

type GetAllByPrefixResult added in v0.41.0

type GetAllByPrefixResult struct {
	Pods []Pod
	Err  error
}

GetAllByPrefixResult is the result type for GetAllByPrefixAsync

func GetAllByPrefixAsync added in v0.41.0

func GetAllByPrefixAsync(prefix, namespace string) GetAllByPrefixResult

GetAllByPrefixAsync wraps GetAllByPrefix with a struct response for goroutine + channel usage

type GetPodResult added in v0.41.0

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

GetPodResult is a return struct for GetPodAsync

func GetPodAsync added in v0.41.0

func GetPodAsync(name, namespace string, timeout time.Duration) GetPodResult

GetPodAsync wraps GetWithRetry with a struct response for goroutine + channel usage

type GetResult added in v0.41.0

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

GetResult is a return struct for GetAsync

func GetAsync added in v0.41.0

func GetAsync(podName, namespace string) GetResult

GetAsync wraps Get with a struct response for goroutine + channel usage

type Limits

type Limits struct {
	CPU    string `json:"cpu"`
	Memory string `json:"memory"`
}

Limits represents container resource limits

type List

type List struct {
	Pods []Pod `json:"items"`
}

List is a container that holds all pods returned from doing a kubectl get pods

func GetAll

func GetAll(namespace string) (*List, error)

GetAll will return all pods in a given namespace

func (*List) CheckOutboundConnection added in v0.33.0

func (l *List) CheckOutboundConnection(sleep, timeout time.Duration, osType api.OSType) (bool, error)

CheckOutboundConnection checks outbound connection for a list of pods.

func (*List) ValidateCurlConnection added in v0.33.0

func (l *List) ValidateCurlConnection(uri string, sleep, timeout time.Duration) (bool, error)

ValidateCurlConnection checks curl connection for a list of Linux pods to a specified uri.

type Metadata

type Metadata struct {
	CreatedAt time.Time         `json:"creationTimestamp"`
	Labels    map[string]string `json:"labels"`
	Name      string            `json:"name"`
	Namespace string            `json:"namespace"`
}

Metadata holds information like name, createdat, labels, and namespace

type Pod

type Pod struct {
	Metadata Metadata `json:"metadata"`
	Spec     Spec     `json:"spec"`
	Status   Status   `json:"status"`
}

Pod is used to parse data from kubectl get pods

func CreatePodFromFile

func CreatePodFromFile(filename, name, namespace string, sleep, timeout time.Duration) (*Pod, error)

CreatePodFromFile will create a Pod from file with a name

func CreatePodFromFileIfNotExist added in v0.36.0

func CreatePodFromFileIfNotExist(filename, name, namespace string, sleep, timeout time.Duration) (*Pod, error)

CreatePodFromFileIfNotExist will create a Pod from file with a name

func Get

func Get(podName, namespace string, retries int) (*Pod, error)

Get will return a pod with a given name and namespace

func GetAllByPrefix

func GetAllByPrefix(prefix, namespace string) ([]Pod, error)

GetAllByPrefix will return all pods in a given namespace that match a prefix

func GetWithRetry

func GetWithRetry(podPrefix, namespace string, sleep, timeout time.Duration) (*Pod, error)

GetWithRetry gets a pod, allowing for retries

func RunLinuxPod

func RunLinuxPod(image, name, namespace, command string, printOutput bool, sleep, commandTimeout, podGetTimeout time.Duration) (*Pod, error)

RunLinuxPod will create a pod that runs a bash command --overrides := `"spec": {"nodeSelector":{"beta.kubernetes.io/os":"windows"}}}`

func RunWindowsPod

func RunWindowsPod(image, name, namespace, command string, printOutput bool, sleep, duration time.Duration, timeout time.Duration) (*Pod, error)

RunWindowsPod will create a pod that runs a powershell command --overrides := `"spec": {"nodeSelector":{"beta.kubernetes.io/os":"windows"}}}`

func (*Pod) CheckLinuxOutboundConnection

func (p *Pod) CheckLinuxOutboundConnection(sleep, timeout time.Duration) (bool, error)

CheckLinuxOutboundConnection will keep retrying the check if an error is received until the timeout occurs or it passes. This helps us when DNS may not be available for some time after a pod starts.

func (*Pod) CheckWindowsOutboundConnection

func (p *Pod) CheckWindowsOutboundConnection(sleep, timeout time.Duration) (bool, error)

CheckWindowsOutboundConnection will keep retrying the check if an error is received until the timeout occurs or it passes. This helps us when DNS may not be available for some time after a pod starts.

func (*Pod) ContainerStatus added in v0.41.0

func (p *Pod) ContainerStatus(name string) (ContainerStatus, error)

ContainerStatus returns a named pod ContainerStatus object

func (*Pod) Delete

func (p *Pod) Delete(retries int) error

Delete will delete a Pod in a given namespace

func (*Pod) Describe added in v0.33.0

func (p *Pod) Describe() error

Describe will describe a pod resource

func (*Pod) Exec

func (p *Pod) Exec(c ...string) ([]byte, error)

Exec will execute the given command in the pod

func (*Pod) ExecAsync added in v0.41.0

func (p *Pod) ExecAsync(c ...string) ExecResult

ExecAsync wraps Exec with a struct response for goroutine + channel usage

func (*Pod) IsFailed added in v0.41.0

func (p *Pod) IsFailed() bool

IsFailed returns if a pod is in a Failed state

func (*Pod) IsSucceeded added in v0.41.0

func (p *Pod) IsSucceeded() bool

IsSucceeded returns if a pod is in a Succeeded state

func (*Pod) Logs added in v0.30.0

func (p *Pod) Logs() error

Logs will get logs from all containers in a pod

func (*Pod) ValidateAzureFile

func (p *Pod) ValidateAzureFile(mountPath string, sleep, timeout time.Duration) (bool, error)

ValidateAzureFile will keep retrying the check if azure file is mounted in Pod

func (*Pod) ValidateCurlConnection

func (p *Pod) ValidateCurlConnection(uri string, sleep, timeout time.Duration) (bool, error)

ValidateCurlConnection connects to a URI on TCP 80

func (*Pod) ValidateHostPort

func (p *Pod) ValidateHostPort(check string, attempts int, sleep time.Duration, master, sshKeyPath string) bool

ValidateHostPort will attempt to run curl against the POD's hostIP and hostPort

func (*Pod) ValidateOmsAgentLogs

func (p *Pod) ValidateOmsAgentLogs(execCmdString string, sleep, timeout time.Duration) (bool, error)

ValidateOmsAgentLogs validates omsagent logs

func (*Pod) ValidatePVC

func (p *Pod) ValidatePVC(mountPath string, sleep, timeout time.Duration) (bool, error)

ValidatePVC will keep retrying the check if azure disk is mounted in Pod

func (*Pod) WaitOnReady

func (p *Pod) WaitOnReady(sleep, timeout time.Duration) (bool, error)

WaitOnReady will call the static method WaitOnReady passing in p.Metadata.Name and p.Metadata.Namespace

func (*Pod) WaitOnSucceeded

func (p *Pod) WaitOnSucceeded(sleep, duration time.Duration) (bool, error)

WaitOnSucceeded will call the static method WaitOnSucceeded passing in p.Metadata.Name and p.Metadata.Namespace

func (*Pod) WaitOnTerminated added in v0.41.0

func (p *Pod) WaitOnTerminated(container string, sleep, containerExecutionTimeout, timeout time.Duration) (bool, error)

WaitOnTerminated will call the static method WaitOnTerminated passing in p.Metadata.Name and p.Metadata.Namespace

type Port

type Port struct {
	ContainerPort int `json:"containerPort"`
	HostPort      int `json:"hostPort"`
}

Port represents a container port definition

type Requests

type Requests struct {
	CPU    string `json:"cpu"`
	Memory string `json:"memory"`
}

Requests represents container resource requests

type Resources

type Resources struct {
	Requests Requests `json:"requests"`
	Limits   Limits   `json:"limits"`
}

Resources represents a container resources definition

type Spec

type Spec struct {
	Containers []Container `json:"containers"`
	NodeName   string      `json:"nodeName"`
}

Spec holds information like containers

type Status

type Status struct {
	HostIP            string            `json:"hostIP"`
	Phase             string            `json:"phase"`
	PodIP             string            `json:"podIP"`
	StartTime         time.Time         `json:"startTime"`
	ContainerStatuses []ContainerStatus `json:"containerStatuses"`
}

Status holds information like hostIP and phase

type TerminatedContainerState

type TerminatedContainerState struct {
	ContainerID string `json:"containerID"`
	ExitCode    int    `json:"exitCode"`
	FinishedAt  string `json:"finishedAt"`
	Reason      string `json:"reason"`
	StartedAt   string `json:"startedAt"`
}

TerminatedContainerState shows terminated state of a container

Jump to

Keyboard shortcuts

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