node

package
v0.0.0-...-310f30e Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package node implements `olares-cli cluster node ...` — cluster node inspection visible to the active profile.

Like every other verb in the cluster tree, server-side scoping decides what's visible (e.g. a non-admin profile may receive an empty list or 403 when listing nodes). CLI never gates locally; see olares-cluster SKILL.md for the security rationale.

This is the per-user K8s view of nodes — for host-side node install / join / drain operations see `olares-cli node` (the kubeconfig-based tree).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGetCommand

func NewGetCommand(f *cmdutil.Factory) *cobra.Command

NewGetCommand: `olares-cli cluster node get <name> [-o table|json]`.

Calls SPA's getNodeDetail (apps/packages/app/src/apps/controlPanelCommon/network/index.ts:164): `/kapis/resources.kubesphere.io/v1alpha3/nodes/<node>` — returns the K8s native Node object (no envelope; KubeSphere's per-resource detail just forwards the upstream shape).

func NewListCommand

func NewListCommand(f *cmdutil.Factory) *cobra.Command

NewListCommand: `olares-cli cluster node list [-l SEL] [--limit N] [--page N] [--all] [-o table|json]`.

Calls SPA's getNodesList (apps/packages/app/src/apps/controlPanelCommon/network/index.ts:46): `/kapis/resources.kubesphere.io/v1alpha3/nodes`. Server-side scoping decides what's visible.

func NewNodeCommand

func NewNodeCommand(f *cmdutil.Factory) *cobra.Command

NewNodeCommand assembles `olares-cli cluster node`. Today's verbs are read-only `list` + `get`. Mutating verbs (cordon / drain) live outside this tree (they require kubeconfig).

Types

type Node

type Node struct {
	Kind       string `json:"kind,omitempty"`
	APIVersion string `json:"apiVersion,omitempty"`
	Metadata   struct {
		Name              string            `json:"name"`
		UID               string            `json:"uid,omitempty"`
		CreationTimestamp string            `json:"creationTimestamp,omitempty"`
		Labels            map[string]string `json:"labels,omitempty"`
		Annotations       map[string]string `json:"annotations,omitempty"`
	} `json:"metadata"`
	Spec struct {
		Unschedulable bool        `json:"unschedulable,omitempty"`
		Taints        []NodeTaint `json:"taints,omitempty"`
	} `json:"spec,omitempty"`
	Status struct {
		Conditions  []NodeCondition   `json:"conditions,omitempty"`
		Addresses   []NodeAddress     `json:"addresses,omitempty"`
		NodeInfo    NodeInfo          `json:"nodeInfo,omitempty"`
		Capacity    map[string]string `json:"capacity,omitempty"`
		Allocatable map[string]string `json:"allocatable,omitempty"`
	} `json:"status,omitempty"`
}

Node is the minimal corev1.Node + status subset rendered by the cluster node verbs. Mirrors the projection KubeSphere returns from /kapis/resources.kubesphere.io/v1alpha3/nodes.

func (Node) Age

func (n Node) Age(now time.Time) string

Age returns the AGE column.

func (Node) InternalIP

func (n Node) InternalIP() string

InternalIP returns the first InternalIP address (matches kubectl behavior). Falls back to ExternalIP, then "-".

func (Node) KubeletVersion

func (n Node) KubeletVersion() string

KubeletVersion is a small accessor — keeps the rendering code in list.go / get.go from poking deep into Status.NodeInfo.

func (Node) Roles

func (n Node) Roles() string

Roles returns the comma-joined list of node roles, derived from the standard `node-role.kubernetes.io/<role>` label key prefix. Empty (no role labels) → "<none>" (matches `kubectl get nodes`).

func (Node) StatusLabel

func (n Node) StatusLabel() string

StatusLabel returns the kubectl-style STATUS column.

  • "Ready" when conditions[type=Ready].status == "True" and the node is schedulable.
  • "Ready,SchedulingDisabled" when Ready=True but spec.unschedulable=true (cordoned).
  • "NotReady" when Ready=False or Unknown.
  • "Unknown" when no Ready condition is present at all.

Named with the "Label" suffix because Status() would shadow the `Status` field on the same struct.

type NodeAddress

type NodeAddress struct {
	Type    string `json:"type"`
	Address string `json:"address"`
}

type NodeCondition

type NodeCondition struct {
	Type    string `json:"type"`
	Status  string `json:"status"`
	Reason  string `json:"reason,omitempty"`
	Message string `json:"message,omitempty"`
}

type NodeInfo

type NodeInfo struct {
	OSImage                 string `json:"osImage,omitempty"`
	KernelVersion           string `json:"kernelVersion,omitempty"`
	Architecture            string `json:"architecture,omitempty"`
	OperatingSystem         string `json:"operatingSystem,omitempty"`
	KubeletVersion          string `json:"kubeletVersion,omitempty"`
	ContainerRuntimeVersion string `json:"containerRuntimeVersion,omitempty"`
}

type NodeTaint

type NodeTaint struct {
	Key    string `json:"key"`
	Value  string `json:"value,omitempty"`
	Effect string `json:"effect"`
}

Jump to

Keyboard shortcuts

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