pod

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: Apache-2.0 Imports: 31 Imported by: 14

Documentation

Overview

Package pod provides methods for converting between a TaskRun and a Pod.

Index

Constants

View Source
const (
	// ReasonCouldntGetTask indicates that the reason for the failure status is that the
	// Task couldn't be found
	ReasonCouldntGetTask = "CouldntGetTask"

	// ReasonFailedResolution indicated that the reason for failure status is
	// that references within the TaskRun could not be resolved
	ReasonFailedResolution = "TaskRunResolutionFailed"

	// ReasonFailedValidation indicated that the reason for failure status is
	// that taskrun failed runtime validation
	ReasonFailedValidation = "TaskRunValidationFailed"

	// ReasonExceededResourceQuota indicates that the TaskRun failed to create a pod due to
	// a ResourceQuota in the namespace
	ReasonExceededResourceQuota = "ExceededResourceQuota"

	// ReasonExceededNodeResources indicates that the TaskRun's pod has failed to start due
	// to resource constraints on the node
	ReasonExceededNodeResources = "ExceededNodeResources"

	// ReasonCreateContainerConfigError indicates that the TaskRun failed to create a pod due to
	// config error of container
	ReasonCreateContainerConfigError = "CreateContainerConfigError"

	// ReasonPodCreationFailed indicates that the reason for the current condition
	// is that the creation of the pod backing the TaskRun failed
	ReasonPodCreationFailed = "PodCreationFailed"

	// ReasonPending indicates that the pod is in corev1.Pending, and the reason is not
	// ReasonExceededNodeResources or IsPodHitConfigError
	ReasonPending = "Pending"
)
View Source
const (
	// ResultsDir is the folder used by default to create the results file
	ResultsDir = "/tekton/results"
)

Variables

View Source
var (
	ReleaseAnnotation      = "pipeline.tekton.dev/release"
	ReleaseAnnotationValue = version.PipelineVersion
)

These are effectively const, but Go doesn't have such an annotation.

Functions

func CredentialsPath added in v0.11.0

func CredentialsPath(shouldOverrideHomeEnv bool) string

CredentialsPath returns a string path to the location that the creds-init helper binary will write its credentials to. The only argument is a boolean true if Tekton will overwrite Steps' default HOME environment variable with /tekton/home.

func DidTaskRunFail added in v0.11.0

func DidTaskRunFail(pod *corev1.Pod) bool

DidTaskRunFail check the status of pod to decide if related taskrun is failed

func IsContainerStep added in v0.11.0

func IsContainerStep(name string) bool

isContainerStep returns true if the container name indicates that it represents a step.

func IsPodExceedingNodeResources

func IsPodExceedingNodeResources(pod *corev1.Pod) bool

IsPodExceedingNodeResources returns true if the Pod's status indicates there are insufficient resources to schedule the Pod.

func IsPodHitConfigError added in v0.10.0

func IsPodHitConfigError(pod *corev1.Pod) bool

IsPodHitConfigError returns true if the Pod's status undicates there are config error raised

func IsSidecarStatusRunning added in v0.11.0

func IsSidecarStatusRunning(tr *v1beta1.TaskRun) bool

IsSidecarStatusRunning determines if any SidecarStatus on a TaskRun is still running.

func MakeLabels added in v0.11.0

func MakeLabels(s *v1beta1.TaskRun) map[string]string

MakeLabels constructs the labels we will propagate from TaskRuns to Pods.

func MakePod

func MakePod(ctx context.Context, images pipeline.Images, taskRun *v1beta1.TaskRun, taskSpec v1beta1.TaskSpec, kubeclient kubernetes.Interface, entrypointCache EntrypointCache, overrideHomeEnv bool) (*corev1.Pod, error)

MakePod converts TaskRun and TaskSpec objects to a Pod which implements the taskrun specified by the supplied CRD.

func MakeTaskRunStatus

func MakeTaskRunStatus(logger *zap.SugaredLogger, tr v1beta1.TaskRun, pod *corev1.Pod, taskSpec v1beta1.TaskSpec) v1beta1.TaskRunStatus

MakeTaskRunStatus returns a TaskRunStatus based on the Pod's status.

func ShouldOverrideHomeEnv added in v0.11.0

func ShouldOverrideHomeEnv(ctx context.Context) bool

ShouldOverrideHomeEnv returns a bool indicating whether a Pod should have its $HOME environment variable overwritten with /tekton/home or if it should be left unmodified. The default behaviour is to overwrite the $HOME variable but this is planned to change in an upcoming release.

For further reference see https://github.com/tektoncd/pipeline/issues/2013

func SidecarsReady

func SidecarsReady(podStatus corev1.PodStatus) bool

SidecarsReady returns true if all of the Pod's sidecars are Ready or Terminated.

func SortContainerStatuses added in v0.13.0

func SortContainerStatuses(podInstance *corev1.Pod)

SortContainerStatuses sort ContainerStatuses based on "FinishedAt"

func StopSidecars

func StopSidecars(nopImage string, kubeclient kubernetes.Interface, pod corev1.Pod) error

StopSidecars updates sidecar containers in the Pod to a nop image, which exits successfully immediately.

func TrimSidecarPrefix added in v0.11.0

func TrimSidecarPrefix(name string) string

trimSidecarPrefix returns the container name, stripped of its sidecar prefix.

func UpdateReady

func UpdateReady(kubeclient kubernetes.Interface, pod corev1.Pod) error

UpdateReady updates the Pod's annotations to signal the first step to start by projecting the ready annotation via the Downward API.

Types

type EntrypointCache

type EntrypointCache interface {
	// Get the Image data for the given image reference. If the value is
	// not found in the cache, it will be fetched from the image registry,
	// possibly using K8s service account imagePullSecrets.
	Get(ref name.Reference, namespace, serviceAccountName string) (v1.Image, error)
	// Update the cache with a new digest->Image mapping. This will avoid a
	// remote registry lookup next time Get is called.
	Set(digest name.Digest, img v1.Image)
}

EntrypointCache looks up an image's entrypoint (command) in a container image registry, possibly using the given service account's credentials.

func NewEntrypointCache

func NewEntrypointCache(kubeclient kubernetes.Interface) (EntrypointCache, error)

NewEntrypointCache returns a new entrypoint cache implementation that uses K8s credentials to pull image metadata from a container image registry.

Jump to

Keyboard shortcuts

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