kinds

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package kinds describes the Kubernetes resource kinds the UI understands and resolves which of them the cluster actually serves.

A downstream ListenerSet kind registers with CategoryListenerSet and must have the upstream shape the explorer reads: spec.parentRef (the Gateway), spec.listeners[] and status.listeners[].

Index

Constants

View Source
const KgatewayGroup = kgwGroup

KgatewayGroup is the API group of kgateway's own CRDs.

Variables

This section is empty.

Functions

func ExperimentalOnly

func ExperimentalOnly(group, kind, version, controller string) bool

ExperimentalOnly reports whether a kgateway controller at version controller watches group/kind at version only with experimental Gateway API features on. An unknown or unparsable controller version counts a kind as experimental-only when any supported minor gates it (D-018 §3).

Types

type Catalog

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

Catalog is every (group, kind) the API server serves, from discovery. The zero Catalog knows no group: every served state is unknown.

func NewCatalog

func NewCatalog(served []schema.GroupKind, unknown []string) Catalog

NewCatalog returns the Catalog of served kinds, where discovery failed for the unknown groups.

func (Catalog) Complete

func (c Catalog) Complete() bool

Complete reports whether discovery listed every group, so GroupsWithKind names every group that serves a kind.

func (Catalog) GroupsWithKind

func (c Catalog) GroupsWithKind(kind string) []string

GroupsWithKind returns the groups that serve kind, sorted.

func (Catalog) Key

func (c Catalog) Key() string

Key identifies the Catalog's contents; equal catalogs have equal keys.

func (Catalog) Known

func (c Catalog) Known(group string) bool

Known reports whether discovery listed group completely, so a kind it lacks is known not to be served. A group discovery never listed is known.

func (Catalog) Served

func (c Catalog) Served(group, kind string) bool

Served reports whether group serves kind.

type Category

type Category string

Category groups kinds by the role they play in the UI.

const (
	CategoryGatewayClass Category = "gatewayclass"
	CategoryGateway      Category = "gateway"
	CategoryListenerSet  Category = "listenerset"
	CategoryRoute        Category = "route"
	CategoryPolicy       Category = "policy"
	// CategoryWorkload marks kinds read through typed informers (Deployments).
	// They are never watched dynamically or counted; findings link to them.
	CategoryWorkload Category = "workload"
	// CategoryParameters marks kinds read only to resolve other objects
	// (GatewayParameters). They are watched but never counted or attributed.
	CategoryParameters Category = "parameters"
	// CategoryBackend marks kgateway Backends: route targets the explorer
	// shows. They are neither attributed to Gateways nor counted by the
	// controller's managed-resource gauge.
	CategoryBackend Category = "backend"
	// CategoryReferenceGrant marks ReferenceGrants: listed and shown, never
	// evaluated to decide whether a reference resolves.
	CategoryReferenceGrant Category = "referencegrant"
)

Categories understood by the UI.

type Change

type Change struct {
	Added           []string `json:"added,omitempty"`
	Removed         []string `json:"removed,omitempty"`
	ListOnlyAdded   []string `json:"listOnlyAdded,omitempty"`
	ListOnlyRemoved []string `json:"listOnlyRemoved,omitempty"`
}

Change is how the kinds the cluster serves now differ from the watched kinds. Entries are "resource.group/version" ("resource/version" for the core group), sorted. Added and Removed are judged kinds; list-only kinds (Descriptor.ListOnly) have their own fields.

func Diff

func Diff(watched, now []Served) Change

Diff compares the served kinds now with the watched ones by group, version and resource.

func (Change) Empty

func (c Change) Empty() bool

Empty reports whether the served kinds match the watched kinds.

func (Change) Judged

func (c Change) Judged() bool

Judged reports whether a judged kind changed; a list-only change alone is not one.

func (Change) ListOnly

func (c Change) ListOnly() string

ListOnly returns c's list-only half as "added a; removed b".

func (Change) String

func (c Change) String() string

String returns "added a, b; removed c", omitting an empty half; list-only changes follow as "list-only added d; list-only removed e".

type Descriptor

type Descriptor struct {
	Group       string   `json:"group"`
	Kind        string   `json:"kind"`
	Resource    string   `json:"resource"`
	Versions    []string `json:"versions"`
	Namespaced  bool     `json:"namespaced"`
	Category    Category `json:"category"`
	DisplayName string   `json:"displayName"`
	// ListOnly kinds are listed and shown per install scope, never judged for
	// status. Their access is optional for the cluster access check.
	ListOnly bool `json:"-"`
}

Descriptor describes a kind the UI can watch. Versions are in preference order.

func Dedupe

func Dedupe(descs []Descriptor) []Descriptor

Dedupe returns descs with one descriptor per group and kind: a later descriptor replaces an earlier one in the earlier one's position.

func GatewayAPI added in v0.6.0

func GatewayAPI() []Descriptor

GatewayAPI returns the Gateway API kinds of Upstream, in its order: the kinds the core registers without any pack.

func Upstream

func Upstream() []Descriptor

Upstream returns the kinds of Gateway API and kgateway that the UI understands: GatewayAPI plus kgateway's own kinds, in the API v1 order. Secrets and ConfigMaps are deliberately absent (design §11).

type DiscoveryClient

type DiscoveryClient interface {
	ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error)
}

DiscoveryClient is the subset of the discovery API that Resolve needs.

type Monitor

type Monitor struct {

	// OnChange, if set, is notified when a Refresh yields a Change or Catalog that
	// differs from the previous one.
	OnChange *trigger.Signal
	// contains filtered or unexported fields
}

Monitor re-resolves the served kinds and keeps how they differ from the watched set. The UI does not re-watch: a change asks for a restart. It also publishes the Catalog of every served kind.

func NewMonitor

func NewMonitor(dc DiscoveryClient, descs []Descriptor, watched []Served) *Monitor

NewMonitor returns a Monitor of descs against watched, the kinds the cache watches.

func (*Monitor) Catalog

func (m *Monitor) Catalog() Catalog

Catalog returns the latest Catalog; it is the zero Catalog until a Refresh lists one.

func (*Monitor) Change

func (m *Monitor) Change() Change

Change returns the latest difference; it is empty until a Refresh finds one.

func (*Monitor) Refresh

func (m *Monitor) Refresh() error

Refresh resolves the served kinds and the Catalog once. On error the last Change is kept; a Catalog that cannot be listed keeps the last one.

func (*Monitor) Run

func (m *Monitor) Run(ctx context.Context, every time.Duration)

Run refreshes every interval until ctx is done.

type Served

type Served struct {
	Descriptor
	Version string `json:"version"`
}

Served is a Descriptor resolved to the version the cluster serves.

func ByCategory

func ByCategory(served []Served, c Category) []Served

ByCategory returns the served kinds in category c.

func Resolve

func Resolve(dc DiscoveryClient, descs []Descriptor) ([]Served, error)

Resolve returns, in input order, the descriptors whose resource is served in one of their versions, resolved to the first such version. Kinds that are not served (CRD not installed, or removed in this kgateway version) are omitted. Duplicates are removed as by Dedupe.

func (Served) ExperimentalOnly

func (s Served) ExperimentalOnly(controller string) bool

ExperimentalOnly reports whether a kgateway controller at version controller watches s, at its served version, only with experimental Gateway API features on.

func (Served) GVR

GVR returns the group/version/resource used to watch this kind.

Jump to

Keyboard shortcuts

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