k8s

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2020 License: Apache-2.0 Imports: 73 Imported by: 0

Documentation

Index

Constants

View Source
const ContainerIDPrefix = "docker://"
View Source
const DefaultNamespace = Namespace("default")
View Source
const MagicTestContainerID = "tilt-testcontainer"

A magic constant. If the docker client returns this constant, we always match even if the container doesn't have the correct image name.

View Source
const ManagedByLabel = "app.kubernetes.io/managed-by"

https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/

View Source
const ManagedByValue = "tilt"
View Source
const ManifestNameLabel = "tilt-manifest"
View Source
const TiltPodTemplateHashLabel = "tilt.dev/pod-template-hash"

Variables

View Source
var EventGVR = v1.SchemeGroupVersion.WithResource("events")
View Source
var ForbiddenFieldsRe = regexp.MustCompile(`updates to .* are forbidden`)
View Source
var MetadataAnnotationsTooLongRe = regexp.MustCompile(`metadata.annotations: Too long: must have at most \d+ bytes.*`)
View Source
var NoFilter = func(v reflect.Value) bool {
	return true
}
View Source
var PodGVR = v1.SchemeGroupVersion.WithResource("pods")
View Source
var ServiceGVR = v1.SchemeGroupVersion.WithResource("services")

Functions

func ContainerIDFromContainerStatus

func ContainerIDFromContainerStatus(status v1.ContainerStatus) (container.ID, error)

func ContainerMatching

func ContainerMatching(pod *v1.Pod, ref container.RefSelector) (v1.ContainerStatus, error)

func ContainerNameFromContainerStatus

func ContainerNameFromContainerStatus(status v1.ContainerStatus) container.Name

func ContainerSpecOf

func ContainerSpecOf(pod *v1.Pod, status v1.ContainerStatus) v1.Container

func ExtractPodTemplateSpec added in v0.1.0

func ExtractPodTemplateSpec(obj interface{}) ([]*v1.PodTemplateSpec, error)

func ExtractPods

func ExtractPods(obj interface{}) ([]*v1.PodSpec, error)

func FakePodSpec

func FakePodSpec(image reference.NamedTagged) v1.PodSpec

func FakePodStatus

func FakePodStatus(image reference.NamedTagged, phase string) v1.PodStatus

func FindImageNamedTaggedMatching added in v0.2.0

func FindImageNamedTaggedMatching(pod v1.PodSpec, selector container.RefSelector) (reference.NamedTagged, error)

func FindImageRefMatching added in v0.2.0

func FindImageRefMatching(pod v1.PodSpec, selector container.RefSelector) (reference.Named, error)

func FixContainerStatusImages added in v0.8.2

func FixContainerStatusImages(pod *v1.Pod)

Kubernetes has a bug where the image ref in the container status can be wrong (though this does not mean the container is running unexpected code)

Repro steps: 1) Create an image and give it two different tags (A and B) 2) Deploy Pods with both A and B in the pod spec 3) The PodStatus will choose A or B for both pods.

More details here: https://github.com/kubernetes/kubernetes/issues/51017

For Tilt, it's pretty important that the image tag is correct (for matching purposes). To work around this bug, we change the image reference in ContainerStatus to match the ContainerSpec.

func IsContainerExited

func IsContainerExited(pod v1.PodStatus, container v1.ContainerStatus) bool

If true, this means the container is gone and will never recover.

func IsUnschedulable

func IsUnschedulable(pod v1.PodStatus) (bool, string)

Returns the error message if the pod is unschedulable

func LabelPairsToSelector added in v0.8.7

func LabelPairsToSelector(lps []model.LabelPair) labels.Selector

func ManagedByTiltSelector added in v0.10.7

func ManagedByTiltSelector() labels.Selector

func MustTarget added in v0.13.0

func MustTarget(name model.TargetName, yaml string) model.K8sTarget

func NewK8sOnlyManifest added in v0.6.0

func NewK8sOnlyManifest(name model.ManifestName, entities []K8sEntity) (model.Manifest, error)

func NewK8sOnlyManifestFromYAML added in v0.9.3

func NewK8sOnlyManifestFromYAML(yaml string) (model.Manifest, error)

func NewTarget added in v0.6.0

func NewTarget(
	name model.TargetName,
	entities []K8sEntity,
	portForwards []model.PortForward,
	extraPodSelectors []labels.Selector,
	dependencyIDs []model.TargetID,
	refInjectCounts map[string]int) (model.K8sTarget, error)

func NewTiltLabelMap added in v0.10.7

func NewTiltLabelMap() map[string]string

func NormalizeContainerID added in v0.9.6

func NormalizeContainerID(id string) (container.ID, error)

func OwnerRefToObjectRef added in v0.10.5

func OwnerRefToObjectRef(owner metav1.OwnerReference, namespace string) v1.ObjectReference

func PodContainsRef

func PodContainsRef(pod v1.PodSpec, selector container.RefSelector) (bool, error)

func ProvideClientConfig added in v0.7.3

func ProvideClientConfig() clientcmd.ClientConfig

func ProvideContainerRuntime added in v0.7.6

func ProvideContainerRuntime(ctx context.Context, kCli Client) container.Runtime

func ProvideKubeConfig added in v0.7.10

func ProvideKubeConfig(clientLoader clientcmd.ClientConfig) (*api.Config, error)

func ProvideKubectlRunner added in v0.7.4

func ProvideKubectlRunner(kubeContext KubeContext, logLevel KubectlLogLevel) kubectlRunner

func ProvideServerVersion added in v0.7.6

func ProvideServerVersion(maybeClientset ClientsetOrError) (*version.Info, error)

func RuntimeObjToOwnerRef added in v0.10.5

func RuntimeObjToOwnerRef(obj runtime.Object) metav1.OwnerReference

func SelectorEqual added in v0.7.1

func SelectorEqual(a, b labels.Selector) bool

func SerializeSpecYAML added in v0.8.8

func SerializeSpecYAML(decoded []K8sEntity) (string, error)

Serializes the provided K8s objects as YAML.

By convention, all K8s objects contain ObjectMetadata, Spec, and Status. This only serializes the metadata and spec, skipping the status.

func ServiceURL

func ServiceURL(service *v1.Service, ip NodeIP) (*url.URL, error)

func SetUID added in v0.10.0

func SetUID(e *K8sEntity, UID string) error

func SetUIDForTest added in v0.8.9

func SetUIDForTest(t *testing.T, e *K8sEntity, UID string)

func TiltManagedByLabel added in v0.10.7

func TiltManagedByLabel() model.LabelPair

func UniqueNames added in v0.9.3

func UniqueNames(es []K8sEntity, minComponents int) []string

Calculates names for workloads by using the shortest uniquely matching identifiers

func WaitForContainerReady

func WaitForContainerReady(ctx context.Context, client Client, pod *v1.Pod, ref container.RefSelector) (v1.ContainerStatus, error)

Types

type BufferCloser

type BufferCloser struct {
	*bytes.Buffer
}

func (BufferCloser) Close

func (b BufferCloser) Close() error

type Client

type Client interface {
	// Updates the entities, creating them if necessary.
	//
	// Tries to update them in-place if possible. But for certain resource types,
	// we might need to fallback to deleting and re-creating them.
	//
	// Returns entities in the order that they were applied (which may be different
	// than they were passed in) and with UUIDs from the Kube API
	Upsert(ctx context.Context, entities []K8sEntity) ([]K8sEntity, error)

	// Deletes all given entities.
	//
	// Currently ignores any "not found" errors, because that seems like the correct
	// behavior for our use cases.
	Delete(ctx context.Context, entities []K8sEntity) error

	GetByReference(ctx context.Context, ref v1.ObjectReference) (K8sEntity, error)

	PodByID(ctx context.Context, podID PodID, n Namespace) (*v1.Pod, error)

	// Creates a channel where all changes to the pod are brodcast.
	// Takes a pod as input, to indicate the version of the pod where we start watching.
	WatchPod(ctx context.Context, pod *v1.Pod) (watch.Interface, error)

	// Streams the container logs
	ContainerLogs(ctx context.Context, podID PodID, cName container.Name, n Namespace, startTime time.Time) (io.ReadCloser, error)

	// Opens a tunnel to the specified pod+port. Returns the tunnel's local port and a function that closes the tunnel
	CreatePortForwarder(ctx context.Context, namespace Namespace, podID PodID, optionalLocalPort, remotePort int, host string) (PortForwarder, error)

	WatchPods(ctx context.Context, lps labels.Selector) (<-chan ObjectUpdate, error)

	WatchServices(ctx context.Context, lps labels.Selector) (<-chan *v1.Service, error)

	WatchEvents(ctx context.Context) (<-chan *v1.Event, error)

	ConnectedToCluster(ctx context.Context) error

	ContainerRuntime(ctx context.Context) container.Runtime

	// Some clusters support a local image registry that we can push to.
	LocalRegistry(ctx context.Context) container.Registry

	// Some clusters support a node IP where all servers are reachable.
	NodeIP(ctx context.Context) NodeIP

	Exec(ctx context.Context, podID PodID, cName container.Name, n Namespace, cmd []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error
}

func ProvideK8sClient added in v0.7.1

func ProvideK8sClient(
	ctx context.Context,
	env Env,
	maybeRESTConfig RESTConfigOrError,
	maybeClientset ClientsetOrError,
	pfClient PortForwardClient,
	configNamespace Namespace,
	runner kubectlRunner,
	mkClient MinikubeClient,
	clientLoader clientcmd.ClientConfig) Client

type ClientsetOrError added in v0.10.8

type ClientsetOrError struct {
	Clientset *kubernetes.Clientset
	Error     error
}

func ProvideClientset added in v0.10.8

func ProvideClientset(cfg RESTConfigOrError) ClientsetOrError

type ClusterName added in v0.10.7

type ClusterName string

func ProvideClusterName added in v0.10.7

func ProvideClusterName(ctx context.Context, config *api.Config) ClusterName

type Env

type Env string
const (
	EnvUnknown       Env = "unknown"
	EnvGKE           Env = "gke"
	EnvMinikube      Env = "minikube"
	EnvDockerDesktop Env = "docker-for-desktop"
	EnvMicroK8s      Env = "microk8s"
	EnvCRC           Env = "crc"

	// Kind v0.6 substantially changed the protocol for detecting and pulling,
	// so we represent them as two separate envs.
	EnvKIND5 Env = "kind-0.5-"
	EnvKIND6 Env = "kind-0.6+"
	EnvK3D   Env = "k3d"
	EnvNone  Env = "none" // k8s not running (not neces. a problem, e.g. if using Tilt x Docker Compose)
)

func ProvideEnv added in v0.7.4

func ProvideEnv(ctx context.Context, config *api.Config) Env

func (Env) IsLocalCluster

func (e Env) IsLocalCluster() bool

func (Env) UsesLocalDockerRegistry added in v0.10.0

func (e Env) UsesLocalDockerRegistry() bool

type ExecCall added in v0.9.5

type ExecCall struct {
	PID   PodID
	CName container.Name
	Ns    Namespace
	Cmd   []string
	Stdin []byte
}

type FakeK8sClient

type FakeK8sClient struct {
	FakePortForwardClient

	Yaml string
	Lb   LoadBalancerSpec

	DeletedYaml string
	DeleteError error

	LastPodQueryNamespace Namespace
	LastPodQueryImage     reference.NamedTagged

	PodLogsByPodAndContainer map[PodAndCName]BufferCloser
	LastPodLogStartTime      time.Time
	ContainerLogsError       error

	EventsWatchErr error

	UpsertError      error
	LastUpsertResult []K8sEntity

	Runtime    container.Runtime
	Registry   container.Registry
	FakeNodeIP NodeIP

	ExecCalls  []ExecCall
	ExecErrors []error
	// contains filtered or unexported fields
}

func NewFakeK8sClient

func NewFakeK8sClient() *FakeK8sClient

func (*FakeK8sClient) ConnectedToCluster added in v0.2.0

func (c *FakeK8sClient) ConnectedToCluster(ctx context.Context) error

func (*FakeK8sClient) ContainerLogs

func (c *FakeK8sClient) ContainerLogs(ctx context.Context, pID PodID, cName container.Name, n Namespace, startTime time.Time) (io.ReadCloser, error)

func (*FakeK8sClient) ContainerRuntime added in v0.7.6

func (c *FakeK8sClient) ContainerRuntime(ctx context.Context) container.Runtime

func (*FakeK8sClient) CreatePortForwarder added in v0.10.8

func (c *FakeK8sClient) CreatePortForwarder(ctx context.Context, namespace Namespace, podID PodID, optionalLocalPort, remotePort int, host string) (PortForwarder, error)

func (*FakeK8sClient) Delete

func (c *FakeK8sClient) Delete(ctx context.Context, entities []K8sEntity) error

func (*FakeK8sClient) EmitEvent added in v0.8.9

func (c *FakeK8sClient) EmitEvent(ctx context.Context, evt *v1.Event)

func (*FakeK8sClient) EmitPod added in v0.7.1

func (c *FakeK8sClient) EmitPod(ls labels.Selector, p *v1.Pod)

func (*FakeK8sClient) EmitPodDelete added in v0.12.0

func (c *FakeK8sClient) EmitPodDelete(ls labels.Selector, p *v1.Pod)

func (*FakeK8sClient) EmitService added in v0.8.7

func (c *FakeK8sClient) EmitService(ls labels.Selector, s *v1.Service)

func (*FakeK8sClient) Exec added in v0.7.7

func (c *FakeK8sClient) Exec(ctx context.Context, podID PodID, cName container.Name, n Namespace, cmd []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error

func (*FakeK8sClient) GetByReference added in v0.10.1

func (c *FakeK8sClient) GetByReference(ctx context.Context, ref v1.ObjectReference) (K8sEntity, error)

func (*FakeK8sClient) InjectEntityByName added in v0.10.5

func (c *FakeK8sClient) InjectEntityByName(entities ...K8sEntity)

func (*FakeK8sClient) LocalRegistry added in v0.12.0

func (c *FakeK8sClient) LocalRegistry(ctx context.Context) container.Registry

func (*FakeK8sClient) NodeIP added in v0.12.6

func (c *FakeK8sClient) NodeIP(ctx context.Context) NodeIP

func (*FakeK8sClient) PodByID

func (c *FakeK8sClient) PodByID(ctx context.Context, pID PodID, n Namespace) (*v1.Pod, error)

func (*FakeK8sClient) SetLogsForPodContainer added in v0.7.7

func (c *FakeK8sClient) SetLogsForPodContainer(pID PodID, cName container.Name, logs string)

func (*FakeK8sClient) TearDown added in v0.8.9

func (c *FakeK8sClient) TearDown()

func (*FakeK8sClient) Upsert

func (c *FakeK8sClient) Upsert(ctx context.Context, entities []K8sEntity) ([]K8sEntity, error)

func (*FakeK8sClient) WatchEvents added in v0.8.4

func (c *FakeK8sClient) WatchEvents(ctx context.Context) (<-chan *v1.Event, error)

func (*FakeK8sClient) WatchPod

func (c *FakeK8sClient) WatchPod(ctx context.Context, pod *v1.Pod) (watch.Interface, error)

func (*FakeK8sClient) WatchPods

func (c *FakeK8sClient) WatchPods(ctx context.Context, ls labels.Selector) (<-chan ObjectUpdate, error)

func (*FakeK8sClient) WatchServices

func (c *FakeK8sClient) WatchServices(ctx context.Context, ls labels.Selector) (<-chan *v1.Service, error)

func (*FakeK8sClient) WatchedSelectors added in v0.7.1

func (c *FakeK8sClient) WatchedSelectors() []labels.Selector

type FakeMinikube added in v0.13.2

type FakeMinikube struct {
	FakeVersion  string
	DockerEnvMap map[string]string
}

func (FakeMinikube) DockerEnv added in v0.13.2

func (c FakeMinikube) DockerEnv(ctx context.Context) (map[string]string, error)

func (FakeMinikube) NodeIP added in v0.13.2

func (c FakeMinikube) NodeIP(ctx context.Context) (NodeIP, error)

func (FakeMinikube) Version added in v0.13.2

func (c FakeMinikube) Version(ctx context.Context) (string, error)

type FakePortForwardClient added in v0.10.8

type FakePortForwardClient struct {
	CreatePortForwardCallCount int
	LastForwardPortPodID       PodID
	LastForwardPortRemotePort  int
	LastForwardPortHost        string
	LastForwarder              FakePortForwarder
	LastForwardContext         context.Context
}

func (*FakePortForwardClient) CreatePortForwarder added in v0.10.8

func (c *FakePortForwardClient) CreatePortForwarder(ctx context.Context, namespace Namespace, podID PodID, optionalLocalPort, remotePort int, host string) (PortForwarder, error)

type FakePortForwarder added in v0.10.8

type FakePortForwarder struct {
	Done chan error
	// contains filtered or unexported fields
}

func (FakePortForwarder) ForwardPorts added in v0.10.8

func (pf FakePortForwarder) ForwardPorts() error

func (FakePortForwarder) LocalPort added in v0.10.8

func (pf FakePortForwarder) LocalPort() int

type JSONPath added in v0.7.8

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

This is just a wrapper around k8s jsonpath, mostly because k8s jsonpath doesn't produce errors containing the problematic path (and as long as we're here, deal with some of its other annoyances, like taking a "name" that doesn't do anything, and having a separate "Parse" step to make an instance actually useful, and making you use an io.Writer, and wrapping string results in quotes)

func NewJSONPath added in v0.7.8

func NewJSONPath(s string) (JSONPath, error)

func (JSONPath) Execute added in v0.7.8

func (jp JSONPath) Execute(obj interface{}) (string, error)

Gets the value at the specified path NB: currently strips away surrounding quotes, which the underlying parser includes in its return value If, at some point, we want to distinguish between, e.g., ints and strings by the presence of quotes, this will need to be revisited.

func (JSONPath) String added in v0.7.8

func (jp JSONPath) String() string

type K8sClient

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

func (K8sClient) ConnectedToCluster added in v0.2.0

func (k K8sClient) ConnectedToCluster(ctx context.Context) error

func (K8sClient) ContainerLogs

func (k K8sClient) ContainerLogs(ctx context.Context, pID PodID, cName container.Name, n Namespace, startWatchTime time.Time) (io.ReadCloser, error)

func (K8sClient) ContainerRuntime added in v0.7.6

func (c K8sClient) ContainerRuntime(ctx context.Context) container.Runtime

func (K8sClient) CreatePortForwarder added in v0.10.8

func (k K8sClient) CreatePortForwarder(ctx context.Context, namespace Namespace, podID PodID, optionalLocalPort, remotePort int, host string) (PortForwarder, error)

func (K8sClient) Delete

func (k K8sClient) Delete(ctx context.Context, entities []K8sEntity) error

Deletes all given entities.

Currently ignores any "not found" errors, because that seems like the correct behavior for our use cases.

func (K8sClient) Exec added in v0.7.7

func (k K8sClient) Exec(ctx context.Context, podID PodID, cName container.Name, n Namespace, cmd []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error

func (K8sClient) GetByReference added in v0.10.1

func (k K8sClient) GetByReference(ctx context.Context, ref v1.ObjectReference) (K8sEntity, error)

func (K8sClient) LocalRegistry added in v0.12.0

func (c K8sClient) LocalRegistry(ctx context.Context) container.Registry

func (K8sClient) NodeIP added in v0.12.6

func (c K8sClient) NodeIP(ctx context.Context) NodeIP

func (K8sClient) PodByID

func (k K8sClient) PodByID(ctx context.Context, pID PodID, n Namespace) (*v1.Pod, error)

func (K8sClient) Upsert

func (k K8sClient) Upsert(ctx context.Context, entities []K8sEntity) ([]K8sEntity, error)

func (K8sClient) WatchEvents added in v0.8.9

func (kCli K8sClient) WatchEvents(ctx context.Context) (<-chan *v1.Event, error)

func (K8sClient) WatchPod

func (k K8sClient) WatchPod(ctx context.Context, pod *v1.Pod) (watch.Interface, error)

func (K8sClient) WatchPods

func (kCli K8sClient) WatchPods(ctx context.Context, ls labels.Selector) (<-chan ObjectUpdate, error)

func (K8sClient) WatchServices

func (kCli K8sClient) WatchServices(ctx context.Context, ls labels.Selector) (<-chan *v1.Service, error)

type K8sEntity

type K8sEntity struct {
	Obj runtime.Object
}

func CopyEntities added in v0.10.15

func CopyEntities(entities []K8sEntity) []K8sEntity

func Filter added in v0.1.0

func Filter(entities []K8sEntity, test func(e K8sEntity) (bool, error)) (passing, rest []K8sEntity, err error)

Filter returns two slices of entities: those passing the given test, and the remainder of the input.

func FilterByHasPodTemplateSpec added in v0.7.5

func FilterByHasPodTemplateSpec(entities []K8sEntity) (passing, rest []K8sEntity, err error)

func FilterByImage added in v0.1.0

func FilterByImage(entities []K8sEntity, img container.RefSelector, imageJSONPaths func(K8sEntity) []JSONPath, inEnvVars bool) (passing, rest []K8sEntity, err error)

func FilterByMatchesPodTemplateSpec added in v0.7.5

func FilterByMatchesPodTemplateSpec(withPodSpec K8sEntity, entities []K8sEntity) (passing, rest []K8sEntity, err error)

func FilterByMetadataLabels added in v0.7.6

func FilterByMetadataLabels(entities []K8sEntity, labels map[string]string) (passing, rest []K8sEntity, err error)

func FilterBySelectorMatchesLabels added in v0.7.6

func FilterBySelectorMatchesLabels(entities []K8sEntity, labels map[string]string) (passing, rest []K8sEntity, err error)

func ImmutableEntities

func ImmutableEntities(entities []K8sEntity) []K8sEntity

func InjectCommandAndArgs added in v0.12.1

func InjectCommandAndArgs(entity K8sEntity, ref reference.Named, cmd model.Cmd, args model.OverrideArgs) (K8sEntity, error)

func InjectImageDigest

func InjectImageDigest(entity K8sEntity, selector container.RefSelector, injectRef reference.Named, matchInEnvVars bool, policy v1.PullPolicy) (K8sEntity, bool, error)

Iterate through the fields of a k8s entity and replace a image name with its digest.

policy: The pull policy to set on the replaced image.

When working with a local k8s cluster, we want to set this to Never,
to ensure that k8s fails hard if the image is missing from docker.

Returns: the new entity, whether the image was replaced, and an error.

func InjectImagePullPolicy

func InjectImagePullPolicy(entity K8sEntity, policy v1.PullPolicy) (K8sEntity, error)

Iterate through the fields of a k8s entity and replace the image pull policy on all images.

func InjectLabels

func InjectLabels(entity K8sEntity, labels []model.LabelPair) (K8sEntity, error)

func InjectParallelPodManagementPolicy added in v0.10.0

func InjectParallelPodManagementPolicy(entity K8sEntity) K8sEntity

By default, StatefulSets use OrderedPodManagement.

This is a bad policy for development. If the pod goes into a crash loop, the StatefulSet operator will get wedged and require manual intervention. See: https://github.com/windmilleng/tilt/issues/1962

Tilt should change all statefulsets to use a parallel policy.

func InjectPodTemplateSpecHashes added in v0.10.16

func InjectPodTemplateSpecHashes(entity K8sEntity) (K8sEntity, error)

Iterate through the fields of a k8s entity and add the pod template spec hash on all pod template specs

func MutableAndImmutableEntities added in v0.10.15

func MutableAndImmutableEntities(entities entityList) (mutable, immutable []K8sEntity)

MutableAndImmutableEntities returns two lists of k8s entities: mutable ones (that can simply be `kubectl apply`'d), and immutable ones (such as jobs and pods, which will need to be `--force`'d). (We assume input entities are already sorted in a safe order to apply -- see kustomize/ordering.go.)

func MutableEntities

func MutableEntities(entities []K8sEntity) []K8sEntity

func NewK8sEntity added in v0.10.4

func NewK8sEntity(obj runtime.Object) K8sEntity

func NewNamespaceEntity added in v0.10.15

func NewNamespaceEntity(name string) K8sEntity

func OverwriteLabels added in v0.7.5

func OverwriteLabels(entity K8sEntity, labels []model.LabelPair) (K8sEntity, error)

func ParseYAMLFromString

func ParseYAMLFromString(yaml string) ([]K8sEntity, error)

func SortedEntities added in v0.10.15

func SortedEntities(entities []K8sEntity) []K8sEntity

func (K8sEntity) DeepCopy

func (e K8sEntity) DeepCopy() K8sEntity

func (K8sEntity) FindImages added in v0.4.1

func (e K8sEntity) FindImages(imageJSONPaths []JSONPath, envVarImages []container.RefSelector) ([]reference.Named, error)

func (K8sEntity) GVK added in v0.10.4

func (K8sEntity) HasImage added in v0.1.0

func (e K8sEntity) HasImage(image container.RefSelector, imageJSONPaths []JSONPath, inEnvVars bool) (bool, error)

HasImage indicates whether the given entity is tagged with the given image.

func (K8sEntity) HasKind added in v0.7.6

func (e K8sEntity) HasKind(kind string) bool

func (K8sEntity) HasName added in v0.7.6

func (e K8sEntity) HasName(name string) bool

func (K8sEntity) HasNamespace added in v0.7.6

func (e K8sEntity) HasNamespace(ns string) bool

func (K8sEntity) ImmutableOnceCreated

func (e K8sEntity) ImmutableOnceCreated() bool

Most entities can be updated once running, but a few cannot.

func (K8sEntity) Labels added in v0.8.9

func (e K8sEntity) Labels() map[string]string

func (K8sEntity) MatchesMetadataLabels added in v0.7.6

func (e K8sEntity) MatchesMetadataLabels(labels map[string]string) (bool, error)

MatchesMetadataLabels indicates whether the given label(s) are a subset of metadata labels for the given entity.

func (K8sEntity) Name

func (e K8sEntity) Name() string

func (K8sEntity) Namespace

func (e K8sEntity) Namespace() Namespace

func (K8sEntity) SelectorMatchesLabels added in v0.7.6

func (e K8sEntity) SelectorMatchesLabels(labels map[string]string) bool

SelectorMatchesLabels indicates whether the pod selector of the given entity matches the given label(s). Currently only supports Services, but may be expanded to support other types that match pods via selectors.

func (K8sEntity) ToObjectReference added in v0.10.5

func (e K8sEntity) ToObjectReference() v1.ObjectReference

func (K8sEntity) UID added in v0.8.9

func (e K8sEntity) UID() types.UID

func (K8sEntity) WithNamespace added in v0.10.8

func (e K8sEntity) WithNamespace(ns string) K8sEntity

type KubeContext added in v0.6.0

type KubeContext string

func ProvideKubeContext added in v0.7.4

func ProvideKubeContext(config *api.Config) (KubeContext, error)

type KubectlLogLevel added in v0.8.7

type KubectlLogLevel = int

type LoadBalancer

type LoadBalancer struct {
	Spec LoadBalancerSpec
	URL  *url.URL
}

type LoadBalancerSpec

type LoadBalancerSpec struct {
	Name      string
	Namespace Namespace
	Ports     []int32
}

func ToLoadBalancerSpec

func ToLoadBalancerSpec(entity K8sEntity) (LoadBalancerSpec, bool)

Try to convert the current entity to a LoadBalancerSpec service

func ToLoadBalancerSpecs

func ToLoadBalancerSpecs(entities []K8sEntity) []LoadBalancerSpec

type MinikubeClient added in v0.12.9

type MinikubeClient interface {
	Version(ctx context.Context) (string, error)
	DockerEnv(ctx context.Context) (map[string]string, error)
	NodeIP(ctx context.Context) (NodeIP, error)
}

func ProvideMinikubeClient added in v0.12.9

func ProvideMinikubeClient(context KubeContext) MinikubeClient

type NaiveRuntimeSource added in v0.8.10

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

func NewNaiveRuntimeSource added in v0.8.10

func NewNaiveRuntimeSource(r container.Runtime) NaiveRuntimeSource

func (NaiveRuntimeSource) Runtime added in v0.8.10

type Namespace

type Namespace string

func NamespaceFromPod

func NamespaceFromPod(pod *v1.Pod) Namespace

func ProvideConfigNamespace added in v0.7.3

func ProvideConfigNamespace(clientLoader clientcmd.ClientConfig) Namespace

The namespace in the kubeconfig. Used as a default namespace in some (but not all) client commands. https://godoc.org/k8s.io/client-go/tools/clientcmd/api/v1#Context

func (Namespace) Empty added in v0.8.5

func (n Namespace) Empty() bool

func (Namespace) String

func (n Namespace) String() string

type NodeID

type NodeID string

func NodeIDFromPod

func NodeIDFromPod(pod *v1.Pod) NodeID

func (NodeID) String

func (nID NodeID) String() string

type NodeIP added in v0.1.0

type NodeIP string

Some K8s environments expose a single IP for the whole cluster.

type ObjectRefTree added in v0.10.5

type ObjectRefTree struct {
	Ref    v1.ObjectReference
	Owners []ObjectRefTree
}

The ObjectRefTree only contains immutable properties of a Kubernetes object: the name, namespace, and UID

func (ObjectRefTree) String added in v0.10.5

func (t ObjectRefTree) String() string

func (ObjectRefTree) UIDs added in v0.10.5

func (t ObjectRefTree) UIDs() []types.UID

type ObjectUpdate added in v0.12.0

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

A wrapper object around SharedInformer objects, to make them a bit easier to use correctly.

func (ObjectUpdate) AsDeletedKey added in v0.12.0

func (r ObjectUpdate) AsDeletedKey() (Namespace, string, bool)

Returns (namespace, name, isDelete).

The informer's OnDelete handler sometimes gives us a structured object, and sometimes returns a DeletedFinalStateUnknown object. To make this easier to handle correctly, we never allow access to the OnDelete object. Instead, we force the caller to use AsDeletedKey() to get the identifier of the object.

For more info, see: https://godoc.org/k8s.io/client-go/tools/cache#ResourceEventHandler

func (ObjectUpdate) AsPod added in v0.12.0

func (r ObjectUpdate) AsPod() (*v1.Pod, bool)

Returns a Pod if this is a pod Add or a pod Update.

type OwnerFetcher added in v0.10.5

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

func ProvideOwnerFetcher added in v0.10.5

func ProvideOwnerFetcher(kCli Client) OwnerFetcher

func (OwnerFetcher) OwnerTreeOf added in v0.10.5

func (v OwnerFetcher) OwnerTreeOf(ctx context.Context, entity K8sEntity) (result ObjectRefTree, err error)

func (OwnerFetcher) OwnerTreeOfRef added in v0.10.7

func (v OwnerFetcher) OwnerTreeOfRef(ctx context.Context, ref v1.ObjectReference) (result ObjectRefTree, err error)

type PodAndCName added in v0.7.7

type PodAndCName struct {
	PID   PodID
	CName container.Name
}

For keying PodLogsByPodAndContainer

type PodID

type PodID string

func PodIDFromPod

func PodIDFromPod(pod *v1.Pod) PodID

func (PodID) Empty

func (pID PodID) Empty() bool

func (PodID) String

func (pID PodID) String() string

type PodTemplateSpecHash added in v0.10.16

type PodTemplateSpecHash string

func HashPodTemplateSpec added in v0.10.16

func HashPodTemplateSpec(spec *v1.PodTemplateSpec) (PodTemplateSpecHash, error)

func ReadPodTemplateSpecHashes added in v0.10.19

func ReadPodTemplateSpecHashes(entity K8sEntity) ([]PodTemplateSpecHash, error)

ReadPodTemplateSpecHashes pulls the PodTemplateSpecHash that Tilt injected into this entity's metadata during deploy (if any)

type PortForwardClient added in v0.10.8

type PortForwardClient interface {
	// Creates a new port-forwarder that's bound to the given context's lifecycle.
	// When the context is canceled, the port-forwarder will close.
	CreatePortForwarder(ctx context.Context, namespace Namespace, podID PodID, localPort int, remotePort int, host string) (PortForwarder, error)
}

func ProvidePortForwardClient added in v0.10.8

func ProvidePortForwardClient(
	maybeRESTConfig RESTConfigOrError,
	maybeClientset ClientsetOrError) PortForwardClient

type PortForwarder

type PortForwarder interface {
	// The local port we're listening on.
	LocalPort() int

	// Listens on the configured port and forward all traffic to the container.
	// Returns when the port-forwarder sees an unrecoverable error or
	// when the context passed at creation is canceled.
	ForwardPorts() error
}

type RESTConfigOrError added in v0.10.8

type RESTConfigOrError struct {
	Config *rest.Config
	Error  error
}

func ProvideRESTConfig

func ProvideRESTConfig(clientLoader clientcmd.ClientConfig) RESTConfigOrError

type RuntimeSource added in v0.8.10

type RuntimeSource interface {
	Runtime(ctx context.Context) container.Runtime
}

type ServiceName

type ServiceName string

type TypeIndex added in v0.8.8

type TypeIndex map[reflect2.Type]bool

func (TypeIndex) Contains added in v0.8.8

func (idx TypeIndex) Contains(typ reflect2.Type) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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