kube

package
v0.0.40 Latest Latest
Warning

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

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

Documentation

Overview

SSA orchestration over k8s.io/cli-runtime/pkg/resource.Builder. The Builder handles the generic kubectl-style pipeline (parse YAML stream, resolve REST mappings, build per-object REST clients) using our Client's ConfigFlags as the RESTClientGetter; this file adds the seictl-specific orchestration on top: namespace pre-flight, generation-based action attribution, and an actionable wrapper for "CRD missing" errors.

Package kube wraps kubeconfig loading for cluster-facing seictl commands. Client holds a *genericclioptions.ConfigFlags so it satisfies cli-runtime's RESTClientGetter natively — Builder, Helper, and discovery cache all consume it directly without adapter shims.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyResult

type ApplyResult struct {
	Kind      string
	Name      string
	Namespace string
	Action    string // "create" | "update" | "unchanged"
}

ApplyResult is what Apply emits per input document. Action distinguishes create / update / unchanged, sourced from .metadata.generation (which only ticks on spec changes, unlike resourceVersion which controllers bump for status writes).

type Client

type Client struct {
	ContextName   string
	ClusterName   string
	ClusterServer string
	Namespace     string
	// contains filtered or unexported fields
}

func New

func New(opts Options) (*Client, *clioutput.Error)

New resolves kubeconfig context + namespace into a Client. Errors in this layer are kubeconfig-shape problems and map to ExitIdentity / CatKubeconfigParse, not cluster reachability. With no current-context and no --context override, falls back to rest.InClusterConfig().

func (*Client) Apply

func (c *Client) Apply(ctx context.Context, fieldOwner, namespace string, docs [][]byte) ([]ApplyResult, error)

Apply does server-side apply on each input doc with the given field owner, writing into namespace. The contract is all-or-nothing: any failure aborts and returns no partial results, matching the LLD's "no partial-state tracking" stance — the engineer re-runs.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, opts DeleteOptions) ([]DeleteResult, error)

Delete tears down all objects matching the label selector across the requested resource types. DeletePropagationForeground ensures children (e.g., StatefulSet pods owned by a SeiNodeDeployment) cascade in order.

Returns one DeleteResult per matched object. NotFound is treated as success ("already gone"). The caller is responsible for the finalizer-stuck timeout policy (LLD §Landmine).

func (*Client) GetJobSnapshot

func (c *Client) GetJobSnapshot(ctx context.Context, namespace, name string) (JobSnapshot, error)

GetJobSnapshot returns {Found: false} on NotFound; other apiserver errors propagate.

func (*Client) GetSND added in v0.0.35

func (c *Client) GetSND(ctx context.Context, namespace, name string) (*unstructured.Unstructured, error)

GetSND returns (nil, nil) on NotFound so callers distinguish "not yet" from a hard error.

func (*Client) List

List returns Unstructured objects across the given resource types filtered by labels. Errors short-circuit; partial results are not returned (mirrors Apply's all-or-nothing contract).

func (*Client) RESTClientGetter

func (c *Client) RESTClientGetter() genericclioptions.RESTClientGetter

RESTClientGetter exposes the underlying ConfigFlags for callers that need to feed cli-runtime APIs (resource.Builder, etc.) directly.

type DeleteOptions

type DeleteOptions struct {
	Namespace     string
	Resources     []string
	LabelSelector string
}

DeleteOptions mirrors ListOptions — same selector + resource types, but every match is deleted with foreground propagation.

type DeleteResult

type DeleteResult struct {
	Kind      string
	Name      string
	Namespace string
	Action    string // "deleted" | "not-found" | "still-terminating"
}

DeleteResult is what Delete emits per matched object.

type JobSnapshot

type JobSnapshot struct {
	Found           bool
	ImageSHA        string // annotations["sei.io/image-sha"]
	DeadlineSeconds int64  // spec.activeDeadlineSeconds
}

JobSnapshot exposes the subset of Job state that callers need to reason about Job immutability without importing batchv1.

type ListOptions

type ListOptions struct {
	Namespace     string
	Resources     []string
	LabelSelector string
	AllNamespaces bool
}

ListOptions selects what to list. Resources is a slice of resource names (plural) like "seinodedeployments", "jobs", "configmaps". LabelSelector follows the standard `key=value,key2=value2` form.

type Options

type Options struct {
	// Kubeconfig is an explicit kubeconfig path. Empty falls back to
	// the KUBECONFIG env var, then ~/.kube/config.
	Kubeconfig string
	// Context is the kubeconfig context name to use. Empty falls back
	// to the kubeconfig's current-context.
	Context string
	// Namespace overrides the context's namespace. Empty falls back to
	// the context's namespace, then "default".
	Namespace string
}

Jump to

Keyboard shortcuts

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