github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/sidecar.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/sidecar.cue 3 apiVersion: core.oam.dev/v1beta1 4 kind: TraitDefinition 5 metadata: 6 annotations: 7 definition.oam.dev/description: Inject a sidecar container to K8s pod for your workload which follows the pod spec in path 'spec.template'. 8 name: sidecar 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 patch: { 21 // +patchKey=name 22 spec: template: spec: containers: [{ 23 name: parameter.name 24 image: parameter.image 25 if parameter.cmd != _|_ { 26 command: parameter.cmd 27 } 28 if parameter.args != _|_ { 29 args: parameter.args 30 } 31 if parameter["env"] != _|_ { 32 env: parameter.env 33 } 34 if parameter["volumes"] != _|_ { 35 volumeMounts: [ for v in parameter.volumes { 36 { 37 mountPath: v.path 38 name: v.name 39 } 40 }] 41 } 42 if parameter["livenessProbe"] != _|_ { 43 livenessProbe: parameter.livenessProbe 44 } 45 46 if parameter["readinessProbe"] != _|_ { 47 readinessProbe: parameter.readinessProbe 48 } 49 }] 50 } 51 parameter: { 52 // +usage=Specify the name of sidecar container 53 name: string 54 55 // +usage=Specify the image of sidecar container 56 image: string 57 58 // +usage=Specify the commands run in the sidecar 59 cmd?: [...string] 60 61 // +usage=Specify the args in the sidecar 62 args?: [...string] 63 64 // +usage=Specify the env in the sidecar 65 env?: [...{ 66 // +usage=Environment variable name 67 name: string 68 // +usage=The value of the environment variable 69 value?: string 70 // +usage=Specifies a source the value of this var should come from 71 valueFrom?: { 72 // +usage=Selects a key of a secret in the pod's namespace 73 secretKeyRef?: { 74 // +usage=The name of the secret in the pod's namespace to select from 75 name: string 76 // +usage=The key of the secret to select from. Must be a valid secret key 77 key: string 78 } 79 // +usage=Selects a key of a config map in the pod's namespace 80 configMapKeyRef?: { 81 // +usage=The name of the config map in the pod's namespace to select from 82 name: string 83 // +usage=The key of the config map to select from. Must be a valid secret key 84 key: string 85 } 86 // +usage=Specify the field reference for env 87 fieldRef?: { 88 // +usage=Specify the field path for env 89 fieldPath: string 90 } 91 } 92 }] 93 94 // +usage=Specify the shared volume path 95 volumes?: [...{ 96 name: string 97 path: string 98 }] 99 100 // +usage=Instructions for assessing whether the container is alive. 101 livenessProbe?: #HealthProbe 102 103 // +usage=Instructions for assessing whether the container is in a suitable state to serve traffic. 104 readinessProbe?: #HealthProbe 105 } 106 107 #HealthProbe: { 108 109 // +usage=Instructions for assessing container health by executing a command. Either this attribute or the httpGet attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with both the httpGet attribute and the tcpSocket attribute. 110 exec?: { 111 // +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. 112 command: [...string] 113 } 114 115 // +usage=Instructions for assessing container health by executing an HTTP GET request. Either this attribute or the exec attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with both the exec attribute and the tcpSocket attribute. 116 httpGet?: { 117 // +usage=The endpoint, relative to the port, to which the HTTP GET request should be directed. 118 path: string 119 // +usage=The TCP socket within the container to which the HTTP GET request should be directed. 120 port: int 121 httpHeaders?: [...{ 122 name: string 123 value: string 124 }] 125 } 126 127 // +usage=Instructions for assessing container health by probing a TCP socket. Either this attribute or the exec attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with both the exec attribute and the httpGet attribute. 128 tcpSocket?: { 129 // +usage=The TCP socket within the container that should be probed to assess container health. 130 port: int 131 } 132 133 // +usage=Number of seconds after the container is started before the first probe is initiated. 134 initialDelaySeconds: *0 | int 135 136 // +usage=How often, in seconds, to execute the probe. 137 periodSeconds: *10 | int 138 139 // +usage=Number of seconds after which the probe times out. 140 timeoutSeconds: *1 | int 141 142 // +usage=Minimum consecutive successes for the probe to be considered successful after having failed. 143 successThreshold: *1 | int 144 145 // +usage=Number of consecutive failures required to determine the container is not alive (liveness probe) or not ready (readiness probe). 146 failureThreshold: *3 | int 147 } 148