cluster

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: 16 Imported by: 0

Documentation

Overview

Package cluster implements the `olares-cli cluster` umbrella command tree. Identity (which Olares user) and transport (which cluster) are resolved from the currently-selected profile via cmdutil.Factory (switch with `olares-cli profile use <name>`), exactly like `olares-cli settings` and `olares-cli market`.

The subtree exposes a per-user K8s view of an Olares instance — pods / workloads / containers / applications, plus the supporting nouns (namespaces, nodes, middleware, jobs). It is the CLI counterpart of the ControlHub SPA at apps/packages/app/src/apps/controlHub.

Boundary notes:

  • This subtree is NOT cluster maintenance. The existing `olares-cli node` / `gpu` / `os` trees handle host-side install and upgrade via kubeconfig; this tree is purely runtime, profile-based, and visibility-scoped per user.

  • Per-user resource scoping is enforced server-side. CLI verbs here MUST NOT consult the locally cached cluster context to decide whether a call is allowed; the server is the only authority. The cache is strictly a display + error-message convenience. See skills/olares-cluster/SKILL.md for the full rationale.

  • Single-app lifecycle (install / uninstall / upgrade / start / stop) belongs to `olares-cli market`. `cluster application ...` here is the runtime-state view (which workloads are healthy, which pod isn't ready) — never a lifecycle mutator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClusterCommand

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

NewClusterCommand assembles the `olares-cli cluster` subtree. Verbs are added incrementally (Phase 0 ships `cluster context`; Phase 1a adds `cluster pod`; Phase 1d (partial) adds `cluster application`); the umbrella's --help is the directory of available areas from day one even when individual nouns are still pending later phases.

Authentication and transport are inherited from the shared cmdutil.Factory (set up in cli/cmd/ctl/root.go) so the currently-selected profile flows through unchanged. No per-command auth flags, and no per-invocation profile override — switch with `olares-cli profile use <name>` ahead of time.

func NewContextCommand

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

NewContextCommand: `olares-cli cluster context [--refresh] [-o table|json]`

Reports the active profile's identity from the ControlHub side — who the server says you are (username, globalrole), which workspaces and system namespaces you can see, which clusters you've been granted, and the overall cluster role. Defaults to the locally cached value (config.json's clusterContext / clusterContextRefreshedAt fields). Use --refresh to force a server roundtrip against /capi/app/detail — the same endpoint the ControlHub SPA's AppDetail store hits in apps/packages/app/src/apps/controlHub/stores/AppDetail.ts.

This is the moral counterpart of `olares-cli profile whoami`: whoami answers "who am I in BFL terms?" (OwnerRole on the desktop ingress), context answers "who am I in K8s/KubeSphere terms?" (globalrole on the ControlHub ingress). Both default to the cached value to keep "what scope do I have right now?" a one-key answer; both refresh on demand via --refresh.

IMPORTANT: this cache is for display only. NO `cluster ...` verb reads it to decide whether a call is allowed — the server is the only authority. If you suspect role drift after the cache was written, run with --refresh to reconcile.

Output:

  • table (default): identity + freshness + workspaces + system namespaces + granted clusters, plus a "globalrole changed: X -> Y" notice when --refresh detected drift.
  • json: clusterctx.Display verbatim, so scripts can branch on {"globalrole":"platform-admin"} without parsing prose.

Types

This section is empty.

Directories

Path Synopsis
Package application implements `olares-cli cluster application ...`.
Package application implements `olares-cli cluster application ...`.
Package container implements `olares-cli cluster container ...` — per-container drill-down inside a Pod.
Package container implements `olares-cli cluster container ...` — per-container drill-down inside a Pod.
Package cronjob implements `olares-cli cluster cronjob ...` — CronJob inspection plus suspend/resume mutations.
Package cronjob implements `olares-cli cluster cronjob ...` — CronJob inspection plus suspend/resume mutations.
internal
clusteropts
Package clusteropts hosts the shared option bag used by every `cluster ...` verb (top-level + subpackages).
Package clusteropts hosts the shared option bag used by every `cluster ...` verb (top-level + subpackages).
Package job implements `olares-cli cluster job ...` — read- and write-side Job inspection (and the KubeSphere-flavored "rerun" action) for the active user's profile.
Package job implements `olares-cli cluster job ...` — read- and write-side Job inspection (and the KubeSphere-flavored "rerun" action) for the active user's profile.
Package middleware implements `olares-cli cluster middleware ...`.
Package middleware implements `olares-cli cluster middleware ...`.
password
Package password implements `olares-cli cluster middleware password ...`.
Package password implements `olares-cli cluster middleware password ...`.
Package namespace implements `olares-cli cluster namespace ...` — raw K8s Namespace inspection visible to the active profile.
Package namespace implements `olares-cli cluster namespace ...` — raw K8s Namespace inspection visible to the active profile.
Package node implements `olares-cli cluster node ...` — cluster node inspection visible to the active profile.
Package node implements `olares-cli cluster node ...` — cluster node inspection visible to the active profile.
Package pod implements `olares-cli cluster pod ...` — read-side pod inspection for the active user's profile.
Package pod implements `olares-cli cluster pod ...` — read-side pod inspection for the active user's profile.
Package workload implements `olares-cli cluster workload ...` — read-side workload (Deployment / StatefulSet / DaemonSet) inspection for the active user's profile.
Package workload implements `olares-cli cluster workload ...` — read-side workload (Deployment / StatefulSet / DaemonSet) inspection for the active user's profile.

Jump to

Keyboard shortcuts

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