Documentation
¶
Overview ¶
Package kubernetes implements the Kubernetes protocol plugin: a Lens-grade operations cockpit rendered entirely from the manifest projection over the generic renderer. It reaches the API server with client-go either directly (kubeconfig) or through the L7 (http_proxy) agent, which injects the cluster's own ServiceAccount credentials.
Index ¶
- func ApplyYAML(rc *plugin.RequestContext) (any, error)
- func ClusterList(rc *plugin.RequestContext) (any, error)
- func ClusterMetrics(rc *plugin.RequestContext, client plugin.ClientStream) error
- func ClusterShellStream(rc *plugin.RequestContext, client plugin.ClientStream) error
- func ColumnsForKind(rc *plugin.RequestContext) (any, error)
- func Connect(ctx context.Context, cfg plugin.ConnectConfig) (plugin.Session, error)
- func CordonNode(rc *plugin.RequestContext) (any, error)
- func DeleteResource(rc *plugin.RequestContext) (any, error)
- func DrainNode(rc *plugin.RequestContext) (any, error)
- func ExecStream(rc *plugin.RequestContext, client plugin.ClientStream) error
- func GetResource(rc *plugin.RequestContext) (any, error)
- func GetYAML(rc *plugin.RequestContext) (any, error)
- func HelmRelease(rc *plugin.RequestContext) (any, error)
- func HelmReleases(rc *plugin.RequestContext) (any, error)
- func ListResource(rc *plugin.RequestContext) (any, error)
- func LogsStream(rc *plugin.RequestContext, client plugin.ClientStream) error
- func NodeMetrics(rc *plugin.RequestContext, client plugin.ClientStream) error
- func NodePods(rc *plugin.RequestContext) (any, error)
- func PodProxyURL(rc *plugin.RequestContext) (any, error)
- func ResourceEvents(rc *plugin.RequestContext) (any, error)
- func RestartResource(rc *plugin.RequestContext) (any, error)
- func RolloutUndo(rc *plugin.RequestContext) (any, error)
- func Routes() []plugin.Route
- func ScaleResource(rc *plugin.RequestContext) (any, error)
- func ServiceProxyURL(rc *plugin.RequestContext) (any, error)
- func TemplateYAML(rc *plugin.RequestContext) (any, error)
- func TreeCRDGroup(rc *plugin.RequestContext) (any, error)
- func TreeCRDs(rc *plugin.RequestContext) (any, error)
- func TreeCategory(rc *plugin.RequestContext) (any, error)
- func TreeGatewayAPI(rc *plugin.RequestContext) (any, error)
- func TreeHelm(_ *plugin.RequestContext) (any, error)
- func TreeSubgroup(rc *plugin.RequestContext) (any, error)
- func TriggerCronJob(rc *plugin.RequestContext) (any, error)
- func UncordonNode(rc *plugin.RequestContext) (any, error)
- func WatchResource(rc *plugin.RequestContext, client plugin.ClientStream) error
- func WorkloadPods(rc *plugin.RequestContext) (any, error)
- type ApplyRequest
- type DrainRequest
- type Plugin
- type Row
- type ScaleRequest
- type Session
- func (s *Session) Clientset() *kubeclient.Clientset
- func (s *Session) Close() error
- func (s *Session) DefaultNamespace() string
- func (s *Session) Discovery() discovery.CachedDiscoveryInterface
- func (s *Session) Dynamic() dynamic.Interface
- func (s *Session) HealthCheck(ctx context.Context) error
- func (s *Session) Mapper() meta.RESTMapper
- func (s *Session) Metrics() *metricsclient.Clientset
- func (s *Session) OpenChannel(_ context.Context, _ plugin.ChannelRequest) (plugin.Channel, error)
- func (s *Session) ServeHTTPProxy(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyYAML ¶
func ApplyYAML(rc *plugin.RequestContext) (any, error)
ApplyYAML server-side-applies one or more manifests (a multi-document YAML stream, like `kubectl apply -f`). Each document's GVK/namespace come from the document; the RESTMapper resolves the resource. Documents apply in order; an error stops the run, leaving earlier documents applied.
func ClusterList ¶
func ClusterList(rc *plugin.RequestContext) (any, error)
ClusterList returns the single cluster row backing the Overview dashboard.
func ClusterMetrics ¶
func ClusterMetrics(rc *plugin.RequestContext, client plugin.ClientStream) error
ClusterMetrics streams cluster-wide CPU/memory/pod usage vs capacity. Frames degrade gracefully (metricsAvailable=false) when metrics-server is absent.
func ClusterShellStream ¶
func ClusterShellStream(rc *plugin.RequestContext, client plugin.ClientStream) error
ClusterShellStream attaches an interactive shell to a long-lived kubectl pod, giving the operator cluster-scoped kubectl from inside the cluster. A single fixed-name pod is reused across sessions, so reconnects are instant and never pile up duplicates.
func ColumnsForKind ¶
func ColumnsForKind(rc *plugin.RequestContext) (any, error)
ColumnsForKind returns the column definitions for a kind's list, used by the generic table's columnsSource. CRDs report their server-side printer columns; built-in kinds report their declared columns.
func Connect ¶
Connect builds the REST config for the connection's transport and wires the typed, dynamic, discovery, RESTMapper, and metrics clients over it.
func CordonNode ¶
func CordonNode(rc *plugin.RequestContext) (any, error)
CordonNode / UncordonNode toggle a node's schedulability.
func DeleteResource ¶
func DeleteResource(rc *plugin.RequestContext) (any, error)
func DrainNode ¶
func DrainNode(rc *plugin.RequestContext) (any, error)
DrainNode cordons a node (Unschedulable=true) and evicts its pods through the Eviction API, honoring PodDisruptionBudgets. Mirror/static and DaemonSet pods are skipped (as kubectl drain does); bare pods are skipped unless force.
func ExecStream ¶
func ExecStream(rc *plugin.RequestContext, client plugin.ClientStream) error
ExecStream runs an interactive exec into a pod container, bridged to the terminal panel. Exec uses a SPDY/WebSocket upgrade; over agent transport that rides the loopback bridge (upgradeConfig), so it works on both transports.
func GetResource ¶
func GetResource(rc *plugin.RequestContext) (any, error)
GetResource returns one object for the detail/YAML view (Secrets redacted).
func GetYAML ¶
func GetYAML(rc *plugin.RequestContext) (any, error)
GetYAML returns a resource as editable YAML (managedFields/status stripped).
func HelmRelease ¶
func HelmRelease(rc *plugin.RequestContext) (any, error)
HelmRelease returns one release's detail (status, chart, notes).
func HelmReleases ¶
func HelmReleases(rc *plugin.RequestContext) (any, error)
func ListResource ¶
func ListResource(rc *plugin.RequestContext) (any, error)
ListResource lists any kind via the dynamic client (built-in GVR or CRD).
func LogsStream ¶
func LogsStream(rc *plugin.RequestContext, client plugin.ClientStream) error
LogsStream streams a pod container's logs to the client. Pod logs are a plain chunked GET (no upgrade), so this works over both direct and agent transport through the session's REST client.
func NodeMetrics ¶
func NodeMetrics(rc *plugin.RequestContext, client plugin.ClientStream) error
NodeMetrics streams one node's CPU/memory usage vs capacity.
func NodePods ¶
func NodePods(rc *plugin.RequestContext) (any, error)
NodePods lists the pods scheduled on a node (for the node detail).
func PodProxyURL ¶
func PodProxyURL(rc *plugin.RequestContext) (any, error)
PodProxyURL is the pod equivalent of ServiceProxyURL: it proxies straight to a pod's container port (a browser-usable, HTTP form of `kubectl port-forward`).
func ResourceEvents ¶
func ResourceEvents(rc *plugin.RequestContext) (any, error)
ResourceEvents lists the events involving one object, for its detail Events tab.
func RestartResource ¶
func RestartResource(rc *plugin.RequestContext) (any, error)
RestartResource triggers a rolling restart (the kubectl rollout-restart stamp).
func RolloutUndo ¶
func RolloutUndo(rc *plugin.RequestContext) (any, error)
RolloutUndo rolls a Deployment back to its previous revision: it finds the owned ReplicaSet with the highest revision below the Deployment's current one and patches the Deployment's pod template back to that ReplicaSet's template.
func Routes ¶
Routes wires the generic, catalog-driven Kubernetes routes. One set of routes (parameterized by {kind}) serves every built-in kind and every CRD.
func ScaleResource ¶
func ScaleResource(rc *plugin.RequestContext) (any, error)
ScaleResource sets spec.replicas on scalable workloads.
func ServiceProxyURL ¶
func ServiceProxyURL(rc *plugin.RequestContext) (any, error)
ServiceProxyURL returns the gateway URL that proxies to a Service's web port for an "Open in browser" link. It picks the most likely web port (an http port, else an https one, else the first) unless an explicit port is given.
func TemplateYAML ¶
func TemplateYAML(rc *plugin.RequestContext) (any, error)
TemplateYAML builds a starter manifest for a kind, derived dynamically from the resolved GroupVersionKind (and the scoped namespace) — never a hardcoded blob.
func TreeCRDGroup ¶
func TreeCRDGroup(rc *plugin.RequestContext) (any, error)
TreeCRDGroup lists the CRD kinds belonging to one API group.
func TreeCRDs ¶
func TreeCRDs(rc *plugin.RequestContext) (any, error)
TreeCRDs groups installed CRDs by API group under Custom Resources: a flat "Definitions" list of every CRD, then one expandable folder per group whose children are that group's kinds.
func TreeCategory ¶
func TreeCategory(rc *plugin.RequestContext) (any, error)
TreeCategory returns a category's kinds as leaves plus any nested sub-groups (e.g. Admission Policies under Config, Gateway API under Network).
func TreeGatewayAPI ¶
func TreeGatewayAPI(rc *plugin.RequestContext) (any, error)
TreeGatewayAPI nests the Gateway API CRD kinds under Network.
func TreeHelm ¶
func TreeHelm(_ *plugin.RequestContext) (any, error)
TreeHelm lists the Helm sub-items (Releases; Charts/repos are out of scope).
func TreeSubgroup ¶
func TreeSubgroup(rc *plugin.RequestContext) (any, error)
TreeSubgroup returns the kinds belonging to a nested sub-group.
func TriggerCronJob ¶
func TriggerCronJob(rc *plugin.RequestContext) (any, error)
TriggerCronJob manually creates a Job from a CronJob's jobTemplate, mirroring `kubectl create job --from=cronjob/<name>`.
func UncordonNode ¶
func UncordonNode(rc *plugin.RequestContext) (any, error)
func WatchResource ¶
func WatchResource(rc *plugin.RequestContext, client plugin.ClientStream) error
WatchResource streams live ResourceEvents for a kind so the generic table/tree patches in place. It uses the API watch directly (the dynamic client's Watch), scoped to the same namespace as the list.
func WorkloadPods ¶
func WorkloadPods(rc *plugin.RequestContext) (any, error)
WorkloadPods lists the pods a workload owns, matched by its selector labels.
Types ¶
type ApplyRequest ¶
ApplyRequest is the code_editor save body, optionally a dry-run.
type DrainRequest ¶
type ScaleRequest ¶
type ScaleRequest struct {
Replicas int64 `json:"replicas"`
}
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a live connection to one Kubernetes cluster. It holds every per-connection client; the plugin struct stays stateless. Heavy machinery (informers) is opened lazily and guarded by mu.
func Unwrap ¶
Unwrap recovers the concrete Session from a plugin.Session, looking through a wrapper (e.g. the recording layer) that exposes Session().
func (*Session) Clientset ¶
func (s *Session) Clientset() *kubeclient.Clientset
Clientset exposes the typed client for built-in API groups.
func (*Session) DefaultNamespace ¶
DefaultNamespace is the connection's configured default ("" = all namespaces).
func (*Session) Discovery ¶
func (s *Session) Discovery() discovery.CachedDiscoveryInterface
Discovery exposes cached API discovery (kinds, CRDs, server version).
func (*Session) Dynamic ¶
Dynamic exposes the unstructured client used for every kind, including CRDs.
func (*Session) HealthCheck ¶
HealthCheck probes connectivity and auth with a context-bound /version call (allowed for every principal, so it never trips on a scoped credential).
func (*Session) Mapper ¶
func (s *Session) Mapper() meta.RESTMapper
Mapper resolves a GroupVersionKind to its REST resource (and scope).
func (*Session) Metrics ¶
func (s *Session) Metrics() *metricsclient.Clientset
Metrics exposes the metrics.k8s.io client (may be unavailable on a cluster without metrics-server; callers degrade gracefully).
func (*Session) OpenChannel ¶
OpenChannel is implemented in step 3 (pod logs/exec/port-forward); core resources stream via informer-backed watch routes, not channels.
func (*Session) ServeHTTPProxy ¶
func (s *Session) ServeHTTPProxy(w http.ResponseWriter, r *http.Request)
ServeHTTPProxy reverse-proxies a browser request to a Service or Pod port. It reaches the workload through the pod port-forward subresource — an L4 tunnel — so the app's own Authorization/cookies pass through to the backend, which the API server's HTTP proxy would otherwise strip. The incoming path is `/{services|pods}/{ns}/{name}/{port}/{rest...}`; generic HTML/redirect/cookie rewriting and the service worker live in the shared webproxy package.