github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/startup-probe.yaml (about) 1 # Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file. 2 # Definition source cue file: vela-templates/definitions/internal/startup-probe.cue 3 apiVersion: core.oam.dev/v1beta1 4 kind: TraitDefinition 5 metadata: 6 annotations: 7 definition.oam.dev/description: Add startup probe hooks for the specified container of K8s pod for your workload which follows the pod spec in path 'spec.template'. 8 name: startup-probe 9 namespace: {{ include "systemDefinitionNamespace" . }} 10 spec: 11 appliesToWorkloads: 12 - deployments.apps 13 - statefulsets.apps 14 - daemonsets.apps 15 - jobs.batch 16 podDisruptive: true 17 schematic: 18 cue: 19 template: | 20 #StartupProbeParams: { 21 // +usage=Specify the name of the target container, if not set, use the component name 22 containerName: *"" | string 23 // +usage=Number of seconds after the container has started before liveness probes are initiated. Minimum value is 0. 24 initialDelaySeconds: *0 | int 25 // +usage=How often, in seconds, to execute the probe. Minimum value is 1. 26 periodSeconds: *10 | int 27 // +usage=Number of seconds after which the probe times out. Minimum value is 1. 28 timeoutSeconds: *1 | int 29 // +usage=Minimum consecutive successes for the probe to be considered successful after having failed. Minimum value is 1. 30 successThreshold: *1 | int 31 // +usage=Minimum consecutive failures for the probe to be considered failed after having succeeded. Minimum value is 1. 32 failureThreshold: *3 | int 33 // +usage=Optional duration in seconds the pod needs to terminate gracefully upon probe failure. Set this value longer than the expected cleanup time for your process. 34 terminationGracePeriodSeconds?: int 35 // +usage=Instructions for assessing container startup status by executing a command. Either this attribute or the httpGet attribute or the grpc attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with the httpGet attribute and the tcpSocket attribute and the gRPC attribute. 36 exec?: { 37 // +usage=A command to be executed inside the container to assess its health. Each space delimited token of the command is a separate array element. Commands exiting 0 are considered to be successful probes, whilst all other exit codes are considered failures. 38 command: [...string] 39 } 40 // +usage=Instructions for assessing container startup status by executing an HTTP GET request. Either this attribute or the exec attribute or the grpc attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with the exec attribute and the tcpSocket attribute and the gRPC attribute. 41 httpGet?: { 42 // +usage=The endpoint, relative to the port, to which the HTTP GET request should be directed. 43 path?: string 44 // +usage=The port numer to access on the host or container. 45 port: int 46 // +usage=The hostname to connect to, defaults to the pod IP. You probably want to set "Host" in httpHeaders instead. 47 host?: string 48 // +usage=The Scheme to use for connecting to the host. 49 scheme?: *"HTTP" | "HTTPS" 50 // +usage=Custom headers to set in the request. HTTP allows repeated headers. 51 httpHeaders?: [...{ 52 // +usage=The header field name 53 name: string 54 //+usage=The header field value 55 value: string 56 }] 57 } 58 // +usage=Instructions for assessing container startup status by probing a gRPC service. Either this attribute or the exec attribute or the grpc attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with the exec attribute and the httpGet attribute and the tcpSocket attribute. 59 grpc?: { 60 // +usage=The port number of the gRPC service. 61 port: int 62 // +usage=The name of the service to place in the gRPC HealthCheckRequest 63 service?: string 64 } 65 // +usage=Instructions for assessing container startup status by probing a TCP socket. Either this attribute or the exec attribute or the tcpSocket attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with the exec attribute and the httpGet attribute and the gRPC attribute. 66 tcpSocket?: { 67 // +usage=Number or name of the port to access on the container. 68 port: int 69 // +usage=Host name to connect to, defaults to the pod IP. 70 host?: string 71 } 72 } 73 PatchContainer: { 74 _params: #StartupProbeParams 75 name: _params.containerName 76 _baseContainers: context.output.spec.template.spec.containers 77 _matchContainers_: [ for _container_ in _baseContainers if _container_.name == name {_container_}] 78 if len(_matchContainers_) == 0 { 79 err: "container \(name) not found" 80 } 81 if len(_matchContainers_) > 0 { 82 startupProbe: { 83 if _params.exec != _|_ { 84 exec: _params.exec 85 } 86 if _params.httpGet != _|_ { 87 httpGet: _params.httpGet 88 } 89 if _params.grpc != _|_ { 90 grpc: _params.grpc 91 } 92 if _params.tcpSocket != _|_ { 93 tcpSocket: _params.tcpSocket 94 } 95 if _params.initialDelaySeconds != _|_ { 96 initialDelaySeconds: _params.initialDelaySeconds 97 } 98 if _params.periodSeconds != _|_ { 99 periodSeconds: _params.periodSeconds 100 } 101 if _params.tcpSocket != _|_ { 102 tcpSocket: _params.tcpSocket 103 } 104 if _params.timeoutSeconds != _|_ { 105 timeoutSeconds: _params.timeoutSeconds 106 } 107 if _params.successThreshold != _|_ { 108 successThreshold: _params.successThreshold 109 } 110 if _params.failureThreshold != _|_ { 111 failureThreshold: _params.failureThreshold 112 } 113 if _params.terminationGracePeriodSeconds != _|_ { 114 terminationGracePeriodSeconds: _params.terminationGracePeriodSeconds 115 } 116 } 117 } 118 } 119 120 patch: spec: template: spec: { 121 if parameter.probes == _|_ { 122 // +patchKey=name 123 containers: [{ 124 PatchContainer & {_params: { 125 if parameter.containerName == "" { 126 containerName: context.name 127 } 128 if parameter.containerName != "" { 129 containerName: parameter.containerName 130 } 131 periodSeconds: parameter.periodSeconds 132 initialDelaySeconds: parameter.initialDelaySeconds 133 timeoutSeconds: parameter.timeoutSeconds 134 successThreshold: parameter.successThreshold 135 failureThreshold: parameter.failureThreshold 136 terminationGracePeriodSeconds: parameter.terminationGracePeriodSeconds 137 if parameter.exec != _|_ { 138 exec: parameter.exec 139 } 140 if parameter.httpGet != _|_ { 141 httpGet: parameter.httpGet 142 } 143 if parameter.grpc != _|_ { 144 grpc: parameter.grpc 145 } 146 if parameter.tcpSocket != _|_ { 147 tcpSocket: parameter.tcpSocket 148 } 149 }} 150 }] 151 } 152 if parameter.probes != _|_ { 153 // +patchKey=name 154 containers: [ for c in parameter.probes { 155 if c.name == "" { 156 err: "containerName must be set when specifying startup probe for multiple containers" 157 } 158 if c.name != "" { 159 PatchContainer & {_params: c} 160 } 161 }] 162 } 163 } 164 165 parameter: *#StartupProbeParams | close({ 166 // +usage=Specify the startup probe for multiple containers 167 probes: [...#StartupProbeParams] 168 }) 169 170 errs: [ for c in patch.spec.template.spec.containers if c.err != _|_ {c.err}] 171