github.com/oam-dev/kubevela@v1.9.11/vela-templates/definitions/internal/trait/lifecycle.cue (about)

     1  lifecycle: {
     2  	type: "trait"
     3  	annotations: {}
     4  	description: "Add lifecycle hooks for every container of K8s pod for your workload which follows the pod spec in path 'spec.template'."
     5  	attributes: {
     6  		podDisruptive: true
     7  		appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"]
     8  	}
     9  }
    10  template: {
    11  	patch: spec: template: spec: containers: [...{
    12  		lifecycle: {
    13  			if parameter.postStart != _|_ {
    14  				postStart: parameter.postStart
    15  			}
    16  			if parameter.preStop != _|_ {
    17  				preStop: parameter.preStop
    18  			}
    19  		}
    20  	}]
    21  	parameter: {
    22  		postStart?: #LifeCycleHandler
    23  		preStop?:   #LifeCycleHandler
    24  	}
    25  	#Port: int & >=1 & <=65535
    26  	#LifeCycleHandler: {
    27  		exec?: command: [...string]
    28  		httpGet?: {
    29  			path?:  string
    30  			port:   #Port
    31  			host?:  string
    32  			scheme: *"HTTP" | "HTTPS"
    33  			httpHeaders?: [...{
    34  				name:  string
    35  				value: string
    36  			}]
    37  		}
    38  		tcpSocket?: {
    39  			port:  #Port
    40  			host?: string
    41  		}
    42  	}
    43  }