Documentation
¶
Overview ¶
pkg/kordinator/gateway_handlers.go
HTTP handlers served by the gateway process at /katalog and /katalog/{crd}.
The gateway /katalog response carries the same per-CRD shape as the runtime /katalog response but only populates the fields the gateway owns: admission, conversion, deletion-protection, and namespace-protection stats. Reconciler health fields (workers, queue depth, error rate, etc.) are omitted.
Control center merge strategy ────────────────────────────── The runtime /katalog response includes a "gatewayEndpoint" field. The control center reads that URL, fetches the gateway /katalog, then merges per-CRD by GVR string ("group/version/resource") — the canonical key used by both processes. Neither process pushes to the other; each is independently queryable.
Index ¶
- func BuildGatewayCRDHandler(name, gvk, gvrStr, gvrKey string, ws GatewayStatsProvider, ...) http.HandlerFunc
- func BuildGatewayKatalogHandler(kat *katalog.Katalog, ws GatewayStatsProvider) http.HandlerFunc
- func BuildNotifyHandler(kat *katalog.Katalog) http.HandlerFunc
- type AdmissionStatsResponse
- type ConversionStatsResponse
- type DeletionProtectionStatsResponse
- type GatewayCRDStatsResponse
- type GatewayKatalogResponse
- type GatewayStatsProvider
- type HousekeeperStats
- type NamespaceProtectionResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildGatewayCRDHandler ¶
func BuildGatewayCRDHandler(name, gvk, gvrStr, gvrKey string, ws GatewayStatsProvider, kat *katalog.Katalog) http.HandlerFunc
BuildGatewayCRDHandler returns the handler for GET /katalog/{crd} on the gateway. name, gvk, gvrStr, and gvrKey are derived from the CRDEntry at registration time.
func BuildGatewayKatalogHandler ¶
func BuildGatewayKatalogHandler(kat *katalog.Katalog, ws GatewayStatsProvider) http.HandlerFunc
BuildGatewayKatalogHandler returns the handler for GET /katalog on the gateway. It iterates the enabled CRDs from the Katalog, looks up per-CRD stats from ws, and returns a GatewayKatalogResponse.
func BuildNotifyHandler ¶
func BuildNotifyHandler(kat *katalog.Katalog) http.HandlerFunc
BuildNotifyHandler returns an http.HandlerFunc that receives a notification Event from the runtime and dispatches it to the configured team channels.
The gateway is the single point for SMTP/Slack dispatch — the runtime only POSTs pre-built events after its own throttle check.
Types ¶
type AdmissionStatsResponse ¶
type AdmissionStatsResponse struct {
WebhooksEnabled bool `json:"webhooksEnabled"`
ValidationTotal int64 `json:"validationTotal"`
ValidationAllowed int64 `json:"validationAllowed"`
ValidationDenied int64 `json:"validationDenied"`
ValidationWarned int64 `json:"validationWarned"`
ValAvgLatencyMs float64 `json:"valAvgLatencyMs"`
ValP95LatencyMs float64 `json:"valP95LatencyMs"`
ValMaxLatencyMs float64 `json:"valMaxLatencyMs"`
MutationTotal int64 `json:"mutationTotal"`
MutationApplied int64 `json:"mutationApplied"`
MutationSkipped int64 `json:"mutationSkipped"`
MutAvgLatencyMs float64 `json:"mutAvgLatencyMs"`
MutP95LatencyMs float64 `json:"mutP95LatencyMs"`
MutMaxLatencyMs float64 `json:"mutMaxLatencyMs"`
}
type ConversionStatsResponse ¶
type GatewayCRDStatsResponse ¶
type GatewayCRDStatsResponse struct {
Name string `json:"name"`
GVK string `json:"gvk"`
GVR string `json:"gvr"` // merge key: "group/version/resource"
Admission *AdmissionStatsResponse `json:"admission,omitempty"`
Conversion *ConversionStatsResponse `json:"conversion,omitempty"`
DeletionProtection *DeletionProtectionStatsResponse `json:"deletionProtection,omitempty"`
NamespaceProtection *NamespaceProtectionResponse `json:"namespaceProtection,omitempty"`
}
GatewayCRDStatsResponse holds the gateway-owned stats for one CRD. The GVR field is the merge key used by the control center.
type GatewayKatalogResponse ¶
type GatewayKatalogResponse struct {
Source string `json:"source"` // always "gateway"
Name string `json:"name"`
Version string `json:"version,omitempty"`
// Security feature flags — mirrors Katalog configuration.
AdmissionEnabled bool `json:"admissionEnabled"`
ConversionEnabled bool `json:"conversionEnabled"`
DeletionProtectionEnabled bool `json:"deletionProtectionEnabled"`
NamespaceProtectionEnabled bool `json:"namespaceProtectionEnabled"`
StrictModeEnabled bool `json:"strictModeEnabled"`
// Per-CRD stats — only gateway-owned fields populated.
CRDs []GatewayCRDStatsResponse `json:"crds"`
// Process-level stats for events not attributable to a single CRD:
// the webhook configuration itself and Orkestra infra resources.
InfraProtection *DeletionProtectionStatsResponse `json:"infraProtection,omitempty"`
Housekeeper *HousekeeperStats `json:"housekeeper,omitempty"`
GatewayVersion string `json:"gatewayVersion"`
}
GatewayKatalogResponse is served at GET /katalog by the gateway process. It mirrors the top-level shape of KatalogResponse so control-center clients can pattern-match on the "source" field and merge stats by GVR key.
type GatewayStatsProvider ¶
type GatewayStatsProvider interface {
AdmissionStatsFor(gvrKey string) *health.AdmissionStats
ConversionStatsFor(gvrKey string) *health.ConversionStats
ProtectionStatsFor(gvrKey string) *health.DeletionProtectionStats
NamespaceStatsFor(gvrKey string) *health.NamespaceProtectionStats
InfraProtectionStats() *health.DeletionProtectionStats
HousekeeperStats() *health.WebhookStats
}
GatewayStatsProvider is the subset of webhook.WebhookServer that the gateway /katalog handlers need. Defined here so pkg/kordinator does not import pkg/webhook (which would create a cycle).
type HousekeeperStats ¶
type NamespaceProtectionResponse ¶
type NamespaceProtectionResponse struct {
Enabled bool `json:"enabled"`
HasNamespaceRules bool `json:"hasNamespaceRules"`
Total int64 `json:"total"`
Blocked int64 `json:"blocked"`
Allowed int64 `json:"allowed"`
AllowedNamespaces []string `json:"allowedNamespaces,omitempty"`
RestrictedNamespaces []string `json:"restrictedNamespaces,omitempty"`
}