KnativeDeployer
Class: KnativeDeployer<T>
Defined in: kubernetes/src/deployers/knative.service.ts:677
Deploy the application as a Knative Service, also valid for Cloud Run
Declare it as a unit of a deployment, after the Webda/ContainerDeployer building the image:
{
"units": [
{ "name": "image", "type": "Webda/ContainerDeployer", "image": "ghcr.io/my-org/my-app" },
{ "name": "knative", "type": "Webda/KnativeDeployer", "containerDeployer": "image", "namespace": "apps" }
]
}
then run webda -d <deployment> knative manifest to review the Service, deploy to push the image,
apply the Service and wait for it to be Ready, knative status and knative delete --yes.
The application listens on the injected PORT and answers the readiness probe on healthPath
(the WEBDA_HEALTH_PATH environment variable enables it), so it needs no Knative-specific configuration.
Webda Modda
Extends
Service<T>
Type Parameters
T
T extends KnativeDeployerParameters = KnativeDeployerParameters
Implements
Deployer
Constructors
Constructor
new KnativeDeployer<
T>(name,params):KnativeDeployer<T>
Defined in: core/lib/services/service.d.ts:72
Create a new Service instance
Service
Parameters
name
string
The name of the service
params
T
The parameters block define in the configuration file
Returns
KnativeDeployer<T>
Inherited from
Service<T>.constructor
Properties
_compiledCapabilities
protected_compiledCapabilities:Record<string,any>
Defined in: core/lib/services/iservice.d.ts:50
Capabilities detected at compile-time from @WebdaCapability-tagged interfaces.
Populated during Service.resolve by reading the service's entry in
webda.module.json. Each key is a capability name (e.g., "request-filter"),
and the value is an empty object {} by default. Override getCapabilities
to provide capability-specific configuration or to conditionally disable capabilities.
See
getCapabilities
Inherited from
Service._compiledCapabilities
[WEBDA_EVENTS]
[WEBDA_EVENTS]:
object
Defined in: core/lib/services/service.d.ts:50
Set the Webda events here
Inherited from
Service.[WEBDA_EVENTS]
client?
optionalclient?:KubernetesObjectApi
Defined in: kubernetes/src/deployers/knative.service.ts:684
Kubernetes client, created on the first command touching the cluster
logger
protectedlogger:Logger
Defined in: core/lib/services/service.d.ts:59
Logger with class context
Inherited from
Service.logger
metrics?
protectedoptionalmetrics?:object
Defined in: core/lib/services/service.d.ts:63
Get metrics
Inherited from
Service.metrics
name
readonlyname:string
Defined in: core/lib/services/iservice.d.ts:27
Name
Inherited from
Service.name
parameters
readonlyparameters:T
Defined in: core/lib/services/iservice.d.ts:31
Parameters
Inherited from
Service.parameters
pollInterval
pollInterval:
number=2000
Defined in: kubernetes/src/deployers/knative.service.ts:688
Milliseconds between two reads while waiting for the Service to be Ready
createConfiguration?
staticoptionalcreateConfiguration?: (params) =>any
Defined in: core/lib/services/iservice.d.ts:35
Create configuration set by the application on load
Parameters
params
any
Returns
any
Inherited from
Service.createConfiguration
filterConfiguration?
staticoptionalfilterConfiguration?: (params) =>any
Defined in: core/lib/services/iservice.d.ts:39
Create configuration set by the application on load
Parameters
params
any
Returns
any
Inherited from
Service.filterConfiguration
Parameters
staticParameters: typeofServiceParameters
Defined in: core/lib/services/service.d.ts:46
Service parameters
Inherited from
Service.Parameters
Methods
__clean()
abstract__clean():Promise<void>
Defined in: core/lib/services/service.d.ts:224
Clean the service data, can only be used in test mode
Returns
Promise<void>
Inherited from
Service.__clean
addListener()
addListener<
Key>(eventName,listener):this
Defined in: core/lib/events/asynceventemitter.d.ts:87
Add listener
Type Parameters
Key
Key extends never
Parameters
eventName
Key
the event name
listener
(event) => void | Promise<void>
the event listener
Returns
this
this for chaining
See
EventEmitter.addListener
Inherited from
Service.addListener
addRoute()
protectedaddRoute(url,methods,executer,openapi?,override?):void
Defined in: core/lib/services/service.d.ts:177
Add a route dynamicaly
Parameters
url
string
of the route can contains dynamic part like {uuid}
methods
HttpMethodType[]
the HTTP methods
executer
Function
Method to execute for this route
openapi?
OpenAPIWebdaDefinition
the OpenAPI specification
override?
boolean
whether to override existing
Returns
void
Inherited from
Service.addRoute
apply()
apply<
T>(manifest):Promise<T>
Defined in: kubernetes/src/deployers/knative.service.ts:845
Create a Service or a Trigger, or server-side apply it when it exists: the webda field manager owns the fields
Type Parameters
T
T extends KnativeManifest
Parameters
manifest
T
the manifest
Returns
Promise<T>
the resource as stored by the cluster
authorizeClientEvent()
authorizeClientEvent(
_event,_context):boolean
Defined in: core/lib/services/service.d.ts:153
Authorize a public event subscription
Parameters
_event
string
the event name
_context
OperationContext
the execution context
Returns
boolean
true if the condition is met
Inherited from
Service.authorizeClientEvent
computeParameters()
computeParameters():
void
Defined in: core/lib/services/service.d.ts:77
Used to compute or derivate input parameter to attribute
Returns
void
Deprecated
Inherited from
Service.computeParameters
delete()
delete(
yes?):Promise<void>
Defined in: kubernetes/src/deployers/knative.service.ts:974
Delete the Triggers, then the Service and its revisions
Parameters
yes?
boolean = false
Confirm the deletion
Returns
Promise<void>
deploy()
deploy():
Promise<KnativeServiceManifest>
Defined in: kubernetes/src/deployers/knative.service.ts:901
Push the image with the containerDeployer unit, create or apply the Service, wait for it to be Ready,
then apply its Triggers
Returns
Promise<KnativeServiceManifest>
the ready Service
emit()
emit<
Key>(event,data):Promise<void>
Defined in: core/lib/services/service.d.ts:213
Emit the event with data and wait for Promise to finish if listener returned a Promise
Type Parameters
Key
Key extends never
Parameters
event
Key
the event name
data
object[Key]
the data to process
Returns
Promise<void>
Inherited from
Service.emit
getCapabilities()
getCapabilities():
Record<string,any>
Defined in: core/lib/services/iservice.d.ts:72
Return the capabilities of this service.
By default returns capabilities detected at compile-time from
Returns
Record<string, any>
the result
Webda Capability-tagged
interfaces in webda.module.json.
Override to disable capabilities based on configuration:
getCapabilities() {
const caps = super.getCapabilities();
if (!this.parameters.enabled) delete caps["request-filter"];
return caps;
}
Inherited from
Service.getCapabilities
getClient()
getClient():
KubernetesObjectApi
Defined in: kubernetes/src/deployers/knative.service.ts:801
Kubernetes client of the configured cluster
Returns
KubernetesObjectApi
the client
getClientEvents()
getClientEvents():
string[]
Defined in: core/lib/services/service.d.ts:144
Return the events that an external system can subscribe to
Returns
string[]
the list of results
Inherited from
Service.getClientEvents
getManifest()
getManifest(
image?):KnativeServiceManifest
Defined in: kubernetes/src/deployers/knative.service.ts:720
Build the Service manifest, with the template overrides merged
Parameters
image?
string
the image to deploy, the image parameter by default
Returns
the manifest
getManifests()
getManifests(
image?):KnativeManifest[]
Defined in: kubernetes/src/deployers/knative.service.ts:745
The Service and its Triggers
Parameters
image?
string
the image to deploy, the image parameter by default
Returns
the Service first, then the Triggers
getMaxListeners()
getMaxListeners():
number
Defined in: core/lib/events/asynceventemitter.d.ts:91
Returns
number
Inherited from
Service.getMaxListeners
getMetric()
getMetric<
T>(type,configuration):T
Defined in: core/lib/services/service.d.ts:138
Add service name label
Type Parameters
T
T = Counter<string> | Histogram<string> | Gauge<string>
Parameters
type
CustomConstructor<T, [MetricConfiguration<T>]>
the type to look up
configuration
MetricConfiguration<T>
the configuration
Returns
T
the result
Inherited from
Service.getMetric
getName()
getName():
string
Defined in: core/lib/services/service.d.ts:218
Get service name
Returns
string
the result string
Inherited from
Service.getName
getOpenApiReplacements()
getOpenApiReplacements():
any
Defined in: core/lib/services/service.d.ts:182
Return variables for replacement in openapi
Returns
any
the result
Inherited from
Service.getOpenApiReplacements
getOperationId()
getOperationId(
id):string|undefined
Defined in: core/lib/services/service.d.ts:167
If undefined is returned it cancel the operation registration
Parameters
id
string
the identifier
Returns
string | undefined
the result
Inherited from
Service.getOperationId
getParameters()
getParameters():
T
Defined in: core/lib/services/service.d.ts:82
Get the service parameters
Returns
T
the result
Inherited from
Service.getParameters
getReference()
protectedgetReference(manifest?):KnativeServiceReference
Defined in: kubernetes/src/deployers/knative.service.ts:812
Header identifying a Service or a Trigger on the cluster
Parameters
manifest?
KnativeServiceReference = ...
the manifest, the Service built from the parameters by default
Returns
the apiVersion, kind, name and namespace
getResolvedParameters()
getResolvedParameters():
T
Defined in: kubernetes/src/deployers/knative.service.ts:695
Parameters with the deployment templates replaced, and template loaded when it is a file
Returns
T
the resolved parameters
getService()
getService<
T>(name):ServicesMap[T]
Defined in: core/lib/services/service.d.ts:131
Get a service by name
Type Parameters
T
T extends keyof ServicesMap
Parameters
name
T
the name to use
Returns
ServicesMap[T]
the result map
Deprecated
Use useService, might reconsider
Inherited from
Service.getService
getState()
getState():
ServiceStates
Defined in: core/lib/services/service.d.ts:55
Get the current state
Returns
ServiceStates
the result
Inherited from
Service.getState
getTriggers()
getTriggers(
service?):KnativeTriggerManifest[]
Defined in: kubernetes/src/deployers/knative.service.ts:735
Build the Trigger manifests of the triggers parameter
Parameters
service?
KnativeServiceManifest = ...
the Service they deliver to, built from the parameters by default
Returns
the manifests
getUrl()
getUrl(
url,_methods):string
Defined in: core/lib/services/service.d.ts:161
Return the full path url based on parameters
Parameters
url
string
relative url to service
_methods
HttpMethodType[]
in case we need filtering (like Store)
Returns
string
absolute url or undefined if need to skip the Route
Inherited from
Service.getUrl
init()
abstractinit():Promise<KnativeDeployer<T>>
Defined in: core/lib/services/service.d.ts:207
Will be called after all the Services are created
Returns
Promise<KnativeDeployer<T>>
Inherited from
Service.init
initMetrics()
initMetrics():
void
Defined in: core/lib/services/service.d.ts:124
Init the metrics
Returns
void
Inherited from
Service.initMetrics
initOperations()
initOperations():
void
Defined in: core/lib/services/service.d.ts:195
Init the operations from
Returns
void
Operation
decorators on this service
Inherited from
Service.initOperations
listeners()
listeners(
eventName):Function[]
Defined in: core/lib/events/asynceventemitter.d.ts:151
Get all listeners for an event
Parameters
eventName
never
the event name
Returns
Function[]
the list of results
Inherited from
Service.listeners
loadCapabilities()
protectedloadCapabilities():void
Defined in: core/lib/services/service.d.ts:120
Load capabilities from webda.module.json metadata into _compiledCapabilities.
Called during resolve after dependency injection. Reads the service's
type name from parameters, looks it up in the application's module metadata
(moddas or beans section), and populates _compiledCapabilities with an
empty object for each declared capability name.
Fails silently if the application is not available (e.g., in unit tests where services are instantiated without a full application context).
Returns
void
Example
// If webda.module.json contains:
// { "moddas": { "MyApp/HawkService": { "capabilities": ["request-filter", "cors-filter"] } } }
// Then after resolve(), this.getCapabilities() returns:
// { "request-filter": {}, "cors-filter": {} }
See
getCapabilities
Inherited from
Service.loadCapabilities
log()
log(
level, ...args):void
Defined in: core/lib/services/service.d.ts:236
Log operation
Parameters
level
WorkerLogLevel
to log
args
...any[]
additional arguments
Returns
void
Inherited from
Service.log
manifest()
manifest(
output?):Promise<string>
Defined in: kubernetes/src/deployers/knative.service.ts:784
Print the Service manifest and its Triggers, or write them to output, without touching the cluster
Review it, or apply it yourself: kubectl apply -f on Knative, gcloud run services replace on Cloud Run.
Parameters
output?
string
File to write the manifest to, the output parameter by default
Returns
Promise<string>
the YAML manifest, one document per resource
off()
off<
Key>(eventName,listener):this
Defined in: core/lib/events/asynceventemitter.d.ts:127
Perform off
Type Parameters
Key
Key extends never
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.off
Inherited from
Service.off
on()
on<
Key>(eventName,listener):this
Defined in: core/lib/events/asynceventemitter.d.ts:111
Perform on
Type Parameters
Key
Key extends never
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.once
Inherited from
Service.on
once()
once<
Key>(eventName,listener):this
Defined in: core/lib/events/asynceventemitter.d.ts:103
Perform once
Type Parameters
Key
Key extends never
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.once
Inherited from
Service.once
operationSchemaName()
protectedoperationSchemaName(method,side):string
Defined in: core/lib/services/service.d.ts:191
Schema of an operation side: <service name>.<method>.<side> when the application knows it, else the one the
build writes, <class>.<method>.<side>, for the class or its nearest ancestor that has it (a service configured
under another name than its class)
Parameters
method
string
the method name
side
"input" | "output"
input or output
Returns
string
the schema name
Inherited from
Service.operationSchemaName
read()
read<
T>(manifest?):Promise<T|undefined>
Defined in: kubernetes/src/deployers/knative.service.ts:826
Read a Service or a Trigger from the cluster
Type Parameters
T
T extends KnativeManifest = KnativeServiceManifest
Parameters
manifest?
the manifest identifying it
Returns
Promise<T | undefined>
the resource, undefined when it does not exist
removeAllListeners()
removeAllListeners<
Key>(eventName?):this
Defined in: core/lib/events/asynceventemitter.d.ts:134
Remove all listeners
Type Parameters
Key
Key extends never
Parameters
eventName?
Key
the event name
Returns
this
this for chaining
See
EventEmitter.removeAllListeners
Inherited from
Service.removeAllListeners
removeListener()
removeListener<
Key>(eventName,listener):this
Defined in: core/lib/events/asynceventemitter.d.ts:119
Remove listener
Type Parameters
Key
Key extends never
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.removeListener
Inherited from
Service.removeListener
resolve()
resolve():
this
Defined in: core/lib/services/service.d.ts:98
Resolve parameters and load metadata. @Route-declared routes are scanned
and registered by Router.discoverRoutes(services) from Core.init()
once every service has resolved — nothing to do per-service here.
Returns
this
the result
Inherited from
Service.resolve
resolvePath()
protectedresolvePath(path):string
Defined in: kubernetes/src/deployers/knative.service.ts:710
Resolve a path against the application folder
Parameters
path
string
the relative or absolute path
Returns
string
the absolute path
setMaxListeners()
setMaxListeners(
n):this
Defined in: core/lib/events/asynceventemitter.d.ts:95
Parameters
n
number
Returns
this
Inherited from
Service.setMaxListeners
status()
status():
Promise<KnativeServiceManifest|undefined>
Defined in: kubernetes/src/deployers/knative.service.ts:941
Print the URL, the revisions and the traffic of the Service
Returns
Promise<KnativeServiceManifest | undefined>
the Service, undefined when it does not exist
stop()
stop():
Promise<void>
Defined in: core/lib/services/service.d.ts:86
Shutdown the current service if action need to be taken
Returns
Promise<void>
Inherited from
Service.stop
toJSON()
toJSON():
string
Defined in: core/lib/services/service.d.ts:200
Prevent service to be serialized
Returns
string
the result
Inherited from
Service.toJSON
toString()
toString():
string
Defined in: core/lib/services/service.d.ts:91
Return service representation
Returns
string
the result
Inherited from
Service.toString
waitReady()
waitReady(
manifest,generation?):Promise<KnativeServiceManifest>
Defined in: kubernetes/src/deployers/knative.service.ts:865
Wait for the Service to be Ready
Parameters
manifest
the manifest identifying it
generation?
number
the generation the status must report, so a previous Ready revision does not count
Returns
Promise<KnativeServiceManifest>
the ready Service
Throws
WebdaError.CodeError KNATIVE_NOT_READY with the condition reason and message, or
KNATIVE_TIMEOUT after readyTimeout seconds
writeManifest()
protectedwriteManifest(manifests,output):string
Defined in: kubernetes/src/deployers/knative.service.ts:767
Write the manifests to a file
Parameters
manifests
the manifests
output
string
the file, relative to the application
Returns
string
the absolute path
toYaml()
statictoYaml(manifests):string
Defined in: kubernetes/src/deployers/knative.service.ts:756
Serialize manifests as a multi-document YAML
Parameters
manifests
the manifests
Returns
string
the YAML, one document per manifest