kubernetes

package
v0.0.0-...-938e221 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProvider

func NewProvider(ic provider.InitConfig) (provider.Provider, error)

NewProvider returns a Provider that runs pods by submitting them to a remote API server.

func ValidateConfigFile

func ValidateConfigFile(cfg ConfigFile) error

ValidateConfigFile returns an error if the supplied config is invalid.

Types

type APIDependencyFetcher

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

An APIDependencyFetcher fetches the dependencies of a particular pod by reading them from the API server.

func NewAPIDependencyFetcher

func NewAPIDependencyFetcher(c client.Reader, o ...APIDependencyFetcherOption) *APIDependencyFetcher

NewAPIDependencyFetcher returns a DependencyFetcher that fetches the dependencies of a particular pod by reading them from the API server.

func (*APIDependencyFetcher) Fetch

func (f *APIDependencyFetcher) Fetch(ctx context.Context, pod *corev1.Pod) ([]runtime.Object, error)

Fetch the dependencies of the supplied pod by reading them from the API server.

type APIDependencyFetcherOption

type APIDependencyFetcherOption func(*APIDependencyFetcher)

An APIDependencyFetcherOption configures the supplied APIDependencyFetcher.

func WithDependencyFinder

func WithDependencyFinder(df DependencyFinder) APIDependencyFetcherOption

WithDependencyFinder configures how an APIDependencyFetcher finds the dependencies it should fetch.

type Client

A Client for a Kubernetes cluster.

func NewClient

func NewClient(cc ClientConfig) (Client, error)

NewClient returns a client for a Kubernetes cluster.

type ClientConfig

type ClientConfig struct {
	// KubeConfigPath is an optional path to a kubeconfig file that will be used
	// to configure a client. Clients attempt in-cluster config if no kubeconfig
	// is provided.
	KubeConfigPath string `toml:"kubeconfig_path"`

	// ResyncInterval specifies how frequently the client's cache resync its
	// contents with the API server. The cache watches the API server; the
	// resync guards against missed updates.
	ResyncInterval time.Duration `toml:"resync_interval"`
}

A ClientConfig is used to configure a Kubernetes client.

type Config

type Config struct {
	provider.InitConfig
	ConfigFile
}

A Config contains the configuration that a provider needs - both that provided by the InitConfig and that read from the config file therein.

type ConfigFile

type ConfigFile struct {
	// Local client configuration - i.e. how AK should connect to the API
	// server to which it registers as a node.
	Local ClientConfig `toml:"local"`

	// Remote client configuration - i.e. the API server in which AK runs pods.
	Remote ClientConfig `toml:"remote"`

	// Pods configuration - influences how pods are prepared for submission to
	// the remote API server.
	Pods PodsConfig `toml:"pods"`

	// Node configuration - configures how the Node is presented to the local
	// API server.
	Node NodeConfig `toml:"node"`
}

A ConfigFile is used to configure AK.

func ParseConfigFile

func ParseConfigFile(path string) (ConfigFile, error)

ParseConfigFile parses the TOML config file at the supplied path.

type Dependency

type Dependency struct {
	Kind     DependencyKind
	Name     string
	Optional bool
}

A Dependency of a pod.

func FindContainerDependencies

func FindContainerDependencies(c corev1.Container) []Dependency

FindContainerDependencies returns all of the dependencies the supplied container depends on to work as expected.

func FindPodDependencies

func FindPodDependencies(pod *corev1.Pod) []Dependency

FindPodDependencies returns all of the resources the supplied pod depends on to work as expected.

func FindVolumeDependencies

func FindVolumeDependencies(v corev1.Volume) []Dependency

FindVolumeDependencies returns all of the dependencies the supplied volume depends on to work as expected.

type DependencyFetcher

type DependencyFetcher interface {
	// Fetch the dependencies of the supplied pod.
	Fetch(ctx context.Context, pod *corev1.Pod) ([]runtime.Object, error)
}

A DependencyFetcher fetches the dependencies of a particular pod.

type DependencyFinder

type DependencyFinder interface {
	FindDependencies(*corev1.Pod) []Dependency
}

A DependencyFinder returns all of the resources the supplied pod depends on to work as expected.

type DependencyFinderFn

type DependencyFinderFn func(*corev1.Pod) []Dependency

A DependencyFinderFn returns all of the resources the supplied pod depends on to work as expected.

func (DependencyFinderFn) FindDependencies

func (fn DependencyFinderFn) FindDependencies(pod *corev1.Pod) []Dependency

FindDependencies returns all of the resources the supplied pod depends on to work as expected.

type DependencyKind

type DependencyKind int

A DependencyKind is a kind of resource a pod might depend on.

const (
	DependencyKindConfigMap DependencyKind = iota
	DependencyKindSecret
	DependencyKindServiceAccountTokenSecret
)

The things a pod might depend on.

type NodeConfig

type NodeConfig struct {
	// Resources the Node should indicate it has.
	Resources NodeResourcesConfig `toml:"resources"`
}

The NodeConfig is used to configure how the Node presented to the local API server.

type NodeResourcesConfig

type NodeResourcesConfig struct {
	// Allocatable resources the Node should indicate it has.
	Allocatable map[string]string `toml:"allocatable"`
}

The NodeResourcesConfig is used to configure the resources the Node will present to the local API server.

type PodsConfig

type PodsConfig struct {
	// Env vars that should be added to (or overridden in) all pod containers.
	Env []corev1.EnvVar `toml:"env"`
}

The PodsConfig is used to influence how pods are prepared for submission to the remote API server.

type Provider

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

A Provider runs pods by submitting them to a remote API server.

func (*Provider) ApplyPodDependencies

func (p *Provider) ApplyPodDependencies(ctx context.Context, lcl *corev1.Pod) error

ApplyPodDependencies applies (i.e. creates or overwrites) the resources the supplied pod depends on in order to work as expected.

func (*Provider) ConfigureNode

func (p *Provider) ConfigureNode(_ context.Context, n *corev1.Node)

ConfigureNode configures the AK Node in the local API server.

func (*Provider) CreatePod

func (p *Provider) CreatePod(ctx context.Context, lcl *corev1.Pod) error

CreatePod prepares the supplied pod and creates it in the remote API server.

func (*Provider) DeletePod

func (p *Provider) DeletePod(ctx context.Context, lcl *corev1.Pod) error

DeletePod from the remote API server.

func (*Provider) GetContainerLogs

func (p *Provider) GetContainerLogs(ctx context.Context, namespace, podName, containerName string, opts api.ContainerLogOpts) (io.ReadCloser, error)

GetContainerLogs retrieves the logs of a container by name from the remote API server

func (*Provider) GetPod

func (p *Provider) GetPod(ctx context.Context, namespace, name string) (*corev1.Pod, error)

GetPod retrieves a pod by name from the remote API server.

func (*Provider) GetPodStatus

func (p *Provider) GetPodStatus(ctx context.Context, namespace, name string) (*corev1.PodStatus, error)

GetPodStatus retrieves the status of a pod by name from the remote API server.

func (*Provider) GetPods

func (p *Provider) GetPods(ctx context.Context) ([]*corev1.Pod, error)

GetPods retrieves a list of all pods running on the remote API server.

func (*Provider) NotifyPods

func (p *Provider) NotifyPods(ctx context.Context, changed func(*corev1.Pod))

NotifyPods calls the supplied changed function when a pod in the remote API server may have changed.

func (*Provider) RunInContainer

func (p *Provider) RunInContainer(ctx context.Context, namespace, podName, containerName string, cmd []string, attach api.AttachIO) error

RunInContainer executes a command in a container in the pod on the remote API server, copying data between in/out/err and the container's stdin/stdout/stderr.

func (*Provider) UpdatePod

func (p *Provider) UpdatePod(ctx context.Context, lcl *corev1.Pod) error

UpdatePod prepares the supplied pod and updates it in the remote API server.

Jump to

Keyboard shortcuts

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