Reference
Events
Every event Klass8s dispatches, its name, its payload and when it fires.
Every event Klass8s dispatches, its payload, and the moment it fires. Concepts and patterns live in The Event System; this page is the catalog.
Subscribe by name. Events are dispatched under their NAME constants, not their class names: subscribe with DeploymentGeneratedEvent::NAME, as the subscribers in the guide do.
All classes live in Klass8s\Event\ unless noted otherwise.
Method events
Fired by the proxy layer around every public method call on a manifest or container — including methods you defined yourself.
| Event | NAME | Fires |
|---|---|---|
ManifestMethodEvent | klass8s.manifest.before_method | before a manifest method's body |
ManifestMethodCalledEvent | klass8s.manifest.method_called | after a manifest method's body |
ContainerMethodEvent | klass8s.container.before_method | before a container method's body |
ContainerMethodCalledEvent | klass8s.container.method_called | after a container method's body |
The shared API (ProxyableMethodEventInterface):
| Method | Purpose |
|---|---|
proxyable() | the manifest/container object (for instanceof filtering) |
methodName() | the intercepted method's name |
methodParams() / methodParam($name) | the call's arguments, by parameter name |
typedMethodParam($name, $class) | argument with an instanceof check — throws on mismatch |
setReturnValue($v) | before-event: skip the real body, return $v · after-event: replace what the caller receives |
getReturnValue() / returnValueHasChanged() | inspect what a subscriber has set |
returnedValue() | (after-events only) what the real method actually returned |
The *Called events extend their before-counterparts; ManifestMethodEvent additionally exposes manifest(), the container events container().
Base classes for method subscribers
Extend one, implement supports() and beforeMethod()/afterMethod(), optionally override protected static function priority(): int (default 0):
| Base class | Phase | Pinned to |
|---|---|---|
AbstractMethodSubscriber | before | (you list event names via eventNames()) |
AbstractMethodResultSubscriber | after | (same) |
AbstractManifestMethodSubscriber | before | manifest events |
AbstractManifestMethodResultSubscriber | after | manifest events |
AbstractContainerMethodSubscriber | before | container events |
AbstractContainerMethodResultSubscriber | after | container events |
All in Klass8s\Bundle\EventListener\.
Per-kind generated events
Notification events dispatched by a kind's resource maker once the k8schema object is fully built (after your configurators and configure{Kind}()). Payload: manifest(), apiResource(), a kind-named getter, and app(). Mutate the resource object directly.
| Event | NAME (klass8s.manifest_generated. +) | Kind getter |
|---|---|---|
ConfigMapGeneratedEvent | config_map | configMap() |
SecretGeneratedEvent | secret | secret() |
DeploymentGeneratedEvent | deployment | deployment() |
StatefulSetGeneratedEvent | stateful_set | statefulSet() |
JobGeneratedEvent | job | job() |
CronJobGeneratedEvent | cron_job | cronJob() |
ServiceGeneratedEvent | service | service() |
ServiceAccountGeneratedEvent | service_account | serviceAccount() |
IngressGeneratedEvent | ingress | ingress() |
CustomResourceDefinitionGeneratedEvent | custom_resource_definition | crd() |
GatewayGeneratedEvent | gateway | gateway() |
GatewayClassGeneratedEvent | gateway_class | gatewayClass() |
HTTPRouteGeneratedEvent | http_route | httpRoute() |
GRPCRouteGeneratedEvent | grpc_route | grpcRoute() |
BackendTLSPolicyGeneratedEvent | backend_tls_policy | backendTLSPolicy() |
ReferenceGrantGeneratedEvent | reference_grant | referenceGrant() |
ScaledObjectGeneratedEvent * | scaled_object | scaledObject() |
ScaledJobGeneratedEvent * | scaled_job | scaledJob() |
* KEDA events live in Klass8s\Autoscaling\Keda\Event\.
Kinds with no dedicated event — only the generic ManifestGeneratedEvent (below) fires for: HorizontalPodAutoscaler, PriorityClass, Role, ClusterRole, RoleBinding, ClusterRoleBinding, PersistentVolumeClaim, Prometheus monitors/rules, and all self-making manifests.
The generic manifest event
| Event | NAME | Fires |
|---|---|---|
ManifestGeneratedEvent | klass8s.manifest_generated | for every manifest of every kind, after the per-kind event |
Payload: manifest(), apiResource(), and the mutable flag public bool $preventProcessing — set true to drop the manifest from the output entirely (conditional existence). This is the event to use for rules spanning all kinds (the built-in klass8s.dev/* annotations use it).
Component events
Readonly events with public properties (no getters), fired while pods are assembled — for every workload kind at once:
| Event | NAME | Payload |
|---|---|---|
ContainerGeneratedEvent | klass8s.container.generated | $container (k8schema Container), $builder (ContainerInterface) |
PodSpecGeneratedEvent | klass8s.pod_spec.generated | $podSpec, $builder |
PodTemplateSpecGeneratedEvent | klass8s.pod_template_spec.generated | $templateSpec, $builder — note the property is $templateSpec |
Env-source events
Fired by EnvConfigurator when a container consumes a ConfigMap/Secret by class reference. The non-Added pair is stoppable — stopPropagation() vetoes the source before it's added; the Added pair notifies afterwards:
| Event | NAME | Veto? |
|---|---|---|
ConfigMapEnvSourceEvent | klass8s.env_source.config_map | yes — stopPropagation() |
ConfigMapEnvSourceAddedEvent | klass8s.env_source.config_map.added | no |
SecretEnvSourceEvent | klass8s.env_source.secret | yes |
SecretEnvSourceAddedEvent | klass8s.env_source.secret.added | no |
Payload (public readonly): the source class name, the AppInterface, and the EnvConfigurator itself.
Lifecycle events
| Event | NAME | Fires |
|---|---|---|
ManifestsProcessedEvent | klass8s.manifests.processed | once per generation, after all Apps are built, before output — payload $outputDir. The whole-build vantage point (checksums hook here). |
ManifestsDumpedEvent | klass8s.manifests.dumped | after files are written, by every k8s:dump:* command |
Helm
| Event | NAME | Fires |
|---|---|---|
Helm\HelmManifestProcessedEvent | klass8s.helm.manifest_processed | once per YAML document produced by helm template, before it's added to the release's output |
Payload (public readonly): $kind, $name, $release (HelmReleaseInterface), and $resource — a mutable \stdClass parsed from the chart's output. Vendor YAML isn't schema-typed; mutate the tree directly (example).
Framework subscriber priorities
For ordering your own subscribers around the built-ins (all others run at 0):
| Built-in | Event | Priority |
|---|---|---|
EnvSuffixedMethodsSubscriber | method-called events | -1024 — env-suffixed overrides get the last word |
TrackAPIResourcesSubscriber | six generated events | -1024 — tracks resources for checksum lookups |
ChecksumsSubscriber | ManifestsProcessedEvent | -1024 |
AutoscaleSubscriber | DeploymentGeneratedEvent / ManifestsProcessedEvent | 0 / 512 — spawns #[Autoscale] ScaledObjects before the late listeners |
Rule of thumb: subscribe below -1024 to observe truly final values; at 0 to contribute values that env-suffixed methods may still override.
See also
- The Event System — semantics, patterns, and the built-in opinion layer
- Configuration — the flags that enable/disable built-in subscribers