kube

package
v0.0.0-...-6ca4c02 Latest Latest
Warning

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

Go to latest
Published: May 19, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestContainerName = "test"

	EmptySelector = ""

	DefaultClusterAlias = "default"
)
View Source
const (
	PresubmitJob  ProwJobType = "presubmit"
	PostsubmitJob             = "postsubmit"
	PeriodicJob               = "periodic"
	BatchJob                  = "batch"
)
View Source
const (
	TriggeredState ProwJobState = "triggered"
	PendingState                = "pending"
	SuccessState                = "success"
	FailureState                = "failure"
	AbortedState                = "aborted"
	ErrorState                  = "error"
)
View Source
const (
	// CreatedByProw is added on pods created by prow. We cannot
	// really use owner references because pods may reside on a
	// different namespace from the namespace parent prowjobs
	// live and that would cause the k8s garbage collector to
	// identify those prow pods as orphans and delete them
	// instantly.
	// TODO: Namespace this label.
	CreatedByProw = "created-by-prow"
	// ProwJobTypeLabel is added in pods created by prow and
	// carries the job type (presubmit, postsubmit, periodic, batch)
	// that the pod is running.
	ProwJobTypeLabel = "prow.k8s.io/type"
	// ProwJobIDLabel is added in pods created by prow and
	// carries the ID of the ProwJob that the pod is fulfilling.
	// We also name pods after the ProwJob that spawned them but
	// this allows for multiple resources to be linked to one
	// ProwJob.
	ProwJobIDLabel = "prow.k8s.io/id"
	// ProwJobAnnotation is added in pods created by prow and
	// carries the name of the job that the pod is running. Since
	// job names can be arbitrarily long, this is added as
	// an annotation instead of a label.
	ProwJobAnnotation = "prow.k8s.io/job"
)
View Source
const (
	PathStrategyLegacy   = "legacy"
	PathStrategySingle   = "single"
	PathStrategyExplicit = "explicit"
)
View Source
const (
	PodPending   = v1.PodPending
	PodRunning   = v1.PodRunning
	PodSucceeded = v1.PodSucceeded
	PodFailed    = v1.PodFailed
	PodUnknown   = v1.PodUnknown
)
View Source
const (
	Evicted = "Evicted"
)

Variables

This section is empty.

Functions

func ClientMapFromFile

func ClientMapFromFile(clustersPath, namespace string) (map[string]*Client, error)

ClientMapFromFile reads the file at clustersPath and attempts to load a map of cluster aliases to authenticated clients to the respective clusters. The file at clustersPath is expected to be a yaml map from strings to Cluster structs OR it may simply be a single Cluster struct which will be assigned the alias $DefaultClusterAlias. If the file is an alias map, it must include the alias $DefaultClusterAlias.

func GatherProwJobMetrics

func GatherProwJobMetrics(pjs []ProwJob)

GatherProwJobMetrics gathers prometheus metrics for prowjobs.

Types

type Client

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

Client interacts with the Kubernetes api-server.

func NewClient

func NewClient(c *Cluster, namespace string) (*Client, error)

NewClient returns an authenticated Client using the keys in the Cluster.

func NewClientFromFile

func NewClientFromFile(clusterPath, namespace string) (*Client, error)

NewClientFromFile reads a Cluster object at clusterPath and returns an authenticated client using the keys within.

func NewClientInCluster

func NewClientInCluster(namespace string) (*Client, error)

NewClientInCluster creates a Client that works from within a pod.

func NewFakeClient

func NewFakeClient(deckURL string) *Client

NewFakeClient creates a client that doesn't do anything. If you provide a deck URL then the client will hit that for the supported calls.

func (*Client) CreateConfigMap

func (c *Client) CreateConfigMap(content ConfigMap) (ConfigMap, error)

func (*Client) CreatePod

func (c *Client) CreatePod(p v1.Pod) (Pod, error)

func (*Client) CreateProwJob

func (c *Client) CreateProwJob(j ProwJob) (ProwJob, error)

func (*Client) DeletePod

func (c *Client) DeletePod(name string) error

func (*Client) DeleteProwJob

func (c *Client) DeleteProwJob(name string) error

func (*Client) GetLog

func (c *Client) GetLog(pod string) ([]byte, error)

func (*Client) GetPod

func (c *Client) GetPod(name string) (Pod, error)

func (*Client) GetProwJob

func (c *Client) GetProwJob(name string) (ProwJob, error)

func (*Client) ListPods

func (c *Client) ListPods(selector string) ([]Pod, error)

func (*Client) ListProwJobs

func (c *Client) ListProwJobs(selector string) ([]ProwJob, error)

func (*Client) Namespace

func (c *Client) Namespace(ns string) *Client

Namespace returns a copy of the client pointing at the specified namespace.

func (*Client) ReplaceConfigMap

func (c *Client) ReplaceConfigMap(name string, config ConfigMap) (ConfigMap, error)

func (*Client) ReplaceProwJob

func (c *Client) ReplaceProwJob(name string, job ProwJob) (ProwJob, error)

func (*Client) SetHiddenReposProvider

func (c *Client) SetHiddenReposProvider(p func() []string, hiddenOnly bool)

SetHiddenRepoProvider takes a continuation that fetches a list of orgs and repos for which PJs should not be returned. NOTE: This function is not thread safe and should be called before the client is in use.

type Cluster

type Cluster struct {
	// The IP address of the cluster's master endpoint.
	Endpoint string `yaml:"endpoint"`
	// Base64-encoded public cert used by clients to authenticate to the
	// cluster endpoint.
	ClientCertificate string `yaml:"clientCertificate"`
	// Base64-encoded private key used by clients..
	ClientKey string `yaml:"clientKey"`
	// Base64-encoded public certificate that is the root of trust for the
	// cluster.
	ClusterCACertificate string `yaml:"clusterCaCertificate"`
}

Cluster represents the information necessary to talk to a Kubernetes master endpoint. NOTE: if your cluster runs on GKE you can use the following command to get these credentials: gcloud --project <gcp_project> container clusters describe --zone <zone> <cluster_name>

type ConfigMap

type ConfigMap = v1.ConfigMap

type ConfigMapSource

type ConfigMapSource = v1.ConfigMapVolumeSource

type ConflictError

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

func NewConflictError

func NewConflictError(e error) ConflictError

func (ConflictError) Error

func (e ConflictError) Error() string

type Container

type Container = v1.Container

type DecorationConfig

type DecorationConfig struct {
	// Timeout is how long the pod utilities will wait
	// before aborting a job with SIGINT.
	Timeout time.Duration `json:"timeout,omitempty"`
	// GracePeriod is how long the pod utilities will wait
	// after sending SIGINT to send SIGKILL when aborting
	// a job. Only applicable if decorating the PodSpec.
	GracePeriod time.Duration `json:"grace_period,omitempty"`
	// UtilityImages holds pull specs for utility container
	// images used to decorate a PodSpec.
	UtilityImages *UtilityImages `json:"utility_images,omitempty"`
	// GCSConfiguration holds options for pushing logs and
	// artifacts to GCS from a job.
	GCSConfiguration *GCSConfiguration `json:"gcs_configuration,omitempty"`
	// GCSCredentialsSecret is the name of the Kubernetes secret
	// that holds GCS push credentials
	GCSCredentialsSecret string `json:"gcs_credentials_secret,omitempty"`
	// SshKeySecrets are the names of Kubernetes secrets that contain
	// SSK keys which should be used during the cloning process
	SshKeySecrets []string `json:"ssh_key_secrets,omitempty"`
}

type EmptyDirVolumeSource

type EmptyDirVolumeSource = v1.EmptyDirVolumeSource

type EnvVar

type EnvVar = v1.EnvVar

type GCSConfiguration

type GCSConfiguration struct {
	// Bucket is the GCS bucket to upload to
	Bucket string `json:"bucket,omitempty"`
	// PathPrefix is an optional path that follows the
	// bucket name and comes before any structure
	PathPrefix string `json:"path_prefix,omitempty"`
	// PathStrategy dictates how the org and repo are used
	// when calculating the full path to an artifact in GCS
	PathStrategy string `json:"path_strategy,omitempty"`
	// DefaultOrg is omitted from GCS paths when using the
	// legacy or simple strategy
	DefaultOrg string `json:"default_org,omitempty"`
	// DefaultRepo is omitted from GCS paths when using the
	// legacy or simple strategy
	DefaultRepo string `json:"default_repo,omitempty"`
}

GCSConfiguration holds options for pushing logs and artifacts to GCS from a job.

type Logger

type Logger interface {
	Debugf(s string, v ...interface{})
}

type ObjectMeta

type ObjectMeta = metav1.ObjectMeta

type Pod

type Pod = v1.Pod

type PodSpec

type PodSpec = v1.PodSpec

type PodStatus

type PodStatus = v1.PodStatus

type PodTemplateSpec

type PodTemplateSpec = v1.PodTemplateSpec

type Port

type Port = v1.ContainerPort

type ProwJob

type ProwJob struct {
	APIVersion        string `json:"apiVersion,omitempty"`
	Kind              string `json:"kind,omitempty"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   ProwJobSpec   `json:"spec,omitempty"`
	Status ProwJobStatus `json:"status,omitempty"`
}

func (*ProwJob) ClusterAlias

func (j *ProwJob) ClusterAlias() string

func (*ProwJob) Complete

func (j *ProwJob) Complete() bool

func (*ProwJob) SetComplete

func (j *ProwJob) SetComplete()

type ProwJobAgent

type ProwJobAgent string
const (
	KubernetesAgent ProwJobAgent = "kubernetes"
	JenkinsAgent                 = "jenkins"
)

type ProwJobSpec

type ProwJobSpec struct {
	// Type is the type of job and informs how
	// the jobs is triggered
	Type ProwJobType `json:"type,omitempty"`
	// Agent determines which controller fulfills
	// this specific ProwJobSpec and runs the job
	Agent ProwJobAgent `json:"agent,omitempty"`
	// Cluster is which Kubernetes cluster is used
	// to run the job, only applicable for that
	// specific agent
	Cluster string `json:"cluster,omitempty"`
	// Job is the name of the job
	Job string `json:"job,omitempty"`
	// Refs is the code under test, determined at
	// runtime by Prow itself
	Refs *Refs `json:"refs,omitempty"`
	// ExtraRefs are auxiliary repositories that
	// need to be cloned, determined from config
	ExtraRefs []*Refs `json:"extra_refs,omitempty"`

	// Report determines if the result of this job should
	// be posted as a status on GitHub
	Report bool `json:"report,omitempty"`
	// Context is the name of the status context used to
	// report back to GitHub
	Context string `json:"context,omitempty"`
	// RerunCommand is the command a user would write to
	// trigger this job on their pull request
	RerunCommand string `json:"rerun_command,omitempty"`
	// MaxConcurrency restricts the total number of instances
	// of this job that can run in parallel at once
	MaxConcurrency int `json:"max_concurrency,omitempty"`

	// PodSpec provides the basis for running the test under
	// a Kubernetes agent
	PodSpec *v1.PodSpec `json:"pod_spec,omitempty"`

	// DecorationConfig holds configuration options for
	// decorating PodSpecs that users provide
	DecorationConfig *DecorationConfig `json:"decoration_config,omitempty"`

	// RunAfterSuccess are jobs that should be triggered if
	// this job runs and does not fail
	RunAfterSuccess []ProwJobSpec `json:"run_after_success,omitempty"`
}

type ProwJobState

type ProwJobState string

type ProwJobStatus

type ProwJobStatus struct {
	StartTime      metav1.Time  `json:"startTime,omitempty"`
	CompletionTime *metav1.Time `json:"completionTime,omitempty"`
	State          ProwJobState `json:"state,omitempty"`
	Description    string       `json:"description,omitempty"`
	URL            string       `json:"url,omitempty"`

	// PodName applies only to ProwJobs fulfilled by
	// plank. This field should always be the same as
	// the ProwJob.ObjectMeta.Name field.
	PodName string `json:"pod_name,omitempty"`

	// BuildID is the build identifier vended either by tot
	// or the snowflake library for this job and used as an
	// identifier for grouping artifacts in GCS for views in
	// TestGrid and Gubernator. Idenitifiers vended by tot
	// are monotonically increasing whereas identifiers vended
	// by the snowflake library are not.
	BuildID string `json:"build_id,omitempty"`

	// JenkinsBuildID applies only to ProwJobs fulfilled
	// by the jenkins-operator. This field is the build
	// identifier that Jenkins gave to the build for this
	// ProwJob.
	JenkinsBuildID string `json:"jenkins_build_id,omitempty"`
}

type ProwJobType

type ProwJobType string

type Pull

type Pull struct {
	Number int    `json:"number,omitempty"`
	Author string `json:"author,omitempty"`
	SHA    string `json:"sha,omitempty"`

	// Ref is git ref can be checked out for a change
	// for example,
	// github: pull/123/head
	// gerrit: refs/changes/00/123/1
	Ref string `json:"ref,omitempty"`
}

type Refs

type Refs struct {
	Org  string `json:"org,omitempty"`
	Repo string `json:"repo,omitempty"`

	BaseRef string `json:"base_ref,omitempty"`
	BaseSHA string `json:"base_sha,omitempty"`

	Pulls []Pull `json:"pulls,omitempty"`

	// PathAlias is the location under <root-dir>/src
	// where this repository is cloned. If this is not
	// set, <root-dir>/src/github.com/org/repo will be
	// used as the default.
	PathAlias string `json:"path_alias,omitempty"`
	// CloneURI is the URI that is used to clone the
	// repository. If unset, will default to
	// `https://github.com/org/repo.git`.
	CloneURI string `json:"clone_uri,omitempty"`
}

func (Refs) String

func (r Refs) String() string

type Secret

type Secret = v1.Secret

type SecretSource

type SecretSource = v1.SecretVolumeSource

type UnprocessableEntityError

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

func NewUnprocessableEntityError

func NewUnprocessableEntityError(e error) UnprocessableEntityError

func (UnprocessableEntityError) Error

func (e UnprocessableEntityError) Error() string

type UtilityImages

type UtilityImages struct {
	// CloneRefs is the pull spec used for the clonerefs utility
	CloneRefs string `json:"clonerefs,omitempty"`
	// InitUpload is the pull spec used for the initupload utility
	InitUpload string `json:"initupload,omitempty"`
	// Entrypoint is the pull spec used for the entrypoint utility
	Entrypoint string `json:"entrypoint,omitempty"`
	// sidecar is the pull spec used for the sidecar utility
	Sidecar string `json:"sidecar,omitempty"`
}

UtilityImages holds pull specs for the utility images to be used for a job

type Volume

type Volume = v1.Volume

type VolumeMount

type VolumeMount = v1.VolumeMount

type VolumeSource

type VolumeSource = v1.VolumeSource

Jump to

Keyboard shortcuts

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