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 DebugCreate(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 PodContainers(rc *plugin.RequestContext) (any, error)
- func PodFileDelete(rc *plugin.RequestContext) (any, error)
- func PodFileDownload(rc *plugin.RequestContext) (any, error)
- func PodFileMkdir(rc *plugin.RequestContext) (any, error)
- func PodFileRead(rc *plugin.RequestContext) (any, error)
- func PodFileRename(rc *plugin.RequestContext) (any, error)
- func PodFileUpload(rc *plugin.RequestContext) (any, error)
- func PodFileWrite(rc *plugin.RequestContext) (any, error)
- func PodFilesList(rc *plugin.RequestContext) (any, error)
- func PodMetrics(rc *plugin.RequestContext, client plugin.ClientStream) error
- func PodOpenPorts(rc *plugin.RequestContext) (any, error)
- func PodProxyURL(rc *plugin.RequestContext) (any, error)
- func ResourceEvents(rc *plugin.RequestContext) (any, error)
- func ResourceOverview(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 ServiceOpenPorts(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 WatchEvents(rc *plugin.RequestContext, client plugin.ClientStream) error
- func WatchObject(rc *plugin.RequestContext, client plugin.ClientStream) error
- func WatchObjectYAML(rc *plugin.RequestContext, client plugin.ClientStream) error
- func WatchResource(rc *plugin.RequestContext, client plugin.ClientStream) error
- func WorkloadLogsStream(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 DebugCreate ¶ added in v0.1.1
func DebugCreate(rc *plugin.RequestContext) (any, error)
DebugCreate adds an ephemeral debug container to a running pod and returns once it is running; the action's onSuccess then execs into it. Keeping create and attach separate means the container is only added on an explicit Debug click.
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 (server-managed fields 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)
HelmReleases lists one page of releases. The page is chosen from label metadata and only its own revisions are decoded, so a namespace retaining many revisions per release costs a page of gunzips, not a cluster's worth.
func ListResource ¶
func ListResource(rc *plugin.RequestContext) (any, error)
ListResource lists any kind via the dynamic client (built-in GVR or CRD), returning one bounded page plus the apiserver's cursor for the next.
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 PodContainers ¶ added in v0.1.1
func PodContainers(rc *plugin.RequestContext) (any, error)
PodContainers lists a pod's containers (init then app) as options for a stream control such as the logs container picker.
func PodFileDelete ¶ added in v0.1.1
func PodFileDelete(rc *plugin.RequestContext) (any, error)
func PodFileDownload ¶ added in v0.1.1
func PodFileDownload(rc *plugin.RequestContext) (any, error)
func PodFileMkdir ¶ added in v0.1.1
func PodFileMkdir(rc *plugin.RequestContext) (any, error)
func PodFileRead ¶ added in v0.1.1
func PodFileRead(rc *plugin.RequestContext) (any, error)
func PodFileRename ¶ added in v0.1.1
func PodFileRename(rc *plugin.RequestContext) (any, error)
func PodFileUpload ¶ added in v0.1.1
func PodFileUpload(rc *plugin.RequestContext) (any, error)
func PodFileWrite ¶ added in v0.1.1
func PodFileWrite(rc *plugin.RequestContext) (any, error)
func PodFilesList ¶ added in v0.1.1
func PodFilesList(rc *plugin.RequestContext) (any, error)
func PodMetrics ¶ added in v0.1.1
func PodMetrics(rc *plugin.RequestContext, client plugin.ClientStream) error
PodMetrics streams one pod's current CPU/memory usage with request/limit context when metrics-server is installed.
func PodOpenPorts ¶ added in v0.1.1
func PodOpenPorts(rc *plugin.RequestContext) (any, error)
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 ResourceOverview ¶ added in v0.1.1
func ResourceOverview(rc *plugin.RequestContext) (any, error)
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)
func ServiceOpenPorts ¶ added in v0.1.1
func ServiceOpenPorts(rc *plugin.RequestContext) (any, error)
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 WatchEvents ¶ added in v0.1.1
func WatchEvents(rc *plugin.RequestContext, client plugin.ClientStream) error
WatchEvents streams live events involving one object so its Events timeline updates in place instead of polling.
func WatchObject ¶ added in v0.1.1
func WatchObject(rc *plugin.RequestContext, client plugin.ClientStream) error
WatchObject streams one resource as the same record shape the overview GET returns, so the detail panel live-updates in place.
func WatchObjectYAML ¶ added in v0.1.1
func WatchObjectYAML(rc *plugin.RequestContext, client plugin.ClientStream) error
WatchObjectYAML streams one resource as clean editable YAML, matching GetYAML so the editor's live content equals a fresh load.
func WatchResource ¶
func WatchResource(rc *plugin.RequestContext, client plugin.ClientStream) error
WatchResource streams a kind's live ResourceEvents so the generic table/tree patches in place, scoped to the same namespace as the list.
func WorkloadLogsStream ¶ added in v0.1.1
func WorkloadLogsStream(rc *plugin.RequestContext, client plugin.ClientStream) error
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.
Source Files
¶
- clustershell.go
- config.go
- crd.go
- debug.go
- errors.go
- events.go
- exec.go
- generic.go
- header.go
- helm.go
- kindrows.go
- kinds.go
- kubernetes.go
- logging.go
- logs.go
- mappers.go
- metrics.go
- object_overview.go
- ops.go
- overviews.go
- params.go
- permissions.go
- pod.go
- podfs.go
- portforward.go
- prometheus.go
- proxy_http.go
- resources.go
- routes.go
- rows.go
- session.go
- table.go
- tree.go
- watch.go
- watchhub.go
- yaml.go
- yamlui.go