Skip to main content
Version: v1.4.x

Lifecycle

TypeTrait

Parameters​

Parameter
Type
Required
DefaultDescription
postStartobjectNo
preStopobjectNo

Template​

The following tabs display the definition's Cue template and the rendered YAML. The rendered YAML is the output of the Cue template when the definition is applied to a cluster.

lifecycle: {
type: "trait"
annotations: {}
labels: {
"definition.spectrocloud.com/category": "Container-and-Runtime"
}
description: "Add lifecycle hooks for every container of K8s pod for your workload which follows the pod spec in path 'spec.template'."
attributes: {
version: "1.0.1"
}
}

template: {
patch: spec: template: spec: containers: [...{
lifecycle: {
if parameter.postStart != _|_ {
postStart: parameter.postStart
}
if parameter.preStop != _|_ {
preStop: parameter.preStop
}
}
}]
parameter: {
postStart?: #LifeCycleHandler
preStop?: #LifeCycleHandler
}
#Port: int & >=1 & <=65535
#LifeCycleHandler: {
exec?: command!: [...string]
httpGet?: {
path?: string
port: #Port
host?: string
scheme: *"HTTP" | "HTTPS"
httpHeaders?: [...{
name: string
value: string
}]
}
tcpSocket?: {
port: #Port
host?: string
}
}
}