kube

package
v0.0.0-...-c5e374d Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 18 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 context for resources owned by jobs (pods/builds).
	DefaultClusterAlias = "default" // TODO(fejta): rename to context
	// InClusterContext specifies the context for prowjob resources.
	InClusterContext = ""
)
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"
	// CreatedByTideLabel is added by tide when it triggered a job.
	// TODO: Namespace this label.
	CreatedByTideLabel = "created-by-tide"
	// 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"
	// ProwBuildIDLabel is added in resources created by prow and
	// carries the BuildID from a Prow Job's Status.
	ProwBuildIDLabel = "prow.k8s.io/build-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"
	// ContextAnnotation is added in resources created by prow and
	// carries the context 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.
	ContextAnnotation = "prow.k8s.io/context"
	// PlankVersionLabel is added in resources created by prow and
	// carries the version of prow that decorated this job.
	PlankVersionLabel = "prow.k8s.io/plank-version"
	// 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"
	// BaseRefLabel is added in resources created by prow and
	// carries the base ref associated with the job, eg main
	BaseRefLabel = "prow.k8s.io/refs.base_ref"
	// 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"
	// RetestLabel exposes if the job was created by a re-test request.
	RetestLabel = "prow.k8s.io/retest"
	// IsOptionalLabel is added in resources created by prow and
	// carries the Optional from a Presubmit job.
	IsOptionalLabel = "prow.k8s.io/is-optional"

	// GerritID identifies a gerrit change
	GerritID = "prow.k8s.io/gerrit-id"
	// GerritInstance is the gerrit host url
	GerritInstance = "prow.k8s.io/gerrit-instance"
	// GerritRevision is the SHA of current patchset from a gerrit change
	GerritRevision = "prow.k8s.io/gerrit-revision"
	// GerritPatchset is the numeric ID of the current patchset
	GerritPatchset = "prow.k8s.io/gerrit-patchset"
	// GerritReportLabel is the gerrit label prow will cast vote on, fallback to CodeReview label if unset
	GerritReportLabel = "prow.k8s.io/gerrit-report-label"
)

Variables

This section is empty.

Functions

func GatherProwJobMetrics

func GatherProwJobMetrics(l *logrus.Entry, current []prowapi.ProwJob)

GatherProwJobMetrics gathers prometheus metrics for prowjobs. Not threadsafe, ensure this is called serially.

func GetKubernetesClient

func GetKubernetesClient(masterURL, kubeConfig string) (kubernetes.Interface, error)

GetKubernetesClient retrieves the Kubernetes cluster client from within the cluster

func GetProwJobClient

func GetProwJobClient(masterURL, kubeConfig string) (prowjobclientset.Interface, error)

GetKubernetesClient retrieves the Kubernetes cluster client from within the cluster

func LoadClusterConfigs

func LoadClusterConfigs(opts *Options) (map[string]rest.Config, error)

LoadClusterConfigs loads rest.Configs for creation of clients according to the given options. Errors are returned if a file/dir is specified in the options and invalid or if no valid contexts are found.

func RateLimiter

func RateLimiter(controllerName string) workqueue.RateLimitingInterface

RateLimiter creates a ratelimiting queue for a given prow controller.

Types

type ConfigOptions

type ConfigOptions func(*Options)

func ConfigDir

func ConfigDir(dir string) ConfigOptions

ConfigDir configures the directory containing kubeconfig files

func ConfigFile

func ConfigFile(file string) ConfigOptions

ConfigFile configures the path to a kubeconfig file

func ConfigProjectedTokenFile

func ConfigProjectedTokenFile(projectedTokenFile string) ConfigOptions

ConfigProjectedTokenFile configures the path to a projectedToken file

func ConfigSuffix

func ConfigSuffix(suffix string) ConfigOptions

ConfigSuffix configures the suffix of the file in directory containing kubeconfig files

func DisabledClusters

func DisabledClusters(disabledClusters sets.Set[string]) ConfigOptions

DisabledClusters configures the set of disabled build cluster names. They will be ignored as context names while loading kubeconfig files.

func NoInClusterConfig

func NoInClusterConfig(noInClusterConfig bool) ConfigOptions

NoInClusterConfig indicates that there is no InCluster Config to load

type Options

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

Options defines how to load kubeconfigs files

func NewConfig

func NewConfig(opts ...ConfigOptions) *Options

NewConfig builds Options according to the given ConfigOptions

Jump to

Keyboard shortcuts

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