kubernetes

package
v0.0.227 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: Apache-2.0 Imports: 90 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiscoveryStateKey  = "kubernetes.discovery"
	RestmapperStateKey = "kubernetes.restmapper"
)
View Source
const PortForwardProtocolV1Name = "portforward.k8s.io"

Variables

View Source
var (
	UseNodePlatformsForProduction = true
	ProductionPlatforms           = []string{"linux/amd64", "linux/arm64"}
)
View Source
var DeployAsPodsInTests = true
View Source
var (
	ObserveInitContainerLogs = false
)

Functions

func ClusterIngress added in v0.0.151

func ClusterIngress(cluster *Cluster) (kubedef.IngressClass, error)

func DeleteAllRecursively

func DeleteAllRecursively(ctx context.Context, cli *kubernetes.Clientset, wait bool, progress io.Writer, namespaces ...string) (bool, error)

func IngressOwnedBy added in v0.0.124

func IngressOwnedBy(allFragments []*fnschema.IngressFragment, srv fnschema.PackageName) []*fnschema.IngressFragment

func ModuleNamespace

func ModuleNamespace(ws *schema.Workspace, env *schema.Environment) string

We use namespaces to isolate deployments per workspace and environment. Using the path base plus a digest provides short, memorable names and avoids collision. TODO add knob to allow namespace overwrites if the need arises.

func PrepareProvisionWith

func PrepareProvisionWith(env *schema.Environment, ns string, systemInfo *kubedef.SystemInfo) (*rtypes.RuntimeProvisionProps, error)

func Register

func Register()

func RegisterOverrideClass

func RegisterOverrideClass(name string, p ProvideOverrideFunc)

func WatchDeployable added in v0.0.164

func WatchDeployable[V any](ctx context.Context, actionName string, cli *k8s.Clientset, namespace string, object runtime.Deployable, callback func(corev1.Pod) (V, bool, error)) (V, error)

Types

type BoundNamespace added in v0.0.137

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

type Cluster

type Cluster struct {
	Prepared      client.Prepared
	Configuration cfg.Configuration

	FetchSystemInfo FetchSystemInfoFunc

	ClusterAttachedState
	// contains filtered or unexported fields
}

func ConnectToCluster

func ConnectToCluster(ctx context.Context, config cfg.Configuration) (*Cluster, error)

func NewCluster added in v0.0.104

func NewCluster(cli *client.Prepared, config cfg.Configuration, opts NewClusterOpts) (*Cluster, error)

func (*Cluster) AttachTerminal

func (r *Cluster) AttachTerminal(ctx context.Context, reference *runtimepb.ContainerReference, rio runtime.TerminalIO) error

func (*Cluster) Bind

func (*Cluster) Class

func (u *Cluster) Class() runtime.Class

func (*Cluster) DeleteAllRecursively

func (r *Cluster) DeleteAllRecursively(ctx context.Context, wait bool, progress io.Writer) (bool, error)

func (*Cluster) EnsureKeyedState added in v0.0.143

func (r *Cluster) EnsureKeyedState(ctx context.Context, key, secondary string) (any, error)

func (*Cluster) EnsureState

func (r *Cluster) EnsureState(ctx context.Context, key string) (any, error)

func (*Cluster) FetchDiagnostics

func (r *Cluster) FetchDiagnostics(ctx context.Context, reference *runtimepb.ContainerReference) (*runtimepb.Diagnostics, error)

func (*Cluster) FetchLogsTo

func (r *Cluster) FetchLogsTo(ctx context.Context, reference *runtimepb.ContainerReference, opts runtime.FetchLogsOpts, callback func(runtime.ContainerLogLine)) error

func (*Cluster) ForwardIngress

func (r *Cluster) ForwardIngress(ctx context.Context, localAddrs []string, localPort int, notify runtime.PortForwardedFunc) (io.Closer, error)

func (*Cluster) KubernetesCluster added in v0.0.96

func (u *Cluster) KubernetesCluster() *Cluster

func (*Cluster) PreparedClient

func (u *Cluster) PreparedClient() client.Prepared

func (*Cluster) RESTConfig

func (u *Cluster) RESTConfig() *rest.Config

func (*Cluster) RawDialServer

func (u *Cluster) RawDialServer(ctx context.Context, ns string, podLabels map[string]string, port *schema.Endpoint_Port) (net.Conn, error)

func (*Cluster) RawForwardPort

func (u *Cluster) RawForwardPort(ctx context.Context, desc, ns string, podLabels map[string]string, containerPort int, localAddrs []string, callback runtime.SinglePortForwardedFunc) (io.Closer, error)

func (*Cluster) RunAttachedOpts

func (r *Cluster) RunAttachedOpts(ctx context.Context, ns, name string, runOpts runtime.ContainerRunOpts, io runtime.TerminalIO, onStart func()) error

func (*Cluster) StartAndBlockPortFwd

func (r *Cluster) StartAndBlockPortFwd(ctx context.Context, args StartAndBlockPortFwdArgs) error

func (*Cluster) SystemInfo

func (r *Cluster) SystemInfo(ctx context.Context) (*kubedef.SystemInfo, error)

func (*Cluster) UnmatchedTargetPlatforms

func (r *Cluster) UnmatchedTargetPlatforms(ctx context.Context) ([]specs.Platform, error)

type ClusterAttachedState

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

func (*ClusterAttachedState) EnsureState

func (r *ClusterAttachedState) EnsureState(ctx context.Context, stateKey string, config cfg.Configuration, cluster runtime.Cluster, key *string) (any, error)

type ClusterNamespace

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

func ConnectToNamespace

func ConnectToNamespace(ctx context.Context, env cfg.Context) (*ClusterNamespace, error)

func NewClusterNamespace added in v0.0.103

func NewClusterNamespace(env cfg.Context, parent runtime.Cluster, u *Cluster) *ClusterNamespace

func (*ClusterNamespace) Cluster

func (cn *ClusterNamespace) Cluster() runtime.Cluster

func (*ClusterNamespace) DeleteDeployable

func (r *ClusterNamespace) DeleteDeployable(ctx context.Context, deployable runtime.Deployable) error

func (*ClusterNamespace) DeleteRecursively

func (r *ClusterNamespace) DeleteRecursively(ctx context.Context, wait bool) (bool, error)

func (*ClusterNamespace) DeployedConfigImageID

func (r *ClusterNamespace) DeployedConfigImageID(ctx context.Context, deployable runtime.Deployable) (oci.ImageID, error)

func (*ClusterNamespace) DialServer

func (r *ClusterNamespace) DialServer(ctx context.Context, server runtime.Deployable, port *schema.Endpoint_Port) (net.Conn, error)

func (*ClusterNamespace) FetchEnvironmentDiagnostics

func (r *ClusterNamespace) FetchEnvironmentDiagnostics(ctx context.Context) (*storage.EnvironmentDiagnostics, error)

func (*ClusterNamespace) ForwardPort

func (r *ClusterNamespace) ForwardPort(ctx context.Context, server runtime.Deployable, containerPort int32, localAddrs []string, callback runtime.SinglePortForwardedFunc) (io.Closer, error)

func (*ClusterNamespace) KubeConfig

func (r *ClusterNamespace) KubeConfig() kubedef.KubeConfig

func (*ClusterNamespace) Observe

func (r *ClusterNamespace) Observe(ctx context.Context, srv runtime.Deployable, opts runtime.ObserveOpts, onInstance func(runtime.ObserveEvent) (bool, error)) error

Return true on the callback to signal you're done observing.

func (*ClusterNamespace) ResolveContainers

func (r *ClusterNamespace) ResolveContainers(ctx context.Context, object runtime.Deployable) ([]*runtimepb.ContainerReference, error)

func (*ClusterNamespace) StartTerminal

func (r *ClusterNamespace) StartTerminal(ctx context.Context, server runtime.Deployable, rio runtime.TerminalIO, command string, rest ...string) error

func (*ClusterNamespace) WaitForTermination

func (r *ClusterNamespace) WaitForTermination(ctx context.Context, object runtime.Deployable) ([]runtime.ContainerStatus, error)

func (*ClusterNamespace) WaitUntilReady added in v0.0.75

func (r *ClusterNamespace) WaitUntilReady(ctx context.Context, srv runtime.Deployable) error

type FetchSystemInfoFunc added in v0.0.104

type FetchSystemInfoFunc func(context.Context) (*kubedef.SystemInfo, error)

type NewClusterOpts added in v0.0.124

type NewClusterOpts struct {
	FetchSystemInfo FetchSystemInfoFunc
}

type Planner

type Planner struct {
	Configuration cfg.Configuration
	// contains filtered or unexported fields
}

func NewPlanner

func NewPlanner(ctx context.Context, env cfg.Context, fetch FetchSystemInfoFunc, ingressClass kubedef.IngressClass) (Planner, error)

func NewPlannerWithRegistry added in v0.0.94

func NewPlannerWithRegistry(env cfg.Context, registry registry.Manager, fetch FetchSystemInfoFunc, ingressClass kubedef.IngressClass) Planner

func (Planner) ClusterNamespaceFor added in v0.0.104

func (r Planner) ClusterNamespaceFor(parent runtime.Cluster, underlying *Cluster) *ClusterNamespace

func (Planner) ComputeBaseNaming

func (r Planner) ComputeBaseNaming(*fnschema.Naming) (*fnschema.ComputedNaming, error)

func (Planner) EnsureClusterNamespace added in v0.0.104

func (r Planner) EnsureClusterNamespace(ctx context.Context) (runtime.ClusterNamespace, error)

func (Planner) Ingress added in v0.0.113

func (r Planner) Ingress() runtime.IngressClass

func (Planner) KubernetesNamespace

func (r Planner) KubernetesNamespace() string

func (Planner) MakeServiceName added in v0.0.176

func (r Planner) MakeServiceName(name string) (string, string)

func (Planner) PlanDeployment

func (Planner) PlanIngress

func (r Planner) PlanIngress(ctx context.Context, stack *fnschema.Stack, allFragments []*fnschema.IngressFragment) (*runtime.DeploymentPlan, error)

func (Planner) PrepareProvision

func (r Planner) PrepareProvision(ctx context.Context) (*rtypes.RuntimeProvisionProps, error)

func (Planner) Registry added in v0.0.94

func (r Planner) Registry() registry.Manager

func (Planner) TargetPlatforms

func (r Planner) TargetPlatforms(ctx context.Context) ([]specs.Platform, error)

type PodResolver

type PodResolver interface {
	Resolve(context.Context) (v1.Pod, error)
}

type ProvideOverrideFunc

type ProvideOverrideFunc func(context.Context, cfg.Configuration) (runtime.Class, error)

type ServiceReadiness added in v0.0.157

type ServiceReadiness struct {
	Ready   bool
	Message string
}

func AreServicesReady added in v0.0.157

func AreServicesReady(ctx context.Context, cli *kubernetes.Clientset, namespace string, srv runtime.Deployable) (ServiceReadiness, error)

type StartAndBlockPortFwdArgs

type StartAndBlockPortFwdArgs struct {
	Namespace     string
	Identifier    string
	LocalAddrs    []string
	LocalPort     int // 0 to be dynamically allocated.
	ContainerPort int
	PodResolver   PodResolver
	ReportPorts   func(runtime.ForwardedPort)
}

type UnwrapCluster added in v0.0.96

type UnwrapCluster interface {
	KubernetesCluster() *Cluster
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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