Documentation
¶
Overview ¶
Package kube wires up the Kubernetes client used by all adapters.
The client is a controller-runtime client with the TinySystems CRD types registered in its scheme, so it can directly Get/List/Create/Update/Patch TinyNode, TinyFlow, TinyProject, TinyModule, TinyScenario, and TinySignal resources.
Package kube resolves a *rest.Config from the user's kubeconfig the same way kubectl does — honouring KUBECONFIG, ~/.kube/config, and an explicit --context override. Everything that touches the cluster (helm installs, the NATS token read) goes through here so `tiny` acts on exactly the cluster the user confirmed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForwardPodPort ¶
func ForwardPodPort(ctx context.Context, cfg *rest.Config, namespace, podName string, localPort, podPort int) (stop func(), done <-chan struct{}, err error)
ForwardPodPort opens an SPDY port-forward from 127.0.0.1:localPort on this machine to podPort inside the named pod — the same mechanism as `kubectl port-forward pod/…`. It blocks until the tunnel is ready, then returns a stop func and a done channel. Reaches loopback-bound ports in the pod too (the forward tunnels into the pod's network namespace).
done closes when the forward exits — either because stop was called or, crucially for remote clusters, because the SPDY stream dropped (idle timeout, API-server rollout, network blip). Callers watch done to know a forward went dead and needs re-establishing. stop is safe to call more than once.
func Ping ¶
Ping verifies the cluster is actually reachable and the credentials work — a real round-trip to the API server (which also exercises any exec credential plugin, e.g. gcloud). Returns the underlying error so callers can stop with a clear message instead of serving against a dead connection.
func RestConfig ¶
RestConfig builds a client config from the local kubeconfig. An empty contextName means "use the kubeconfig's current-context" — the same default `tiny status` and the confirmation prompt already report.
No client-side Timeout is set on purpose: helm waits on releases with its own per-operation timeout, and a short rest timeout here would sever those long installs mid-flight.
Types ¶
type Client ¶
Client bundles everything an adapter needs to talk to a cluster: a typed controller-runtime client, the REST config (for port-forwarding), and the target namespace.
func NewClient ¶
NewClient loads a kubeconfig, registers the TinySystems scheme, and returns a ready-to-use Client.
func NewClientFromConfig ¶
NewClientFromConfig builds a Client from an already-resolved rest.Config — for callers (like the FlowService) that resolved the config themselves and just need the typed, scheme-aware client over it.
type Options ¶
type Options struct {
// KubeconfigPath is an explicit path to a kubeconfig file. Empty means
// fall back to $KUBECONFIG and then ~/.kube/config.
KubeconfigPath string
// Context overrides the current-context in the kubeconfig. Empty means
// use whatever is set as current-context in the file.
Context string
// Namespace overrides the kubeconfig context's default namespace.
// Empty means use the context's namespace, or "default" if none is set.
Namespace string
}
Options controls how the client is constructed.
type PortForwarder ¶
type PortForwarder struct {
// contains filtered or unexported fields
}
PortForwarder implements sdk utils.ClientInterface by using the SDK's kubectl port-forward machinery to reach in-cluster services (e.g. the otel-collector that holds trace data).
It lazy-creates one resource.PortForwarder per namespace, keeps it open for the lifetime of the process, and re-uses forwarded ports across calls. Close() stops all active forwards.
func NewPortForwarder ¶
func NewPortForwarder(kube *Client) *PortForwarder
NewPortForwarder creates a PortForwarder tied to the given kube client.
func (*PortForwarder) Close ¶
func (p *PortForwarder) Close()
Close stops all active port-forwards and releases resources.
func (*PortForwarder) GetForwardedAddress ¶
func (p *PortForwarder) GetForwardedAddress(ctx context.Context, req utils.PortForwardRequest, alias string) (string, error)
GetForwardedAddress implements utils.ClientInterface. It returns a localhost:port address that forwards to the requested service.