Documentation
¶
Overview ¶
Package kubernetes exposes the deliberately narrow Kubernetes integration.
Index ¶
Constants ¶
const ( // MaxPageSize bounds one Kubernetes Deployment request. MaxPageSize int64 = 500 // MaxContinueTokenBytes bounds the opaque Kubernetes pagination token. MaxContinueTokenBytes = 4_096 )
Variables ¶
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") )
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") )
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") )
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.
type DeploymentClient ¶
type DeploymentClient interface {
Get(context.Context, string, metav1.GetOptions) (*appsv1.Deployment, error)
List(context.Context, metav1.ListOptions) (*appsv1.DeploymentList, error)
GetScale(context.Context, string, metav1.GetOptions) (*autoscalingv1.Scale, error)
UpdateScale(context.Context, string, *autoscalingv1.Scale, metav1.UpdateOptions) (*autoscalingv1.Scale, error)
}
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 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"`
}
Status is the bounded Deployment state presented by the control plane.
type TenantAdapter ¶
TenantAdapter is the complete bounded Kubernetes surface for one tenant.