kube

package
v0.0.0-...-d7867ec Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TestContainerName specifies the primary container name.
	TestContainerName = "test"

	// EmptySelector selects everything
	EmptySelector = ""

	// DefaultClusterAlias specifies the default cluster key to schedule jobs.
	DefaultClusterAlias = "default"
)
View Source
const (
	// PresubmitJob means it runs on unmerged PRs.
	PresubmitJob = v1.PresubmitJob
	// PostsubmitJob means it runs on each new commit.
	PostsubmitJob = v1.PostsubmitJob
	// Periodic job means it runs on a time-basis, unrelated to git changes.
	PeriodicJob = v1.PeriodicJob
	// BatchJob tests multiple unmerged PRs at the same time.
	BatchJob = v1.BatchJob
)

Various job types.

View Source
const (
	// TriggeredState means the job has been created but not yet scheduled.
	TriggeredState = v1.TriggeredState
	// PendingState means the job is scheduled but not yet running.
	PendingState = v1.PendingState
	// SuccessState means the job completed without error (exit 0)
	SuccessState = v1.SuccessState
	// FailureState means the job completed with errors (exit non-zero)
	FailureState = v1.FailureState
	// AbortedState means prow killed the job early (new commit pushed, perhaps).
	AbortedState = v1.AbortedState
	// ErrorState means the job could not schedule (bad config, perhaps).
	ErrorState = v1.ErrorState
)

Various job states.

View Source
const (
	// KubernetesAgent means prow will create a pod to run this job.
	KubernetesAgent = v1.KubernetesAgent
	// JenkinsAgent means prow will schedule the job on jenkins.
	JenkinsAgent = v1.JenkinsAgent
)
View Source
const (
	// CreatedByProw is added on resources created by prow.
	// Since resources often live in another cluster/namespace,
	// the k8s garbage collector would immediately delete these
	// resources
	// TODO: Namespace this label.
	CreatedByProw = "created-by-prow"
	// ProwJobTypeLabel is added in resources 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 resources created by prow and
	// carries the ID of the ProwJob that the pod is fulfilling.
	// We also name resources 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 resources 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"
	// OrgLabel is added in resources created by prow and
	// carries the org associated with the job, eg kubernetes-sigs.
	OrgLabel = "prow.k8s.io/refs.org"
	// RepoLabel is added in resources created by prow and
	// carries the repo associated with the job, eg test-infra
	RepoLabel = "prow.k8s.io/refs.repo"
	// PullLabel is added in resources created by prow and
	// carries the PR number associated with the job, eg 321.
	PullLabel = "prow.k8s.io/refs.pull"
)
View Source
const (
	PathStrategyLegacy   = v1.PathStrategyLegacy
	PathStrategySingle   = v1.PathStrategySingle
	PathStrategyExplicit = v1.PathStrategyExplicit
)

PathStrategy specifies minutia about how to construct the url. Usually consumed by gubernator/testgrid.

View Source
const (
	PodPending   = v1.PodPending
	PodRunning   = v1.PodRunning
	PodSucceeded = v1.PodSucceeded
	PodFailed    = v1.PodFailed
	PodUnknown   = v1.PodUnknown
)

Phase constants

View Source
const (
	Evicted = "Evicted"
)

PodStatus constants

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.

func MarshalClusterMap

func MarshalClusterMap(c map[string]Cluster) ([]byte, error)

MarshalClusterMap writes c as yaml bytes.

func UnmarshalClusterMap

func UnmarshalClusterMap(data []byte) (map[string]Cluster, error)

UnmarshalClusterMap reads a map[string]Cluster in yaml bytes.

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)

CreateConfigMap creates a configmap, in the client's specified namespace.

Analogous to kubectl create configmap --namespace=client.namespace

func (*Client) CreatePod

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

CreatePod creates a pod in the client's specified namespace.

Analogous to kubectl create pod --namespace=client.namespace

func (*Client) CreateProwJob

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

CreateProwJob creates a prowjob in the client's specified namespace.

Analogous to kubectl create prowjob --namespace=client.namespace

func (*Client) DeletePod

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

DeletePod deletes the pod at name in the client's specified namespace.

Analogous to kubectl delete pod --namespace=client.namespace

func (*Client) DeleteProwJob

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

DeleteProwJob deletes the prowjob at name in the client's specified namespace.

Analogous to kubectl delete prowjob/NAME --namespace=client.namespace

func (*Client) GetConfigMap

func (c *Client) GetConfigMap(name, namespace string) (ConfigMap, error)

GetConfigMap gets the configmap identified, in the client's specified namespace.

Analogous to kubectl get configmap --namespace=client.namespace

func (*Client) GetContainerLog

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

GetContainerLog returns the log of a container in the specified pod, in the client's specified namespace.

Analogous to kubectl logs pod -c container --namespace=client.namespace

func (*Client) GetLog

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

GetLog returns the log of the default container in the specified pod, in the client's specified namespace.

Analogous to kubectl logs pod --namespace=client.namespace

func (*Client) GetLogTail

func (c *Client) GetLogTail(pod, container string, n int64) ([]byte, error)

GetLogTail returns the last n bytes of the log of the specified container in the specified pod, in the client's specified namespace.

Analogous to kubectl logs pod --tail -1 --limit-bytes n -c container --namespace=client.namespace

func (*Client) GetPod

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

GetPod is analogous to kubectl get pods/NAME namespace=client.namespace

func (*Client) GetProwJob

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

GetProwJob returns the prowjob at name in the client's specified namespace.

Analogous to kubectl get prowjob/NAME --namespace=client.namespace

func (*Client) ListPods

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

ListPods is analogous to kubectl get pods --selector=SELECTOR --namespace=client.namespace

func (*Client) ListProwJobs

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

ListProwJobs lists prowjobs using the specified labelSelector in the client's specified namespace.

Analogous to kubectl get prowjobs --selector=SELECTOR --namespace=client.namespace

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)

ReplaceConfigMap puts the configmap into name.

Analogous to kubectl replace configmap

If config.Namespace is empty, the client's specified namespace is used. Returns the content returned by the apiserver

func (*Client) ReplaceProwJob

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

ReplaceProwJob will replace name with job in the client's specified namespace.

Analogous to kubectl replace prowjobs/NAME --namespace=client.namespace

func (*Client) SetHiddenReposProvider

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

SetHiddenReposProvider 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 `json:"endpoint"`
	// Base64-encoded public cert used by clients to authenticate to the
	// cluster endpoint.
	ClientCertificate string `json:"clientCertificate"`
	// Base64-encoded private key used by clients..
	ClientKey string `json:"clientKey"`
	// Base64-encoded public certificate that is the root of trust for the
	// cluster.
	ClusterCACertificate string `json:"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

ConfigMap is a kubernetes v1 ConfigMap

type ConfigMapSource

type ConfigMapSource = v1.ConfigMapVolumeSource

ConfigMapSource is a kubernetes v1 ConfigMapVolumeSource

type ConflictError

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

ConflictError is http 409.

func NewConflictError

func NewConflictError(e error) ConflictError

NewConflictError returns an error with the embedded inner error

func (ConflictError) Error

func (e ConflictError) Error() string

type Container

type Container = v1.Container

Container is a kubernetes v1 Container

type DecorationConfig

type DecorationConfig = v1.DecorationConfig

DecorationConfig specifies how to augment pods.

This is primarily used to provide automatic integration with gubernator and testgrid.

type EmptyDirVolumeSource

type EmptyDirVolumeSource = v1.EmptyDirVolumeSource

EmptyDirVolumeSource is a kubernetes v1 EmptyDirVolumeSource

type EnvVar

type EnvVar = v1.EnvVar

EnvVar is a kubernetes v1 EnvVar

type GCSConfiguration

type GCSConfiguration = v1.GCSConfiguration

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

type Logger

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

Logger can print debug messages

type NotFoundError

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

NotFoundError happens when the apiserver returns http 404

func NewNotFoundError

func NewNotFoundError(e error) NotFoundError

NewNotFoundError returns an error with the embedded inner error

func (NotFoundError) Error

func (e NotFoundError) Error() string

type ObjectMeta

type ObjectMeta = metav1.ObjectMeta

ObjectMeta is a kubernetes v1 ObjectMeta

type Pod

type Pod = v1.Pod

Pod is a kubernetes v1 Pod

type PodSpec

type PodSpec = v1.PodSpec

PodSpec is a kubernetes v1 PodSpec

type PodStatus

type PodStatus = v1.PodStatus

PodStatus is a kubernetes v1 PodStatus

type PodTemplateSpec

type PodTemplateSpec = v1.PodTemplateSpec

PodTemplateSpec is a kubernetes v1 PodTemplateSpec

type Port

type Port = v1.ContainerPort

Port is a kubernetes v1 ContainerPort

type ProwJob

type ProwJob = v1.ProwJob

ProwJob contains the spec as well as runtime metadata.

type ProwJobAgent

type ProwJobAgent = v1.ProwJobAgent

ProwJobAgent specifies the controller (such as plank or jenkins-agent) that runs the job.

type ProwJobSpec

type ProwJobSpec = v1.ProwJobSpec

ProwJobSpec configures the details of the prow job.

Details include the podspec, code to clone, the cluster it runs any child jobs, concurrency limitations, etc.

type ProwJobState

type ProwJobState = v1.ProwJobState

ProwJobState specifies whether the job is running

type ProwJobStatus

type ProwJobStatus = v1.ProwJobStatus

ProwJobStatus provides runtime metadata, such as when it finished, whether it is running, etc.

type ProwJobType

type ProwJobType = v1.ProwJobType

ProwJobType specifies how the job is triggered.

type Pull

type Pull = v1.Pull

Pull describes a pull request at a particular point in time.

type Refs

type Refs = v1.Refs

Refs describes how the repo was constructed.

type Secret

type Secret = v1.Secret

Secret is a kubernetes v1 secret

type SecretSource

type SecretSource = v1.SecretVolumeSource

SecretSource is a kubernetes v1 SecretVolumeSource

type UnprocessableEntityError

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

UnprocessableEntityError happens when the apiserver returns http 422.

func NewUnprocessableEntityError

func NewUnprocessableEntityError(e error) UnprocessableEntityError

NewUnprocessableEntityError returns an error with the embedded inner error

func (UnprocessableEntityError) Error

func (e UnprocessableEntityError) Error() string

type UtilityImages

type UtilityImages = v1.UtilityImages

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

type Volume

type Volume = v1.Volume

Volume is a kubernetes v1 Volume

type VolumeMount

type VolumeMount = v1.VolumeMount

VolumeMount is a kubernetes v1 VolumeMount

type VolumeSource

type VolumeSource = v1.VolumeSource

VolumeSource is a kubernetes v1 VolumeSource

Jump to

Keyboard shortcuts

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