Documentation
¶
Overview ¶
health/admission_evaluation.go
health/admission_handlers.go
health/admission_review.go
health/admission_stats.go
health/conversion.go
health/conversion_logic.go
pkg/health/conversion_stats.go
health/deletion_protection_handler.go
/deletion-protection webhook handler.
Registered only when security.deletionProtection.enabled: true in the Katalog. Separate from /validate — different semantics, different failure policy (Fail vs Ignore).
Intercepts DELETE operations on:
- customresourcedefinitions owned by this operator
- the Orkestra deployment itself
All other resources and operations are allowed immediately.
failurePolicy: Fail — if Orkestra is unreachable, DELETE is blocked. This is intentional: a down Orkestra means protection is still active. To decommission: set deletionProtection.enabled: false, redeploy, then delete.
pkg/health/protection_stats.go
pkg/health/handlers.go
health/namespace_protection_handler.go
/namespace-protection webhook handler.
Registered only when security.namespaceProtection.enabled: true in the Katalog. Separate from /validate — different semantics, different failure policy.
Intercepts CREATE and UPDATE operations on CRDs that declare namespace rules (allowedNamespaces or restrictedNamespaces). The webhook rules filter by GVR; the handler performs the namespace check.
failurePolicy: Fail — if Orkestra is unreachable, CREATE/UPDATE is blocked. This ensures namespace rules remain enforced even during transient outages.
pkg/health/namespace_protection_stats.go
NamespaceProtectionStats tracks counters for the /namespace-protection webhook. Distinct from DeletionProtectionStats (deletion protection) — different admission operations, different semantics. Deletion protection intercepts DELETE; namespace protection intercepts CREATE and UPDATE.
pkg/health/provider_stats.go
pkg/health/webhook_controller.go
health/webhook_registration.go
pkg/health/webhook_stats.go
Index ¶
- Variables
- func RegisterWebhooks(ctx context.Context, client kubernetes.Interface, ...) error
- func UnregisterWebhooks(ctx context.Context, client kubernetes.Interface, opts WebhookCleanupOptions) error
- type AdmissionRequest
- type AdmissionResponse
- type AdmissionReview
- type AdmissionStats
- func (s *AdmissionStats) GetStats(webhooksEnabled bool) AdmissionStatsSnapshot
- func (s *AdmissionStats) RecordMutationApplied(duration time.Duration)
- func (s *AdmissionStats) RecordMutationSkipped(duration time.Duration)
- func (s *AdmissionStats) RecordValidationAllowed(duration time.Duration)
- func (s *AdmissionStats) RecordValidationDenied(duration time.Duration)
- func (s *AdmissionStats) RecordValidationWarned(duration time.Duration)
- type AdmissionStatsSnapshot
- type AdmissionStatus
- type ConversionReview
- type ConversionReviewRequest
- type ConversionReviewResponse
- type ConversionStats
- type ConversionStatsSnapshot
- type DeletionProtectionStats
- type DeletionProtectionStatsSnapshot
- type HealthServer
- func (h *HealthServer) Degraded()
- func (h *HealthServer) EnableConversion(certFile, keyFile string)
- func (h *HealthServer) EnableWebhooks(certFile, keyFile string)
- func (h *HealthServer) GetAdmissionStats() *AdmissionStats
- func (h *HealthServer) GetConversionStats() *ConversionStats
- func (h *HealthServer) GetNamespaceStats() *NamespaceProtectionStats
- func (h *HealthServer) GetProtectionStats() *DeletionProtectionStats
- func (h *HealthServer) GetWebhookStats() *WebhookStats
- func (h *HealthServer) Healthy() bool
- func (h *HealthServer) Name() string
- func (h *HealthServer) Ready() bool
- func (hs *HealthServer) Register(path string, handler http.HandlerFunc)
- func (h *HealthServer) SetAdmissionRegistry(r katalog.AdmissionRegistry)
- func (h *HealthServer) SetKubeClient(c kubernetes.Interface)
- func (h *HealthServer) SetReady()
- func (h *HealthServer) SetStarted()
- func (h *HealthServer) SetStartupComplete()
- func (h *HealthServer) SetWebhookOpts(opts WebhookRegistrationOptions)
- func (h *HealthServer) Shutdown(ctx context.Context)
- func (h *HealthServer) Start(ctx context.Context) error
- func (h *HealthServer) Started() bool
- func (h *HealthServer) StartupComplete() bool
- func (h *HealthServer) Unhealthy()
- func (h *HealthServer) Uptime() string
- type JSONPatchOp
- type NamespaceProtectionStats
- type NamespaceProtectionStatsSnapshot
- type NamespaceRules
- type ProviderStatEntry
- type ProviderStats
- type Status
- type WebhookCleanupOptions
- type WebhookConfgurationOptions
- type WebhookRegistrationOptions
- type WebhookStats
- type WebhookStatsSnapshot
Constants ¶
This section is empty.
Variables ¶
var ( ExportedApplyConversion = applyConversion ExportRegisterWebhooks = RegisterWebhooks ExportUnregisterWebhooks = UnregisterWebhooks ExportApplyValidatingWebhook = applyWebhookConfig ExportApplyMutatingWebhook = applyMutatingWebhookConfig ExportCleanupValidatingWebhook = cleanupValidatingWebhook ExportCleanupMutatingWebhook = cleanupMutatingWebhook )
Export internal functions for integration tests only.
Functions ¶
func RegisterWebhooks ¶
func RegisterWebhooks( ctx context.Context, client kubernetes.Interface, registry admissionRegistryReader, opts WebhookRegistrationOptions, ) error
RegisterWebhooks creates or updates the ValidatingWebhookConfiguration and MutatingWebhookConfiguration based on the current admission registry.
Called from HealthServer.Start() when ENABLE_ADMISSION_WEBHOOK=true, after the Katalog is fully loaded and the admission registry is populated.
The function is idempotent — safe to call on restart. Existing configurations are updated to match the current Katalog state. CRDs removed from the Katalog are removed from the webhook configuration.
func UnregisterWebhooks ¶
func UnregisterWebhooks( ctx context.Context, client kubernetes.Interface, opts WebhookCleanupOptions, ) error
Types ¶
type AdmissionRequest ¶
type AdmissionRequest struct {
// UID — must be echoed verbatim in the Response.UID.
// The API server uses this to correlate requests and responses.
UID string `json:"uid"`
// Kind — the GVK of the object being admitted.
Kind metav1.GroupVersionKind `json:"kind"`
// Resource — the GVR of the object being admitted.
Resource metav1.GroupVersionResource `json:"resource"`
// Name — the name of the object. May be empty for CREATE operations
// when the name is server-generated.
Name string `json:"name,omitempty"`
// Namespace — the namespace of the object. Empty for cluster-scoped resources.
Namespace string `json:"namespace,omitempty"`
// Operation — the operation being performed: CREATE, UPDATE, DELETE, or CONNECT.
Operation string `json:"operation"`
// Object — the full object being admitted, as raw JSON.
// Present for CREATE and UPDATE operations.
// For UPDATE, this is the new (incoming) version of the object.
Object json.RawMessage `json:"object,omitempty"`
// OldObject — the existing object, as raw JSON.
// Present for UPDATE and DELETE operations.
OldObject json.RawMessage `json:"oldObject,omitempty"`
// DryRun — true when the operation is a dry run (kubectl apply --dry-run=server).
// Orkestra should evaluate rules but return allowed: true without side effects.
DryRun *bool `json:"dryRun,omitempty"`
}
AdmissionRequest contains the object the API server is asking about. Orkestra reads this to determine which CRD's rules to apply and to evaluate those rules against the object.
type AdmissionResponse ¶
type AdmissionResponse struct {
// UID — must exactly match AdmissionRequest.UID.
UID string `json:"uid"`
// Allowed — true when the operation should proceed, false to reject.
// For validation webhooks: false causes kubectl to show the Status message.
// For mutation webhooks: should always be true (mutation doesn't reject).
Allowed bool `json:"allowed"`
// Status — populated when Allowed is false. Shown to the user as the
// rejection reason. Code should be 400 for validation failures.
Status *AdmissionStatus `json:"status,omitempty"`
// Patch — JSON patch (RFC 6902) to apply to the object.
// Only meaningful for mutation webhooks.
// Must be base64-encoded. PatchType must be "JSONPatch" when set.
Patch []byte `json:"patch,omitempty"`
// PatchType — the type of patch. Always "JSONPatch" when Patch is set.
PatchType *string `json:"patchType,omitempty"`
// Warnings — strings shown to the user via kubectl as Warning: header lines.
// Used by Orkestra for action: warn validation rules — the object is allowed
// but the warnings surface in the user's terminal.
// Supported by Kubernetes API server 1.19+.
Warnings []string `json:"warnings,omitempty"`
}
AdmissionResponse is what Orkestra writes in reply to an AdmissionRequest.
type AdmissionReview ¶
type AdmissionReview struct {
// TypeMeta mirrors metav1.TypeMeta — we inline it to avoid the import.
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
// Request — populated by the API server. Contains the object being admitted.
// Nil in the response direction.
Request *AdmissionRequest `json:"request,omitempty"`
// Response — populated by Orkestra. Must reference the same UID as Request.
// Nil in the request direction.
Response *AdmissionResponse `json:"response,omitempty"`
}
AdmissionReview is the top-level wrapper sent by the API server and expected in the response. The same struct is used for both request and response — the Request field is populated by the API server, the Response field is populated by Orkestra.
type AdmissionStats ¶
type AdmissionStats struct {
// ── Validation counters ──────────────────────────────────────────────────
ValidationTotal int64 // total /validate calls
ValidationAllowed int64 // allowed (no deny rules fired)
ValidationDenied int64 // denied (at least one deny rule fired)
ValidationWarned int64 // allowed with warnings (warn rules fired, no deny)
// ── Mutation counters ────────────────────────────────────────────────────
MutationTotal int64 // total /mutate calls
MutationApplied int64 // at least one rule produced a change
MutationSkipped int64 // no rules produced changes — no-op
// contains filtered or unexported fields
}
AdmissionStats tracks statistics for the /validate and /mutate endpoints. Thread-safe for concurrent updates from the admission handlers.
Follows the same pattern as ConversionStats — a rolling window ring buffer for percentile calculations alongside simple running totals.
One AdmissionStats instance lives on the HealthServer and accumulates statistics across all CRDs. Per-CRD breakdown is available in Prometheus via the crd label on the metric series.
func NewAdmissionStats ¶
func NewAdmissionStats(windowSize int) *AdmissionStats
NewAdmissionStats creates a new stats tracker with a rolling window. windowSize determines how many requests are kept for percentile calculations. Use the same value as ConversionStats (controlled by CONVERSION_WINDOW env var).
func (*AdmissionStats) GetStats ¶
func (s *AdmissionStats) GetStats(webhooksEnabled bool) AdmissionStatsSnapshot
GetStats returns a point-in-time snapshot of the admission statistics.
func (*AdmissionStats) RecordMutationApplied ¶
func (s *AdmissionStats) RecordMutationApplied(duration time.Duration)
RecordMutationApplied records a /mutate call where at least one rule changed a field.
func (*AdmissionStats) RecordMutationSkipped ¶
func (s *AdmissionStats) RecordMutationSkipped(duration time.Duration)
RecordMutationSkipped records a /mutate call where no rules produced changes.
func (*AdmissionStats) RecordValidationAllowed ¶
func (s *AdmissionStats) RecordValidationAllowed(duration time.Duration)
RecordValidationAllowed records a /validate call that was allowed with no warnings.
func (*AdmissionStats) RecordValidationDenied ¶
func (s *AdmissionStats) RecordValidationDenied(duration time.Duration)
RecordValidationDenied records a /validate call that was denied.
func (*AdmissionStats) RecordValidationWarned ¶
func (s *AdmissionStats) RecordValidationWarned(duration time.Duration)
RecordValidationWarned records a /validate call that was allowed with warnings.
type AdmissionStatsSnapshot ¶
type AdmissionStatsSnapshot struct {
// Validation
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"`
// Mutation
MutationTotal int64 `json:"mutationTotal"`
MutationApplied int64 `json:"mutationApplied"`
MutationSkipped int64 `json:"mutationSkipped"`
MutAvgLatencyMs float64 `json:"mutAvgLatencyMs"`
MutP95LatencyMs float64 `json:"mutP95LatencyMs"`
MutMaxLatencyMs float64 `json:"mutMaxLatencyMs"`
// Whether admission webhooks are enabled
WebhooksEnabled bool `json:"webhooksEnabled"`
}
AdmissionStatsSnapshot is a read-only point-in-time snapshot. Serialised into the /katalog/{crd} JSON response under the "admission" key.
type AdmissionStatus ¶
type AdmissionStatus struct {
// Message — the human-readable rejection message shown by kubectl.
Message string `json:"message"`
// Code — HTTP status code. Use 400 for validation failures.
Code int32 `json:"code"`
}
AdmissionStatus is the rejection reason returned when Allowed is false.
type ConversionReview ¶
type ConversionReview struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Request *ConversionReviewRequest `json:"request,omitempty"`
Response *ConversionReviewResponse `json:"response,omitempty"`
}
--- Kubernetes-style ConversionReview types ---
func ProcessConversionReviewForTest ¶
func ProcessConversionReviewForTest(review ConversionReview, registry katalog.ConversionRegistry) ConversionReview
ProcessConversionReviewForTest exposes the conversion logic for unit tests.
type ConversionReviewRequest ¶
type ConversionReviewRequest struct {
UID string `json:"uid"`
DesiredAPIVersion string `json:"desiredAPIVersion"`
Objects []json.RawMessage `json:"objects"`
}
type ConversionReviewResponse ¶
type ConversionReviewResponse struct {
UID string `json:"uid"`
ConvertedObjects []json.RawMessage `json:"convertedObjects"`
Result *Status `json:"result"`
}
type ConversionStats ¶
type ConversionStats struct {
TotalRequests int64
SuccessRequests int64
FailedRequests int64
// contains filtered or unexported fields
}
ConversionStats tracks statistics for the /convert endpoint. Thread‑safe for concurrent updates from the conversion handler.
func NewConversionStats ¶
func NewConversionStats(windowSize int) *ConversionStats
NewConversionStats creates a new stats tracker with a rolling window. windowSize determines how many requests are kept for percentile calculations.
func (*ConversionStats) GetStats ¶
func (s *ConversionStats) GetStats() ConversionStatsSnapshot
GetStats returns a snapshot of current statistics.
func (*ConversionStats) RecordFailure ¶
func (s *ConversionStats) RecordFailure()
RecordFailure records a failed conversion attempt.
func (*ConversionStats) RecordSuccess ¶
func (s *ConversionStats) RecordSuccess(duration time.Duration)
RecordSuccess records a successful conversion with its duration.
type ConversionStatsSnapshot ¶
type ConversionStatsSnapshot struct {
TotalRequests int64
SuccessRequests int64
FailedRequests int64
AvgLatency time.Duration
P95Latency time.Duration
MaxLatency time.Duration
MinLatency time.Duration
}
ConversionStatsSnapshot is a read‑only snapshot of conversion statistics.
type DeletionProtectionStats ¶ added in v0.1.9
type DeletionProtectionStats struct {
TotalRequests int64 // total DELETE admission reviews received
Blocked int64 // DELETE requests denied (CRD or deployment protected)
Allowed int64 // DELETE requests allowed through
// contains filtered or unexported fields
}
DeletionProtectionStats tracks counters for the /deletion-protection webhook endpoint. Thread-safe for concurrent updates from the deletion protection handler.
Follows the same pattern as ConversionStats, AdmissionStats, and NamespaceProtectionStats. No latency tracking — deletion protection decisions are fast in-memory lookups and the blocking count is the meaningful signal.
func NewDeletionProtectionStats ¶ added in v0.1.9
func NewDeletionProtectionStats() *DeletionProtectionStats
NewDeletionProtectionStats creates a new DeletionProtectionStats instance.
func (*DeletionProtectionStats) GetStats ¶ added in v0.1.9
func (s *DeletionProtectionStats) GetStats() DeletionProtectionStatsSnapshot
GetStats returns a point-in-time snapshot of deletion protection statistics.
func (*DeletionProtectionStats) RecordAllowed ¶ added in v0.1.9
func (s *DeletionProtectionStats) RecordAllowed()
RecordAllowed records a DELETE that was allowed through the webhook.
func (*DeletionProtectionStats) RecordBlocked ¶ added in v0.1.9
func (s *DeletionProtectionStats) RecordBlocked()
RecordBlocked records a DELETE that was denied by the webhook.
type DeletionProtectionStatsSnapshot ¶ added in v0.1.9
type DeletionProtectionStatsSnapshot struct {
TotalRequests int64 `json:"total"`
Blocked int64 `json:"blocked"`
Allowed int64 `json:"allowed"`
}
DeletionProtectionStatsSnapshot is a read-only point-in-time snapshot. Serialised into the /katalog/{crd} JSON response under the "protection" key.
type HealthServer ¶
type HealthServer struct {
// contains filtered or unexported fields
}
func NewHealthServer ¶
func NewHealthServer(kubeclient kubernetes.Interface, katalog *katalog.Katalog, kfg *konfig.Konfig) *HealthServer
NewHealthServer constructs the HealthServer and resolves all declarative runtime behavior from the Katalog and Konfig. This method performs no I/O; it simply materializes the runtime model that Start() will activate.
Responsibilities:
- Resolve webhook enablement and failure‑policy precedence (YAML > ENV > defaults)
- Initialize all HTTP/HTTPS muxes and stats collectors
- Capture conversion/admission registries from the Katalog
- Precompute deletion‑protection CRD sets
- Initialize all readiness/health/startup flags
The HealthServer returned here is inert — Start() is responsible for activating servers, endpoints, and webhook reconciliation.
func (*HealthServer) Degraded ¶
func (h *HealthServer) Degraded()
Degraded transitions the server out of ready state without marking it unhealthy.
func (*HealthServer) EnableConversion ¶
func (h *HealthServer) EnableConversion(certFile, keyFile string)
EnableConversion activates the CRD conversion webhook at runtime. This is an imperative override used primarily in tests or operator-driven reconfiguration. It does not register the webhook — Start() handles that. It simply marks conversion as enabled and updates the TLS material.
func (*HealthServer) EnableWebhooks ¶
func (h *HealthServer) EnableWebhooks(certFile, keyFile string)
EnableWebhooks activates admission (validation + mutation) webhooks at runtime. Like EnableConversion, this is an imperative override and does not perform registration. Start() will reflect this enablement into actual webhook configuration creation and endpoint exposure.
func (*HealthServer) GetAdmissionStats ¶
func (h *HealthServer) GetAdmissionStats() *AdmissionStats
GetAdmissionStats returns the admission statistics for use in handlers.
func (*HealthServer) GetConversionStats ¶
func (h *HealthServer) GetConversionStats() *ConversionStats
GetConversionStats returns the conversion statistics for use in handlers.
func (*HealthServer) GetNamespaceStats ¶ added in v0.1.9
func (h *HealthServer) GetNamespaceStats() *NamespaceProtectionStats
GetNamespaceStats returns the namespace protection statistics for use in handlers.
func (*HealthServer) GetProtectionStats ¶
func (h *HealthServer) GetProtectionStats() *DeletionProtectionStats
GetProtectionStats returns the deletion protection statistics for use in handlers.
func (*HealthServer) GetWebhookStats ¶
func (h *HealthServer) GetWebhookStats() *WebhookStats
GetWebhookStats returns the webhook statistics for use in handlers.
func (*HealthServer) Healthy ¶
func (h *HealthServer) Healthy() bool
Healthy reports whether the server is healthy.
func (*HealthServer) Name ¶
func (h *HealthServer) Name() string
Name returns the configured runtime name.
func (*HealthServer) Ready ¶
func (h *HealthServer) Ready() bool
Ready reports whether the server is ready for admission and health checks.
func (*HealthServer) Register ¶
func (hs *HealthServer) Register(path string, handler http.HandlerFunc)
Register adds a route to the health server mux. Must be called before Start() — routes registered after Start() are not guaranteed to be visible depending on ServeMux implementation.
func (*HealthServer) SetAdmissionRegistry ¶
func (h *HealthServer) SetAdmissionRegistry(r katalog.AdmissionRegistry)
── SetAdmissionRegistry ─────────────────────────────────────────────────────
SetAdmissionRegistry provides the admission registry to the health server. Called from KomposeKatalogFromYaml after rules are loaded.
func (*HealthServer) SetKubeClient ¶
func (h *HealthServer) SetKubeClient(c kubernetes.Interface)
SetKubeClient provides the Kubernetes client for webhook registration.
func (*HealthServer) SetReady ¶
func (h *HealthServer) SetReady()
SetReady marks the server as ready to serve traffic.
func (*HealthServer) SetStarted ¶
func (h *HealthServer) SetStarted()
SetStarted marks the server as having begun serving traffic.
func (*HealthServer) SetStartupComplete ¶
func (h *HealthServer) SetStartupComplete()
SetStartupComplete marks the startup sequence as finished.
func (*HealthServer) SetWebhookOpts ¶
func (h *HealthServer) SetWebhookOpts(opts WebhookRegistrationOptions)
SetWebhookOpts configures webhook registration options.
func (*HealthServer) Shutdown ¶
func (h *HealthServer) Shutdown(ctx context.Context)
Shutdown gracefully terminates all runtime servers and performs optional, declarative cleanup of webhook configurations. This method embodies Orkestra’s “runtime that leaves no trace” principle: cleanup is opt‑in and driven entirely by the Katalog’s shutdown policy. If cleanupOnShutdown is disabled, the cluster is left structurally unchanged.
Responsibilities:
- Transition the runtime out of ready/healthy state
- Gracefully stop HTTP and HTTPS servers
- Optionally unregister admission webhooks (validation + mutation)
- Optionally remove the deletion‑protection webhook configuration
Shutdown never blocks startup or reconciliation guarantees — it is best‑effort.
func (*HealthServer) Start ¶
func (h *HealthServer) Start(ctx context.Context) error
Start activates the HealthServer’s full runtime surface. It launches the HTTP and HTTPS servers, exposes all declared admission/conversion/protection endpoints, performs best‑effort webhook registration, and begins continuous reconciliation of webhook configurations.
This is the transition from a declarative model (NewHealthServer) to an active runtime. All behavior is driven by the Katalog: only capabilities explicitly declared (conversion, validation, mutation, deletion protection) are exposed. Startup is intentionally resilient — webhook registration failures never block readiness or liveness. Once all endpoints are registered and servers launched, Start() marks the runtime as startup‑complete.
func (*HealthServer) Started ¶
func (h *HealthServer) Started() bool
Started reports whether the HTTP/HTTPS servers have begun serving.
func (*HealthServer) StartupComplete ¶
func (h *HealthServer) StartupComplete() bool
StartupComplete reports whether the startup sequence has finished.
func (*HealthServer) Unhealthy ¶
func (h *HealthServer) Unhealthy()
Unhealthy marks the server as unhealthy, signaling a fatal condition.
func (*HealthServer) Uptime ¶
func (h *HealthServer) Uptime() string
Uptime returns human-readable uptime since the server started.
type JSONPatchOp ¶
type JSONPatchOp struct {
Op string `json:"op"`
Path string `json:"path"`
Value interface{} `json:"value,omitempty"`
}
JSONPatchOp is one operation in a JSON Patch document (RFC 6902).
type NamespaceProtectionStats ¶ added in v0.1.9
type NamespaceProtectionStats struct {
TotalRequests int64 // total CREATE/UPDATE admission reviews received
Blocked int64 // requests denied — namespace not in allowed set / in restricted set
Allowed int64 // requests allowed through
// contains filtered or unexported fields
}
NamespaceProtectionStats tracks counters for the /namespace-protection webhook endpoint. Thread-safe for concurrent updates from the namespace protection handler.
func NewNamespaceProtectionStats ¶ added in v0.1.9
func NewNamespaceProtectionStats() *NamespaceProtectionStats
NewNamespaceProtectionStats creates a new NamespaceProtectionStats instance.
func (*NamespaceProtectionStats) GetStats ¶ added in v0.1.9
func (s *NamespaceProtectionStats) GetStats() NamespaceProtectionStatsSnapshot
GetStats returns a point-in-time snapshot of namespace protection statistics.
func (*NamespaceProtectionStats) RecordAllowed ¶ added in v0.1.9
func (s *NamespaceProtectionStats) RecordAllowed()
RecordAllowed records a CREATE/UPDATE that passed the namespace rule.
func (*NamespaceProtectionStats) RecordBlocked ¶ added in v0.1.9
func (s *NamespaceProtectionStats) RecordBlocked()
RecordBlocked records a CREATE/UPDATE that was denied by the namespace rule.
type NamespaceProtectionStatsSnapshot ¶ added in v0.1.9
type NamespaceProtectionStatsSnapshot struct {
TotalRequests int64 `json:"total"`
Blocked int64 `json:"blocked"`
Allowed int64 `json:"allowed"`
}
NamespaceProtectionStatsSnapshot is a read-only point-in-time snapshot. Serialised into the /katalog/{crd} JSON response under the "namespaceProtection" key.
type NamespaceRules ¶ added in v0.1.9
func (*NamespaceRules) IsNamespaceAllowed ¶ added in v0.1.9
func (r *NamespaceRules) IsNamespaceAllowed(ns string) bool
type ProviderStatEntry ¶
ProviderStatEntry is one provider's snapshot — provider name, totals, error rate.
type ProviderStats ¶
type ProviderStats struct {
// contains filtered or unexported fields
}
ProviderStats tracks per-provider reconcile and delete call totals and errors. Thread-safe for concurrent updates from the template reconciler.
One ProviderStats instance is created per CRD at startup and shared between:
- GenericReconciler, which writes to it after each provider.Reconcile / provider.Delete call
- BuildCRDInfoHandler, which reads it to surface error rates in the CRD detail response
Detailed per-kind breakdowns are available in Prometheus via RecordProviderReconcile. This struct exists for fast in-memory error rate checks without querying Prometheus.
func NewProviderStats ¶
func NewProviderStats() *ProviderStats
NewProviderStats creates a new ProviderStats instance.
func (*ProviderStats) GetSnapshot ¶
func (s *ProviderStats) GetSnapshot() []ProviderStatEntry
GetSnapshot returns a point-in-time snapshot for all providers that have been called. Only providers that have been called at least once are included.
func (*ProviderStats) RecordDeleteFailure ¶
func (s *ProviderStats) RecordDeleteFailure(provider string)
RecordDeleteFailure records a failed provider.Delete call.
func (*ProviderStats) RecordDeleteSuccess ¶
func (s *ProviderStats) RecordDeleteSuccess(provider string)
RecordDeleteSuccess records a successful provider.Delete call.
func (*ProviderStats) RecordFailure ¶
func (s *ProviderStats) RecordFailure(provider string)
RecordFailure records a failed provider.Reconcile call for the named provider.
func (*ProviderStats) RecordSuccess ¶
func (s *ProviderStats) RecordSuccess(provider string)
RecordSuccess records a successful provider.Reconcile call for the named provider.
type WebhookCleanupOptions ¶
type WebhookCleanupOptions struct {
// contains filtered or unexported fields
}
UnregisterWebhooks removes the ValidatingWebhookConfiguration and MutatingWebhookConfiguration entries that were previously created from the admission registry.
Called from HealthServer.Shutdown() when ENABLE_ADMISSION_WEBHOOK=true, after the runtime begins shutting down and the admission registry is no longer needed.
The function is destructive — only call during shutdown. Any webhook configurations created by Orkestra are cleaned up.
type WebhookConfgurationOptions ¶
type WebhookConfgurationOptions struct {
WebhooksEnabled bool // admission (validation + mutation) enabled
ConvEnabled bool // CRD conversion webhook enabled
TLSCert string // certificate used by the HTTPS server
TLSKey string // private key used by the HTTPS server
ConversionWindow int // rolling window for conversion statistics
}
WebhookConfgurationOptions captures the declarative enablement state for all webhook-related capabilities (admission, conversion) as resolved from the Katalog and environment. These options determine whether the HealthServer exposes HTTPS endpoints and participates in webhook registration.
This struct does *not* describe the webhook spec itself — only whether the runtime should activate the corresponding admission surfaces.
type WebhookRegistrationOptions ¶
type WebhookRegistrationOptions struct {
// ServiceName — the name of the Kubernetes Service fronting Orkestra.
// The API server calls this service to reach /validate and /mutate.
// Default: "orkestra"
ServiceName string
// ServiceNamespace — the namespace where the Orkestra Service lives.
// Default: read from ORKESTRA_NAMESPACE environment variable.
ServiceNamespace string
// Port — the HTTPS port. Must match the conversion server port.
// Default: 8443
Port int32
// FailurePolicy — what the API server does if Orkestra is unreachable.
// admissionv1.Ignore (default): allow the operation and continue.
// admissionv1.Fail: reject the operation if Orkestra cannot be reached.
// Configurable from WEBHOOK_FAILURE_POLICY environment variable.
FailurePolicy admissionv1.FailurePolicyType
// TLSCertFile — path to the TLS certificate file.
// The certificate is read and used as the caBundle in the webhook config.
// Default: read from TLS_CERT environment variable.
TLSCertFile string
// OrkestraResourceLabels defines the labels used to identify Orkestra-managed
// resources for deletion protection.
OrkestraResourceLabels map[string]string
// Label selector shared by all Orkestra-managed Kubernetes resources.
// Narrows the webhook to only the operator's own deployment, service, ingress,
// and admission webhook configurations (validation + mutation).
OrkestraResourceSelector *metav1.LabelSelector
}
WebhookRegistrationOptions holds the configuration for webhook registration.
type WebhookStats ¶
type WebhookStats struct {
Reconciled int64 // total successful reconciliation cycles
Failed int64 // reconciliation attempts that encountered errors
// contains filtered or unexported fields
}
WebhookStats tracks reconciliation counters for the webhook controller. Thread-safe for concurrent updates from the reconciliation loop.
Mirrors the pattern used by ConversionStats, AdmissionStats, and ProtectionStats. No latency tracking — reconciliation is periodic and the meaningful signals are successful cycles and failures.
func NewWebhookStats ¶
func NewWebhookStats() *WebhookStats
NewWebhookStats creates a new WebhookStats instance.
func (*WebhookStats) GetStats ¶
func (s *WebhookStats) GetStats() WebhookStatsSnapshot
GetStats returns a point-in-time snapshot of webhook reconciliation statistics. Serialized into the /katalog/{crd} JSON response under the "webhooks" key.
func (*WebhookStats) RecordFailure ¶
func (s *WebhookStats) RecordFailure()
RecordFailure increments the reconciliation failure counter.
func (*WebhookStats) RecordReconciled ¶
func (s *WebhookStats) RecordReconciled()
RecordReconciled increments the successful reconciliation counter.
type WebhookStatsSnapshot ¶
type WebhookStatsSnapshot struct {
Reconciled int64 `json:"reconciled"`
Failed int64 `json:"failed"`
}
WebhookStatsSnapshot is a read-only point-in-time snapshot.
Source Files
¶
- admission_evaluation.go
- admission_handlers.go
- admission_review.go
- admission_stats.go
- conversion.go
- conversion_logic.go
- conversion_stats.go
- deletion_protection_handler.go
- deletion_protection_stats.go
- handler.go
- health.go
- health_testexport.go
- methods.go
- namespace_protection_handler.go
- namespace_protection_stats.go
- provider_stats.go
- webhook_controller.go
- webhook_registration.go
- webhook_stats.go