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

kubernetes

package
v1.4.30 Latest Latest
Warning

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

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

Documentation

Overview

Package kubernetes provides bounded, read-only access to Kubernetes APIs.

Index

Constants

View Source
const (
	MaxLogStreamLineBytes  = 16 << 10
	MaxLogStreamBytes      = 16 << 20
	MaxLogStreamDuration   = 30 * time.Minute
	LogStreamHeartbeat     = 15 * time.Second
	LogStreamIdleTimeout   = 2 * time.Minute
	MaxPreviousLogDuration = 30 * time.Second
	MaxOrgLogStreams       = 4
	MaxProcessLogStreams   = 20
)

Variables

View Source
var (
	ErrInvalidEndpoint  = errors.New("kubernetes: invalid endpoint")
	ErrUnauthorized     = errors.New("kubernetes: unauthorized")
	ErrForbidden        = errors.New("kubernetes: forbidden")
	ErrNotFound         = errors.New("kubernetes: not found")
	ErrResponseTooLarge = errors.New("kubernetes: response too large")

	ErrRedirect              = errors.New("kubernetes: redirect refused")
	ErrInvalidArguments      = errors.New("kubernetes: invalid arguments")
	ErrOperationBudget       = errors.New("kubernetes: operation budget exhausted")
	ErrGraphIncomplete       = errors.New("kubernetes: complete graph could not be verified")
	ErrCompleteGraphLimit    = errors.New("kubernetes: complete graph safety limit exceeded")
	ErrCredentialUnavailable = errors.New("kubernetes: credential unavailable")
)
View Source
var ErrLogStreamBusy = errors.New("kubernetes: log stream concurrency limit reached")

Functions

func DecodeCAData

func DecodeCAData(value string) ([]byte, error)

DecodeCAData decodes bounded base64 PEM data for direct connector configuration.

func ParseQuantity

func ParseQuantity(value string) (*big.Rat, error)

ParseQuantity converts a Kubernetes quantity to an exact rational value.

Types

type AuthOptions

type AuthOptions struct {
	Mode, Endpoint, CAFile, CAData, ServerName, Token, TokenFile              string
	CertificateFile, KeyFile, CertificateData, KeyData                        string
	KubeconfigPath, KubeconfigContext                                         string
	EKSClusterName, EKSRegion, EKSRoleARN, EKSProfile                         string
	AKSCredentialMode, AKSServerID, AKSTenantID, AKSClientID, AKSClientSecret string
	AKSFederatedTokenFile, AKSEnvironment, GKECredentialsFile                 string
}

AuthOptions contains the supported, provider-neutral Kubernetes auth inputs.

type Change added in v1.4.29

type Change = kubechanges.Change

type ChangeFieldChange added in v1.4.29

type ChangeFieldChange = kubechanges.FieldChange

type ChangePage added in v1.4.29

type ChangePage struct {
	Items     []Change          `json:"items"`
	Next      string            `json:"next,omitempty"`
	Truncated bool              `json:"truncated"`
	Partial   []PartialFailure  `json:"partial_failures,omitempty"`
	Gaps      []kubechanges.Gap `json:"gaps"`
	Sync      SyncStatus        `json:"sync"`
}

type ChangeQuery added in v1.4.29

type ChangeQuery = kubechanges.Query

type ChangeType added in v1.4.29

type ChangeType = kubechanges.Type

type Client

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

Client is a read-only, bounded Kubernetes API transport.

func NewClient

func NewClient(config Config) (*Client, error)

NewClient validates transport policy and constructs a read-only API client.

func (*Client) GetJSON

func (client *Client) GetJSON(ctx context.Context, apiPath string, output any) error

GetJSON performs one authenticated, bounded GET and decodes its JSON body.

func (*Client) GetMetadataJSON added in v1.4.29

func (client *Client) GetMetadataJSON(ctx context.Context, apiPath string, output any) error

type Condition

type Condition struct {
	Type   string `json:"type"`
	Status string `json:"status"`
	Reason string `json:"reason,omitempty"`
}

type Config

type Config struct {
	Endpoint             string
	TokenFile            string
	CAFile               string
	CAData               []byte
	ServerName           string
	Credentials          CredentialSource
	Timeout              time.Duration
	MaxBodyBytes         int64
	AllowLoopbackHTTP    bool
	AllowLoopback        bool
	AllowPrivateNetworks bool
	EndpointCIDRs        []string
}

Config defines one Kubernetes API connection. Credentials are read from TokenFile for every request so projected service-account rotation is honored.

func ResolveAuthentication

func ResolveAuthentication(options AuthOptions) (Config, error)

ResolveAuthentication resolves one explicit auth mode into the existing stdlib HTTP client configuration.

type CredentialSource

type CredentialSource interface {
	Authorization(context.Context) (string, error)
	ClientCertificate(*tls.CertificateRequestInfo) (*tls.Certificate, error)
}

CredentialSource supplies request and TLS credentials without exposing them through connector configuration or status DTOs.

type DiagnoseOptions added in v1.4.29

type DiagnoseOptions struct {
	ResourceID   string
	Kind         string
	Namespace    string
	Name         string
	LogTail      int
	ChangeWindow time.Duration
}

type Diagnosis added in v1.4.29

type Diagnosis struct {
	Workload      WorkloadDetail      `json:"workload"`
	WarningEvents []ProjectedResource `json:"warning_events,omitempty"`
	WorstPodLogs  *PodLogs            `json:"worst_pod_logs,omitempty"`
	Changes       []Change            `json:"changes"`
	Neighborhood  kubegraph.Graph     `json:"neighborhood"`
	Partial       []PartialFailure    `json:"partial_failures,omitempty"`
	Omitted       []string            `json:"omitted_categories,omitempty"`
	Truncated     bool                `json:"truncated"`
	Sync          SyncStatus          `json:"sync"`
}

type Discovery

type Discovery struct {
	ObservedAt time.Time            `json:"observed_at"`
	Resources  []ResourceDefinition `json:"resources"`
	Partial    []PartialFailure     `json:"partial_failures,omitempty"`
}

Discovery is a bounded cluster-driven API registry.

type ErrorDetail

type ErrorDetail struct {
	Code      string `json:"code"`
	Message   string `json:"message"`
	Action    string `json:"action"`
	Retryable bool   `json:"retryable"`
}

ErrorDetail is a bounded operator-facing explanation of a Kubernetes error. It never includes provider responses, credentials, endpoints, or raw causes.

func DiagnoseError

func DiagnoseError(err error) ErrorDetail

DiagnoseError classifies connector failures without exposing their raw cause.

type EventOptions

type EventOptions struct {
	Namespace string
	Type      string
	Kind      string
	Name      string
	UID       string
	Continue  string
	Cursor    string
	Limit     int
}

EventOptions is the server-owned object event filter contract.

type EventPage added in v1.4.29

type EventPage struct {
	Items            []ProjectedResource `json:"items"`
	Next             string              `json:"next,omitempty"`
	Truncated        bool                `json:"truncated"`
	Partial          []PartialFailure    `json:"partial_failures,omitempty"`
	EncodedTruncated bool                `json:"-"`
	Omitted          []string            `json:"-"`
}

type GitOpsApp added in v1.4.29

type GitOpsApp struct {
	Tool       string    `json:"tool"`
	Kind       string    `json:"kind"`
	Namespace  string    `json:"namespace"`
	Name       string    `json:"name"`
	Sync       string    `json:"sync"`
	Health     string    `json:"health"`
	Revision   string    `json:"revision,omitempty"`
	LastSyncAt time.Time `json:"last_sync_at,omitempty"`
	Message    string    `json:"message,omitempty"`
	Source     string    `json:"source,omitempty"`
	Suspended  bool      `json:"suspended"`
}

type GitOpsAppOptions added in v1.4.29

type GitOpsAppOptions struct {
	Namespace string
	Tool      string
	Status    string
	Limit     int
	Cursor    string
}

type GitOpsAppPage added in v1.4.29

type GitOpsAppPage struct {
	Items     []GitOpsApp      `json:"items"`
	Available bool             `json:"available"`
	Reason    string           `json:"reason,omitempty"`
	Next      string           `json:"next,omitempty"`
	Partial   []PartialFailure `json:"partial_failures,omitempty"`
	Truncated bool             `json:"truncated"`
}

type GraphQuery added in v1.4.29

type GraphQuery struct {
	Namespace     string
	GroupBy       string
	MaxNodes      int
	ConnectedOnly bool
	Complete      bool
	Limit         int
	Cursor        string
	// contains filtered or unexported fields
}

type HelmRelease added in v1.4.29

type HelmRelease struct {
	Namespace string         `json:"namespace"`
	Name      string         `json:"name"`
	Current   HelmRevision   `json:"current"`
	History   []HelmRevision `json:"history"`
	Health    string         `json:"health"`
}

type HelmReleaseOptions added in v1.4.29

type HelmReleaseOptions struct {
	Namespace string
	Status    string
	Limit     int
	Cursor    string
}

type HelmReleasePage added in v1.4.29

type HelmReleasePage struct {
	Items     []HelmRelease    `json:"items"`
	Next      string           `json:"next,omitempty"`
	Truncated bool             `json:"truncated"`
	Partial   []PartialFailure `json:"partial_failures,omitempty"`
}

type HelmRevision added in v1.4.29

type HelmRevision struct {
	Revision int       `json:"revision"`
	Status   string    `json:"status"`
	Created  time.Time `json:"created,omitempty"`
}

type Issue added in v1.4.29

type Issue struct {
	Root      ObjectRef   `json:"root"`
	Rule      string      `json:"rule"`
	Severity  string      `json:"severity"`
	Count     int         `json:"count"`
	Examples  []ObjectRef `json:"examples,omitempty"`
	FirstSeen time.Time   `json:"first_seen,omitempty"`
	LastSeen  time.Time   `json:"last_seen,omitempty"`
}

type IssueOptions added in v1.4.29

type IssueOptions struct {
	Namespace string
	Severity  string
	Kind      string
	Limit     int
	Cursor    string
}

type IssuePage added in v1.4.29

type IssuePage struct {
	Items     []Issue          `json:"items"`
	Totals    map[string]int   `json:"totals"`
	Truncated bool             `json:"truncated"`
	Next      string           `json:"next,omitempty"`
	Partial   []PartialFailure `json:"partial_failures,omitempty"`
	Sync      SyncStatus       `json:"sync"`
}

type ListOptions

type ListOptions struct {
	ResourceID string
	Namespace  string
	Labels     string
	Fields     string
	Continue   string
	Limit      int
}

type MetricsSourceStatus

type MetricsSourceStatus struct {
	Availability string     `json:"availability"`
	Fresh        bool       `json:"fresh"`
	Complete     bool       `json:"complete"`
	Total        int        `json:"total"`
	CPU          string     `json:"cpu,omitempty"`
	Memory       string     `json:"memory,omitempty"`
	ObservedAt   *time.Time `json:"observed_at,omitempty"`
}

MetricsSourceStatus summarizes one Metrics API source before display caps.

type NeighborhoodQuery added in v1.4.29

type NeighborhoodQuery struct {
	ResourceID string
	Kind       string
	Namespace  string
	Name       string
	Hops       int
	MaxNodes   int
}

type ObjectRef

type ObjectRef struct {
	APIVersion string `json:"api_version,omitempty"`
	Kind       string `json:"kind"`
	Namespace  string `json:"namespace,omitempty"`
	Name       string `json:"name"`
	UID        string `json:"uid,omitempty"`
}

type Overview

type Overview struct {
	Connector         string           `json:"connector"`
	ClusterID         string           `json:"cluster_id"`
	ObservedAt        time.Time        `json:"observed_at"`
	Nodes             int              `json:"nodes"`
	ReadyNodes        int              `json:"ready_nodes"`
	Pods              int              `json:"pods"`
	RunningPods       int              `json:"running_pods"`
	Namespaces        int              `json:"namespaces"`
	ActiveNamespaces  int              `json:"active_namespaces"`
	Workloads         int              `json:"workloads"`
	Warnings          int              `json:"warnings"`
	RequestedCPU      string           `json:"requested_cpu,omitempty"`
	LimitedCPU        string           `json:"limited_cpu,omitempty"`
	AllocatableCPU    string           `json:"allocatable_cpu,omitempty"`
	RequestedMemory   string           `json:"requested_memory,omitempty"`
	LimitedMemory     string           `json:"limited_memory,omitempty"`
	AllocatableMemory string           `json:"allocatable_memory,omitempty"`
	UsageCPU          string           `json:"usage_cpu,omitempty"`
	UsageMemory       string           `json:"usage_memory,omitempty"`
	UsageSource       string           `json:"usage_source"`
	MetricsStatus     string           `json:"metrics_status"`
	MetricsObservedAt *time.Time       `json:"metrics_observed_at,omitempty"`
	MetricsFresh      bool             `json:"metrics_fresh"`
	Truncated         bool             `json:"truncated"`
	Omitted           []string         `json:"omitted_categories,omitempty"`
	Partial           []PartialFailure `json:"partial_failures,omitempty"`
	Sync              SyncStatus       `json:"sync"`
}

type PartialFailure

type PartialFailure struct {
	ResourceID   string `json:"resource_id,omitempty"`
	Scope        string `json:"scope,omitempty"`
	GroupVersion string `json:"group_version,omitempty"`
	Class        string `json:"class"`
}

PartialFailure is a bounded failure class with no raw Kubernetes Status text.

type PodLogStreamEvent added in v1.4.30

type PodLogStreamEvent struct {
	Event           string `json:"-"`
	Text            string `json:"text"`
	Container       string `json:"container"`
	Timestamp       string `json:"timestamp,omitempty"`
	Sequence        uint64 `json:"sequence,omitempty"`
	Ordinal         uint64 `json:"ordinal,omitempty"`
	Cursor          string `json:"cursor,omitempty"`
	Reason          string `json:"reason,omitempty"`
	Code            string `json:"code,omitempty"`
	Message         string `json:"message,omitempty"`
	Action          string `json:"action,omitempty"`
	Retryable       bool   `json:"retryable,omitempty"`
	ReplayUncertain bool   `json:"replay_uncertain,omitempty"`
}

type PodLogStreamOptions added in v1.4.30

type PodLogStreamOptions struct {
	Namespace    string
	Pod          string
	Container    string
	SinceSeconds int
	TailLines    int
	Timestamps   bool
	Previous     bool
	Cursor       string
}

type PodLogs

type PodLogs struct {
	ClusterID    string `json:"cluster_id"`
	Namespace    string `json:"namespace"`
	Pod          string `json:"pod"`
	Container    string `json:"container"`
	Previous     bool   `json:"previous"`
	SinceSeconds int    `json:"since_seconds"`
	TailLines    int    `json:"tail_lines"`
	Text         string `json:"text"`
	Truncated    bool   `json:"truncated"`
}

type ProjectedResource

type ProjectedResource struct {
	ResourceID          string            `json:"resource_id"`
	APIVersion          string            `json:"api_version"`
	Kind                string            `json:"kind"`
	Namespace           string            `json:"namespace,omitempty"`
	Name                string            `json:"name"`
	UID                 string            `json:"uid,omitempty"`
	Labels              map[string]string `json:"labels,omitempty"`
	Owners              []ObjectRef       `json:"owners,omitempty"`
	Summary             map[string]any    `json:"summary,omitempty"`
	Conditions          []Condition       `json:"conditions,omitempty"`
	ProjectionTruncated []string          `json:"projection_truncated,omitempty"`
	// contains filtered or unexported fields
}

ProjectedResource is a bounded safe view, never an arbitrary raw object.

type ResourceDefinition

type ResourceDefinition struct {
	ID         string   `json:"resource_id"`
	Group      string   `json:"group,omitempty"`
	Version    string   `json:"version"`
	Resource   string   `json:"resource"`
	Kind       string   `json:"kind"`
	Namespaced bool     `json:"namespaced"`
	Aliases    []string `json:"aliases,omitempty"`
	Verbs      []string `json:"verbs,omitempty"`
	Available  bool     `json:"available"`
	Reason     string   `json:"reason,omitempty"`
}

ResourceDefinition is a server-owned canonical mapping to one API resource.

type ResourceDescription

type ResourceDescription struct {
	Resource    ProjectedResource   `json:"resource"`
	Related     []ObjectRef         `json:"related_resources,omitempty"`
	Events      []ProjectedResource `json:"events,omitempty"`
	Usage       *ResourceUsage      `json:"usage,omitempty"`
	UsageStatus string              `json:"usage_status"`
	Truncated   bool                `json:"truncated"`
	Omitted     []string            `json:"omitted_categories,omitempty"`
	Partial     []PartialFailure    `json:"partial_failures,omitempty"`
}

ResourceDescription adds deterministic diagnostic evidence to one resource.

type ResourcePage

type ResourcePage struct {
	Items            []ProjectedResource `json:"items"`
	Continue         string              `json:"continue,omitempty"`
	Truncated        bool                `json:"truncated"`
	EncodedTruncated bool                `json:"encoded_truncated"`
	Omitted          []string            `json:"omitted_categories,omitempty"`
	Partial          []PartialFailure    `json:"partial_failures,omitempty"`
}

type ResourceUsage

type ResourceUsage struct {
	Kind      string    `json:"kind"`
	Namespace string    `json:"namespace,omitempty"`
	Name      string    `json:"name"`
	Timestamp time.Time `json:"timestamp,omitempty"`
	Window    string    `json:"window,omitempty"`
	CPU       string    `json:"cpu,omitempty"`
	Memory    string    `json:"memory,omitempty"`
}

ResourceUsage is one bounded exact pod or node Metrics API sample.

type Rollout added in v1.4.29

type Rollout struct {
	Namespace  string `json:"namespace"`
	Name       string `json:"name"`
	Phase      string `json:"phase"`
	Strategy   string `json:"strategy,omitempty"`
	Step       int    `json:"step"`
	TotalSteps int    `json:"total_steps"`
	StableRS   string `json:"stable_rs,omitempty"`
	CanaryRS   string `json:"canary_rs,omitempty"`
	Weight     int    `json:"weight,omitempty"`
	Message    string `json:"message,omitempty"`
}

type RolloutListOptions added in v1.4.29

type RolloutListOptions struct {
	Namespace string
	Limit     int
	Cursor    string
}

type RolloutPage added in v1.4.29

type RolloutPage struct {
	Items     []Rollout        `json:"items"`
	Available bool             `json:"available"`
	Reason    string           `json:"reason,omitempty"`
	Next      string           `json:"next,omitempty"`
	Truncated bool             `json:"truncated"`
	Partial   []PartialFailure `json:"partial_failures,omitempty"`
}

type Scope

type Scope struct {
	OrgID        string `json:"org_id,omitempty"`
	ClusterID    string `json:"cluster_id"`
	CredentialID string `json:"-"`
}

Scope isolates cached discovery and reads by organization, cluster, and credential.

type Scrubber

type Scrubber interface{ Scrub(string) string }

Scrubber removes sensitive substrings before text leaves the service.

type SearchOptions

type SearchOptions struct {
	Query        string
	Namespace    string
	Category     string
	Labels       string
	Fields       string
	PerKindLimit int
	TotalLimit   int
}

SearchOptions bounds a true cross-kind name search.

type SearchResult

type SearchResult struct {
	Items         []ProjectedResource `json:"items"`
	Continuations map[string]string   `json:"continuations,omitempty"`
	Requests      int                 `json:"requests"`
	RequestBudget int                 `json:"request_budget"`
	Truncated     bool                `json:"truncated"`
	Omitted       []string            `json:"omitted_categories,omitempty"`
	Partial       []PartialFailure    `json:"partial_failures,omitempty"`
}

SearchResult contains ranked projected matches and explicit incomplete evidence.

type Service

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

Service owns all Kubernetes path construction, decoding, projection, and relationships.

func NewService

func NewService(client *Client, scope Scope, discoveryTTL time.Duration) *Service

NewService constructs a scoped read-only Kubernetes application service.

func (*Service) Changes added in v1.4.29

func (service *Service) Changes(ctx context.Context, query ChangeQuery) (ChangePage, error)

Changes returns the bounded timeline for the service's org/cluster scope.

func (*Service) Describe

func (service *Service) Describe(ctx context.Context, resourceID, namespace, name string) (ResourceDescription, error)

Describe returns one resource with deterministic owners and object-scoped events.

func (*Service) DiagnoseWorkload added in v1.4.29

func (service *Service) DiagnoseWorkload(ctx context.Context, options DiagnoseOptions) (Diagnosis, error)

DiagnoseWorkload combines bounded workload, warning-event and scrubbed log evidence.

func (*Service) Discover

func (service *Service) Discover(ctx context.Context) (Discovery, error)

Discover builds a preferred-version resource registry with partial failures.

func (*Service) Get

func (service *Service) Get(ctx context.Context, resourceID, namespace, name string) (ProjectedResource, error)

Get reads and safely projects one discovered Kubernetes resource.

func (*Service) GetWorkload

func (service *Service) GetWorkload(ctx context.Context, namespace, kind, name string) (WorkloadDetail, error)

GetWorkload returns bounded workload state plus deterministic related resources.

func (*Service) GitOpsApps added in v1.4.29

func (service *Service) GitOpsApps(ctx context.Context, options GitOpsAppOptions) (GitOpsAppPage, error)

GitOpsApps lists only discovered GitOps APIs and safely projected status.

func (*Service) Graph added in v1.4.29

func (service *Service) Graph(ctx context.Context, query GraphQuery) (kubegraph.Graph, error)

Graph builds a bounded topology graph from the shared projected index.

func (*Service) IndexSnapshot added in v1.4.29

func (service *Service) IndexSnapshot(ctx context.Context, kinds ...string) (kubeindex.Snapshot, kubeindex.Status, error)

IndexSnapshot polls requested kinds within the normal operation budget and returns the shared last-good view plus its per-kind freshness state.

func (*Service) InvalidateDiscovery

func (service *Service) InvalidateDiscovery()

InvalidateDiscovery expires only this service's scoped discovery generation.

func (*Service) Issues added in v1.4.29

func (service *Service) Issues(ctx context.Context, options IssueOptions) (IssuePage, error)

Issues returns bounded findings from projected cluster resources.

func (*Service) List

func (service *Service) List(ctx context.Context, options ListOptions) (ResourcePage, error)

List reads one discovered resource page and safely projects every item.

func (*Service) ListEvents

func (service *Service) ListEvents(ctx context.Context, options EventOptions) (EventPage, error)

ListEvents lists events using server-authored field selectors only.

func (*Service) ListWorkloads

func (service *Service) ListWorkloads(ctx context.Context, namespace, kind string, limit int) (WorkloadPage, error)

ListWorkloads aggregates every supported workload kind or one validated kind.

func (*Service) Neighborhood added in v1.4.29

func (service *Service) Neighborhood(ctx context.Context, query NeighborhoodQuery) (kubegraph.Graph, error)

Neighborhood returns a capped BFS slice from the same shared graph view.

func (*Service) Overview

func (service *Service) Overview(ctx context.Context) (Overview, error)

func (*Service) OverviewGraph added in v1.4.29

func (service *Service) OverviewGraph(ctx context.Context) (kubegraph.Graph, error)

func (*Service) PodLogs

func (service *Service) PodLogs(ctx context.Context, namespace, pod, container string, previous bool, sinceSeconds, tailLines int) (PodLogs, error)

PodLogs reads one bounded pod log stream, optionally selecting a container.

func (*Service) Release added in v1.4.29

func (service *Service) Release(ctx context.Context, namespace, name string) (HelmRelease, error)

Release returns one label-only Helm release and its bounded revision history.

func (*Service) Releases added in v1.4.29

func (service *Service) Releases(ctx context.Context, options HelmReleaseOptions) (HelmReleasePage, error)

Releases reads Helm revision labels from PartialObjectMetadata only.

func (*Service) Rollout added in v1.4.29

func (service *Service) Rollout(ctx context.Context, namespace, name string) (Rollout, error)

Rollout returns one safely projected Argo Rollouts status record.

func (*Service) Rollouts added in v1.4.29

func (service *Service) Rollouts(ctx context.Context, options RolloutListOptions) (RolloutPage, error)

Rollouts lists discovered Argo Rollouts using the same projection as Rollout.

func (*Service) Scope

func (service *Service) Scope() Scope

Scope returns the immutable cache and request identity of this service.

func (*Service) Scoped

func (service *Service) Scoped(scope Scope) *Service

Scoped returns a service for another org/cluster/credential that shares the transport and keyed discovery cache with the original service.

func (*Service) Search

func (service *Service) Search(ctx context.Context, options SearchOptions) (SearchResult, error)

Search searches names across discovered readable kinds with per-kind and total budgets.

func (*Service) SetChangeStorage added in v1.4.29

func (service *Service) SetChangeStorage(provider storage.Provider)

SetChangeStorage installs the shared persistence provider for scoped timelines.

func (*Service) SetLogStreamContext added in v1.4.30

func (service *Service) SetLogStreamContext(ctx context.Context)

func (*Service) SetScrubber

func (service *Service) SetScrubber(scrubber Scrubber)

SetScrubber installs the shared model/API text redactor.

func (*Service) SetTrafficContributor added in v1.4.29

func (service *Service) SetTrafficContributor(provider TrafficContributor)

SetTrafficContributor installs an optional traffic reader without coupling the OSS Kubernetes service to any particular telemetry implementation.

func (*Service) StreamPodLogs added in v1.4.30

func (service *Service) StreamPodLogs(ctx context.Context, options PodLogStreamOptions, emit func(PodLogStreamEvent) error) error

func (*Service) SubscribeIndex added in v1.4.29

func (service *Service) SubscribeIndex(ctx context.Context, buffer int, kinds ...string) (<-chan kubeindex.Delta, func(), kubeindex.Status, error)

SubscribeIndex primes the shared index, then subscribes to its bounded deltas.

func (*Service) Top added in v1.4.29

func (service *Service) Top(ctx context.Context, options TopOptions) (TopPage, error)

Top returns the highest-usage pods or nodes from the Metrics API.

func (*Service) Traffic added in v1.4.29

func (service *Service) Traffic(ctx context.Context, query TrafficQuery) (Traffic, error)

func (*Service) Usage

func (service *Service) Usage(ctx context.Context, namespace string, limit int) (Usage, error)

Usage returns bounded pod and node Metrics API samples with freshness metadata.

func (*Service) ValidatePodLogStream added in v1.4.30

func (service *Service) ValidatePodLogStream(options PodLogStreamOptions) error

func (*Service) WorkloadLogs added in v1.4.29

func (service *Service) WorkloadLogs(ctx context.Context, options WorkloadLogOptions) (WorkloadLogs, error)

func (*Service) Workloads added in v1.4.29

func (service *Service) Workloads(ctx context.Context, options WorkloadListOptions) (WorkloadPage, error)

Workloads lists one stable page of supported workload projections.

type ServiceRegistry

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

ServiceRegistry resolves one shared service instance per org, cluster, and credential.

func NewServiceRegistry

func NewServiceRegistry(base *Service) *ServiceRegistry

func (*ServiceRegistry) Resolve

func (registry *ServiceRegistry) Resolve(scope Scope) *Service

func (*ServiceRegistry) ResolveOrg

func (registry *ServiceRegistry) ResolveOrg(orgID string) *Service

ResolveOrg inherits the configured cluster and credential while changing org scope.

type SyncStatus added in v1.4.29

type SyncStatus struct {
	State      string  `json:"state"`
	AgeSeconds float64 `json:"age_s"`
	Partial    bool    `json:"partial"`
}

type TopItem added in v1.4.29

type TopItem struct {
	ResourceUsage
	RequestCPU    string     `json:"request_cpu,omitempty"`
	RequestMemory string     `json:"request_memory,omitempty"`
	Owner         *ObjectRef `json:"owner,omitempty"`
}

type TopOptions added in v1.4.29

type TopOptions struct {
	Kind      string
	Namespace string
	Sort      string
	Limit     int
}

type TopPage added in v1.4.29

type TopPage struct {
	Items        []TopItem        `json:"items"`
	Total        int              `json:"total"`
	Truncated    bool             `json:"truncated"`
	Availability string           `json:"availability"`
	Fresh        bool             `json:"fresh"`
	Partial      []PartialFailure `json:"partial_failures,omitempty"`
	Sync         SyncStatus       `json:"sync"`
}

type Traffic added in v1.4.29

type Traffic struct {
	Available  bool          `json:"available"`
	Reason     string        `json:"reason,omitempty"`
	Source     string        `json:"source,omitempty"`
	Window     string        `json:"window"`
	ObservedAt time.Time     `json:"observed_at,omitempty"`
	Edges      []TrafficEdge `json:"edges,omitempty"`
	Unmapped   int           `json:"unmapped"`
	External   []string      `json:"external,omitempty"`
	Truncated  bool          `json:"truncated"`
}

type TrafficContributor added in v1.4.29

type TrafficContributor interface {
	ReadTraffic(context.Context, TrafficQuery) (Traffic, error)
}

type TrafficEdge added in v1.4.29

type TrafficEdge struct {
	From        TrafficWorkload `json:"from"`
	To          TrafficWorkload `json:"to"`
	RatePerSec  *float64        `json:"rate_per_sec"`
	ErrorRate   *float64        `json:"error_rate"`
	P95Ms       *float64        `json:"p95_ms"`
	BytesPerSec *float64        `json:"bytes_per_sec"`
}

TrafficEdge leaves unavailable measurements nil so they serialize as null.

type TrafficQuery added in v1.4.29

type TrafficQuery struct {
	Namespace string
	Source    string
	Window    string
}

type TrafficWorkload added in v1.4.29

type TrafficWorkload struct {
	Namespace string `json:"namespace"`
	Kind      string `json:"kind"`
	Name      string `json:"name"`
}

type Usage

type Usage struct {
	ObservedAt   time.Time           `json:"observed_at"`
	Availability string              `json:"availability"`
	Fresh        bool                `json:"fresh"`
	PodMetrics   MetricsSourceStatus `json:"pod_metrics"`
	NodeMetrics  MetricsSourceStatus `json:"node_metrics"`
	Pods         []ResourceUsage     `json:"pods,omitempty"`
	Nodes        []ResourceUsage     `json:"nodes,omitempty"`
	Truncated    bool                `json:"truncated"`
	Omitted      []string            `json:"omitted_categories,omitempty"`
	Partial      []PartialFailure    `json:"partial_failures,omitempty"`
}

Usage reports Metrics API availability separately from an empty metric set.

type WorkloadContainer

type WorkloadContainer struct {
	Name     string            `json:"name"`
	Image    string            `json:"image,omitempty"`
	Probes   []string          `json:"probes,omitempty"`
	Requests map[string]string `json:"requests,omitempty"`
	Limits   map[string]string `json:"limits,omitempty"`
}

WorkloadContainer is the bounded operational view of one workload container.

type WorkloadDetail

type WorkloadDetail struct {
	ResourceID         string              `json:"resource_id"`
	Kind               string              `json:"kind"`
	Namespace          string              `json:"namespace,omitempty"`
	Name               string              `json:"name"`
	Desired            *int64              `json:"desired,omitempty"`
	Current            *int64              `json:"current,omitempty"`
	Ready              *int64              `json:"ready,omitempty"`
	Available          *int64              `json:"available,omitempty"`
	Unavailable        *int64              `json:"unavailable,omitempty"`
	Succeeded          *int64              `json:"succeeded,omitempty"`
	Failed             *int64              `json:"failed,omitempty"`
	Active             *int64              `json:"active,omitempty"`
	Generation         *int64              `json:"generation,omitempty"`
	ObservedGeneration *int64              `json:"observed_generation,omitempty"`
	UpdateStrategy     string              `json:"update_strategy,omitempty"`
	Conditions         []Condition         `json:"conditions,omitempty"`
	Containers         []WorkloadContainer `json:"containers,omitempty"`
	Pods               []WorkloadPod       `json:"pods,omitempty"`
	Nodes              []string            `json:"nodes,omitempty"`
	NodeSelector       map[string]string   `json:"node_selector,omitempty"`
	Affinity           []string            `json:"affinity,omitempty"`
	TopologySpread     []string            `json:"topology_spread,omitempty"`
	TerminationGrace   *int64              `json:"termination_grace_seconds,omitempty"`
	HPAs               []ObjectRef         `json:"hpas,omitempty"`
	PDBs               []ObjectRef         `json:"pdbs,omitempty"`
	Usage              []ResourceUsage     `json:"usage,omitempty"`
	Truncated          bool                `json:"truncated"`
	Omitted            []string            `json:"omitted_categories,omitempty"`
	Partial            []PartialFailure    `json:"partial_failures,omitempty"`
}

WorkloadDetail is a dedicated bounded SRE view, not a generic resource projection.

type WorkloadListOptions added in v1.4.29

type WorkloadListOptions struct {
	Namespace string
	Kind      string
	Query     string
	Limit     int
	Cursor    string
}

type WorkloadLogLine added in v1.4.29

type WorkloadLogLine struct {
	Pod       string    `json:"pod"`
	Container string    `json:"container,omitempty"`
	At        time.Time `json:"at,omitempty"`
	Text      string    `json:"text"`
}

type WorkloadLogOptions added in v1.4.29

type WorkloadLogOptions struct {
	Namespace    string
	Kind         string
	Name         string
	Pod          string
	Container    string
	Previous     bool
	SinceSeconds int
	TailLines    int
	Grep         string
	MaxPods      int
}

type WorkloadLogs added in v1.4.29

type WorkloadLogs struct {
	Pods        []string          `json:"pods"`
	Lines       []WorkloadLogLine `json:"lines"`
	Truncated   bool              `json:"truncated"`
	OmittedPods []string          `json:"omitted_pods"`
	Partial     []PartialFailure  `json:"partial_failures,omitempty"`
}

type WorkloadPage

type WorkloadPage struct {
	Items     []ProjectedResource `json:"items"`
	Counts    map[string]int      `json:"counts,omitempty"`
	Next      string              `json:"next,omitempty"`
	Truncated bool                `json:"truncated"`
	Omitted   []string            `json:"omitted_categories,omitempty"`
	Partial   []PartialFailure    `json:"partial_failures,omitempty"`
}

WorkloadPage aggregates the supported workload kinds.

type WorkloadPod

type WorkloadPod struct {
	Name         string    `json:"name"`
	Phase        string    `json:"phase,omitempty"`
	Node         string    `json:"node,omitempty"`
	RestartCount int64     `json:"restart_count"`
	CreatedAt    time.Time `json:"created_at,omitempty"`
}

WorkloadPod captures status and placement for one related pod.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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