Help us shape the future of Go! Take the 2026 Go Developer Survey

kubernetes

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package kubernetes preserves the released path for the deliberately narrow Kubernetes integration.

Deprecated: use github.com/faustbrian/go-queue-control-plane/v2/adapters/kubernetes.

Index

Constants

View Source
const (
	// MaxPageSize bounds one Kubernetes Deployment request.
	MaxPageSize int64 = 500
	// MaxContinueTokenBytes bounds the opaque Kubernetes pagination token.
	MaxContinueTokenBytes = 4_096
)

Variables

View Source
var (
	// ErrInvalidConfiguration reports an unscoped Kubernetes adapter.
	ErrInvalidConfiguration = errors.New("kubernetes: invalid configuration")
	// ErrInvalidWorkload reports a malformed Kubernetes Deployment name.
	ErrInvalidWorkload = errors.New("kubernetes: invalid workload")
	// ErrInvalidPage reports an unbounded Deployment list request.
	ErrInvalidPage = errors.New("kubernetes: invalid page")
	// ErrInvalidResponse reports malformed or cross-namespace Kubernetes state.
	ErrInvalidResponse = errors.New("kubernetes: invalid response")
)
View Source
var (
	// ErrInvalidDispatcher reports a missing tenant-to-cluster resolver.
	ErrInvalidDispatcher = errors.New("kubernetes: invalid dispatcher")
	// ErrUnsupportedCommand reports a non-scaling command at this boundary.
	ErrUnsupportedCommand = errors.New("kubernetes: unsupported command")
)
View Source
var (
	// ErrInvalidResolver reports an empty or malformed tenant mapping.
	ErrInvalidResolver = errors.New("kubernetes: invalid tenant resolver")
	// ErrTenantNotConfigured reports a tenant without Kubernetes visibility.
	ErrTenantNotConfigured = errors.New("kubernetes: tenant not configured")
)
View Source
var ErrInvalidTenantDocument = errors.New("kubernetes: invalid tenant document")

ErrInvalidTenantDocument is a stable Kubernetes mapping error.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter reports Deployment status from one configured namespace.

func New

func New(namespace string, client DeploymentClient) (*Adapter, error)

New creates an adapter scoped to namespace.

func (*Adapter) Get

func (adapter *Adapter) Get(ctx context.Context, name string) (Status, error)

Get returns the current status of one Deployment.

func (*Adapter) List

func (adapter *Adapter) List(ctx context.Context, limit int64, continueToken string) (Page, error)

List returns one server-paginated page of Deployment status.

func (*Adapter) Scale

func (adapter *Adapter) Scale(ctx context.Context, name string, replicas uint32) (ScaleResult, error)

Scale updates only the Deployment scale subresource. Authorization and scale-to-zero confirmation are enforced by the control service before this adapter is called.

type DeploymentClient

DeploymentClient is the deliberately restricted part of a namespace-scoped Kubernetes Deployment client used by the control plane.

type DeploymentFactory

type DeploymentFactory func(namespace string) DeploymentClient

DeploymentFactory returns the restricted Deployment client for one namespace.

type Page

type Page struct {
	Items     []Status `json:"items"`
	Continue  string   `json:"continue,omitempty"`
	Remaining int64    `json:"remaining"`
}

Page is one bounded page of Deployment status.

type ScaleDispatcher

type ScaleDispatcher struct {
	// contains filtered or unexported fields
}

ScaleDispatcher sends validated scaling commands to a tenant-scoped Kubernetes adapter.

func NewScaleDispatcher

func NewScaleDispatcher(resolver TenantResolver) (*ScaleDispatcher, error)

NewScaleDispatcher creates a scale-only Kubernetes command dispatcher.

func (*ScaleDispatcher) Dispatch

func (dispatcher *ScaleDispatcher) Dispatch(ctx context.Context, command controlplane.Command) error

Dispatch resolves the tenant and updates only the workload scale subresource.

type ScaleResult

type ScaleResult struct {
	Namespace       string `json:"namespace"`
	Name            string `json:"name"`
	DesiredReplicas int32  `json:"desired_replicas"`
	CurrentReplicas int32  `json:"current_replicas"`
	ResourceVersion string `json:"resource_version"`
}

ScaleResult is the Kubernetes acknowledgement of an authorized replica update.

type Scaler

type Scaler interface {
	Scale(context.Context, string, uint32) (ScaleResult, error)
}

Scaler is the scale-only workload mutation exposed to the dispatcher.

type StaticTenantResolver

type StaticTenantResolver struct {
	// contains filtered or unexported fields
}

StaticTenantResolver stores an immutable tenant-to-namespace mapping.

func LoadTenantResolver

func LoadTenantResolver(
	reader io.Reader,
	maxBytes int64,
	factory DeploymentFactory,
) (*StaticTenantResolver, error)

LoadTenantResolver builds immutable namespace-scoped adapters from one strict, bounded tenant document.

func NewStaticTenantResolver

func NewStaticTenantResolver(configured map[string]TenantAdapter) (*StaticTenantResolver, error)

NewStaticTenantResolver copies a fixed tenant adapter mapping.

func (*StaticTenantResolver) ListTenantWorkloads

func (resolver *StaticTenantResolver) ListTenantWorkloads(
	ctx context.Context,
	tenant string,
	limit int64,
	continueToken string,
) (Page, error)

ListTenantWorkloads returns a bounded page through the preconfigured tenant boundary.

func (*StaticTenantResolver) ResolveTenant

func (resolver *StaticTenantResolver) ResolveTenant(_ context.Context, tenant string) (Scaler, error)

ResolveTenant returns the preconfigured scale-only tenant boundary.

type Status

type Status struct {
	Namespace           string `json:"namespace"`
	Name                string `json:"name"`
	Generation          int64  `json:"generation"`
	ObservedGeneration  int64  `json:"observed_generation"`
	DesiredReplicas     int32  `json:"desired_replicas"`
	UpdatedReplicas     int32  `json:"updated_replicas"`
	ReadyReplicas       int32  `json:"ready_replicas"`
	AvailableReplicas   int32  `json:"available_replicas"`
	UnavailableReplicas int32  `json:"unavailable_replicas"`
}

Status is the bounded Deployment state presented by the control plane.

type TenantAdapter

type TenantAdapter interface {
	Scaler
	List(context.Context, int64, string) (Page, error)
}

TenantAdapter is the complete bounded Kubernetes surface for one tenant.

type TenantResolver

type TenantResolver interface {
	ResolveTenant(context.Context, string) (Scaler, error)
}

TenantResolver maps a tenant to its namespace-scoped Kubernetes adapter.

Jump to

Keyboard shortcuts

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