github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/init-container.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/init-container.cue 3 apiVersion: core.oam.dev/v1beta1 4 kind: TraitDefinition 5 metadata: 6 annotations: 7 definition.oam.dev/description: add an init container and use shared volume with pod 8 name: init-container 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: spec: template: spec: { 21 // +patchKey=name 22 containers: [{ 23 name: context.name 24 // +patchKey=name 25 volumeMounts: [{ 26 name: parameter.mountName 27 mountPath: parameter.appMountPath 28 }] 29 }] 30 // +patchKey=name 31 initContainers: [{ 32 name: parameter.name 33 image: parameter.image 34 imagePullPolicy: parameter.imagePullPolicy 35 if parameter.cmd != _|_ { 36 command: parameter.cmd 37 } 38 if parameter.args != _|_ { 39 args: parameter.args 40 } 41 if parameter["env"] != _|_ { 42 env: parameter.env 43 } 44 45 // +patchKey=name 46 volumeMounts: [{ 47 name: parameter.mountName 48 mountPath: parameter.initMountPath 49 }] + parameter.extraVolumeMounts 50 }] 51 // +patchKey=name 52 volumes: [{ 53 name: parameter.mountName 54 emptyDir: {} 55 }] 56 } 57 parameter: { 58 // +usage=Specify the name of init container 59 name: string 60 61 // +usage=Specify the image of init container 62 image: string 63 64 // +usage=Specify image pull policy for your service 65 imagePullPolicy: *"IfNotPresent" | "Always" | "Never" 66 67 // +usage=Specify the commands run in the init container 68 cmd?: [...string] 69 70 // +usage=Specify the args run in the init container 71 args?: [...string] 72 73 // +usage=Specify the env run in the init container 74 env?: [...{ 75 // +usage=Environment variable name 76 name: string 77 // +usage=The value of the environment variable 78 value?: string 79 // +usage=Specifies a source the value of this var should come from 80 valueFrom?: { 81 // +usage=Selects a key of a secret in the pod's namespace 82 secretKeyRef?: { 83 // +usage=The name of the secret in the pod's namespace to select from 84 name: string 85 // +usage=The key of the secret to select from. Must be a valid secret key 86 key: string 87 } 88 // +usage=Selects a key of a config map in the pod's namespace 89 configMapKeyRef?: { 90 // +usage=The name of the config map in the pod's namespace to select from 91 name: string 92 // +usage=The key of the config map to select from. Must be a valid secret key 93 key: string 94 } 95 } 96 }] 97 98 // +usage=Specify the mount name of shared volume 99 mountName: *"workdir" | string 100 101 // +usage=Specify the mount path of app container 102 appMountPath: string 103 104 // +usage=Specify the mount path of init container 105 initMountPath: string 106 107 // +usage=Specify the extra volume mounts for the init container 108 extraVolumeMounts: [...{ 109 // +usage=The name of the volume to be mounted 110 name: string 111 // +usage=The mountPath for mount in the init container 112 mountPath: string 113 }] 114 } 115