pod

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: Apache-2.0 Imports: 40 Imported by: 14

Documentation

Overview

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

Index

Constants

View Source
const (
	// TektonHermeticEnvVar is the env var we set in containers to indicate they should be run hermetically
	TektonHermeticEnvVar = "TEKTON_HERMETIC"

	// ExecutionModeAnnotation is an experimental optional annotation to set the execution mode on a TaskRun
	ExecutionModeAnnotation = "experimental.tekton.dev/execution-mode"

	// ExecutionModeHermetic indicates hermetic execution mode
	ExecutionModeHermetic = "hermetic"
)
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"
)

Variables

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

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

Functions

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 IsSidecarStatusRunning added in v0.11.0

func IsSidecarStatusRunning(tr *v1beta1.TaskRun) bool

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

func MakeTaskRunStatus

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

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

func SidecarsReady

func SidecarsReady(podStatus corev1.PodStatus) bool

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

func StepName added in v0.27.0

func StepName(name string, i int) string

StepName returns the step name after adding "step-" prefix to the actual step name or returns "step-unnamed-<step-index>" if not specified

func StopSidecars

func StopSidecars(ctx context.Context, nopImage string, kubeclient kubernetes.Interface, namespace, name string) (*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(ctx context.Context, 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 Builder added in v0.15.0

type Builder struct {
	Images          pipeline.Images
	KubeClient      kubernetes.Interface
	EntrypointCache EntrypointCache
}

Builder exposes options to configure Pod construction from TaskSpecs/Runs.

func (*Builder) Build added in v0.15.0

func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec v1beta1.TaskSpec, transformers ...Transformer) (*corev1.Pod, error)

Build creates a Pod using the configuration options set on b and the TaskRun and TaskSpec provided in its arguments. An error is returned if there are any problems during the conversion.

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(ctx context.Context, ref name.Reference, namespace, serviceAccountName string) (v1.Image, error)
	// Set updates 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.

type Transformer added in v0.28.0

type Transformer func(*corev1.Pod) (*corev1.Pod, error)

Transformer is a function that will transform a Pod. This can be used to mutate a Pod generated by Tekton after it got generated.

Jump to

Keyboard shortcuts

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