kube

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package kube bootstraps a read-only kubeconfig for the cell.

Flow: take an admin kubeconfig on the host, create a ServiceAccount bound to the built-in `view` ClusterRole on the cluster, mint a token, and write a sibling kubeconfig authenticated as that SA. The cell mounts the sibling and gets cluster reads with server-enforced no-writes — regardless of which tool inside the cell uses it (kubectl, helm, the kubernetes-mcp-server).

All cluster mutation happens via host `kubectl`. No client-go dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(ctx context.Context, opts Options, out io.Writer) error

Bootstrap runs the full read-only kubeconfig flow. Status lines are written to out. Returns nil on success.

func SetConfirmFn

func SetConfirmFn(fn func(ctx context.Context, msg string) (bool, error))

SetConfirmFn wires the interactive prompt. The cobra layer calls this once at startup, routing through ux.GetConfirmation. Tests override `confirmFn` directly via the package-private var.

Types

type Options

type Options struct {
	Source      string        // path to admin kubeconfig
	Output      string        // path to write the -read sibling
	SAName      string        // ServiceAccount name on the cluster
	Namespace   string        // ServiceAccount namespace
	TTL         time.Duration // requested token duration (cluster may cap)
	SkipCluster bool          // skip SA/binding/token creation (kubeconfig writeback only)
	Yes         bool          // skip the interactive confirmation prompt
}

Options controls Bootstrap. Zero-value Options should be passed through Defaults() before use.

func Defaults

func Defaults(o Options) Options

Defaults fills in zero fields from the host environment.

  • Source: $KUBECONFIG, else ~/.kube/config
  • Output: derived from Source: `nmd-prod` → `nmd-prod-read`, `config` → `config-read`
  • SAName: $USER + "-readonly" (e.g. dmitry-readonly)
  • Namespace: "default"
  • TTL: 8760h (1 year; cluster may cap shorter)

type SourceInfo

type SourceInfo struct {
	Context  string
	Server   string
	Identity string
}

SourceInfo summarises the source kubeconfig for the confirmation prompt.

Jump to

Keyboard shortcuts

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