github.com/oam-dev/kubevela@v1.9.11/pkg/controller/core.oam.dev/v1beta1/application/assemble/testdata/apprevision.yaml (about) 1 apiVersion: core.oam.dev/v1beta1 2 kind: ApplicationRevision 3 metadata: 4 annotations: 5 oam.dev/kubevela-version: undefined 6 labels: 7 app.oam.dev/app-revision-hash: 883efe1e84fb0964 8 app.oam.dev/name: test-assemble 9 name: test-assemble-v1 10 namespace: default 11 ownerReferences: 12 - apiVersion: core.oam.dev/v1beta1 13 controller: true 14 kind: Application 15 name: test-assemble 16 spec: 17 application: 18 apiVersion: core.oam.dev/v1beta1 19 kind: Application 20 metadata: {} 21 spec: 22 components: 23 - name: test-comp 24 type: webservice 25 properties: 26 image: crccheck/hello-world 27 port: 8000 28 traits: 29 - properties: 30 domain: localhost 31 http: 32 /: 8000 33 type: ingress 34 status: {} 35 componentDefinitions: 36 webservice: 37 apiVersion: core.oam.dev/v1beta1 38 kind: ComponentDefinition 39 metadata: {} 40 spec: 41 schematic: 42 cue: 43 template: "output: {\n\tapiVersion: \"apps/v1\"\n\tkind: \"Deployment\"\n\tspec: 44 {\n\t\tselector: matchLabels: {\n\t\t\t\"app.oam.dev/component\": context.name\n\t\t\tif 45 parameter.addRevisionLabel {\n\t\t\t\t\"app.oam.dev/appRevision\": context.appRevision\n\t\t\t}\n\t\t}\n\n\t\ttemplate: 46 {\n\t\t\tmetadata: labels: {\n\t\t\t\t\"app.oam.dev/component\": context.name\n\t\t\t\tif 47 parameter.addRevisionLabel {\n\t\t\t\t\t\"app.oam.dev/appRevision\": 48 context.appRevision\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tspec: {\n\t\t\t\tcontainers: 49 [{\n\t\t\t\t\tname: context.name\n\t\t\t\t\timage: parameter.image\n\t\t\t\t\tports: 50 [{\n\t\t\t\t\t\tcontainerPort: parameter.port\n\t\t\t\t\t}]\n\n\t\t\t\t\tif 51 parameter[\"cmd\"] != _|_ {\n\t\t\t\t\t\tcommand: parameter.cmd\n\t\t\t\t\t}\n\n\t\t\t\t\tif 52 parameter[\"env\"] != _|_ {\n\t\t\t\t\t\tenv: parameter.env\n\t\t\t\t\t}\n\n\t\t\t\t\tif 53 context[\"config\"] != _|_ {\n\t\t\t\t\t\tenv: context.config\n\t\t\t\t\t}\n\n\t\t\t\t\tif 54 parameter[\"cpu\"] != _|_ {\n\t\t\t\t\t\tresources: {\n\t\t\t\t\t\t\tlimits:\n\t\t\t\t\t\t\t\tcpu: 55 parameter.cpu\n\t\t\t\t\t\t\trequests:\n\t\t\t\t\t\t\t\tcpu: parameter.cpu\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif 56 parameter[\"memory\"] != _|_ {\n\t\t\t\t\t\tresources: {\n\t\t\t\t\t\t\tlimits:\n\t\t\t\t\t\t\t\tmemory: 57 parameter.memory\n\t\t\t\t\t\t\trequests:\n\t\t\t\t\t\t\t\tmemory: parameter.memory\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif 58 parameter[\"volumes\"] != _|_ {\n\t\t\t\t\t\tvolumeMounts: [ for v in 59 parameter.volumes {\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmountPath: v.mountPath\n\t\t\t\t\t\t\t\tname: 60 \ v.name\n\t\t\t\t\t\t\t}}]\n\t\t\t\t\t}\n\n\t\t\t\t\tif parameter[\"livenessProbe\"] 61 != _|_ {\n\t\t\t\t\t\tlivenessProbe: parameter.livenessProbe\n\t\t\t\t\t}\n\n\t\t\t\t\tif 62 parameter[\"readinessProbe\"] != _|_ {\n\t\t\t\t\t\treadinessProbe: 63 parameter.readinessProbe\n\t\t\t\t\t}\n\n\t\t\t\t}]\n\n\t\t\tif parameter[\"volumes\"] 64 != _|_ {\n\t\t\t\tvolumes: [ for v in parameter.volumes {\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 65 v.name\n\t\t\t\t\t\tif v.type == \"pvc\" {\n\t\t\t\t\t\t\tpersistentVolumeClaim: 66 {\n\t\t\t\t\t\t\t\tclaimName: v.claimName\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif 67 v.type == \"configMap\" {\n\t\t\t\t\t\t\tconfigMap: {\n\t\t\t\t\t\t\t\tdefaultMode: 68 v.defaultMode\n\t\t\t\t\t\t\t\tname: v.cmName\n\t\t\t\t\t\t\t\tif 69 v.items != _|_ {\n\t\t\t\t\t\t\t\t\titems: v.items\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif 70 v.type == \"secret\" {\n\t\t\t\t\t\t\tsecret: {\n\t\t\t\t\t\t\t\tdefaultMode: 71 v.defaultMode\n\t\t\t\t\t\t\t\tsecretName: v.secretName\n\t\t\t\t\t\t\t\tif 72 v.items != _|_ {\n\t\t\t\t\t\t\t\t\titems: v.items\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif 73 v.type == \"emptyDir\" {\n\t\t\t\t\t\t\temptyDir: {\n\t\t\t\t\t\t\t\tmedium: 74 v.medium\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}}]\n\t\t\t}\n\t\t}\n\t}\n}\n}\nparameter: 75 {\n\t// +usage=Which image would you like to use for your service\n\t// 76 +short=i\n\timage: string\n\n\t// +usage=Which port do you want customer 77 traffic sent to\n\t// +short=p\n\tport: *80 | int\n\n\t// +ignore\n\t// 78 +usage=If addRevisionLabel is true, the appRevision label will be added 79 to the underlying pods\n\taddRevisionLabel: *false | bool\n\n\t// +usage=Commands 80 to run in the container\n\tcmd?: [...string]\n\n\t// +usage=Define arguments 81 by using environment variables\n\tenv?: [...{\n\t\t// +usage=Environment 82 variable name\n\t\tname: string\n\t\t// +usage=The value of the environment 83 variable\n\t\tvalue?: string\n\t\t// +usage=Specifies a source the value 84 of this var should come from\n\t\tvalueFrom?: {\n\t\t\t// +usage=Selects 85 a key of a secret in the pod's namespace\n\t\t\tsecretKeyRef: {\n\t\t\t\t// 86 +usage=The name of the secret in the pod's namespace to select from\n\t\t\t\tname: 87 string\n\t\t\t\t// +usage=The key of the secret to select from. Must 88 be a valid secret key\n\t\t\t\tkey: string\n\t\t\t}\n\t\t}\n\t}]\n\n\t// 89 +usage=Number of CPU units for the service, like `0.5` (0.5 CPU core), 90 `1` (1 CPU core)\n\tcpu?: string\n\n\t// +usage=Specifies the attributes 91 of the memory resource required for the container.\n\tmemory?: string\n\n\t// 92 +usage=Declare volumes and volumeMounts\n\tvolumes?: [...{\n\t\tname: 93 \ string\n\t\tmountPath: string\n\t\t// +usage=Specify volume type, 94 options: \"pvc\",\"configMap\",\"secret\",\"emptyDir\"\n\t\ttype: \"pvc\" 95 | \"configMap\" | \"secret\" | \"emptyDir\"\n\t\tif type == \"pvc\" 96 {\n\t\t\tclaimName: string\n\t\t}\n\t\tif type == \"configMap\" {\n\t\t\tdefaultMode: 97 *420 | int\n\t\t\tcmName: string\n\t\t\titems?: [...{\n\t\t\t\tkey: 98 \ string\n\t\t\t\tpath: string\n\t\t\t\tmode: *511 | int\n\t\t\t}]\n\t\t}\n\t\tif 99 type == \"secret\" {\n\t\t\tdefaultMode: *420 | int\n\t\t\tsecretName: 100 \ string\n\t\t\titems?: [...{\n\t\t\t\tkey: string\n\t\t\t\tpath: string\n\t\t\t\tmode: 101 *511 | int\n\t\t\t}]\n\t\t}\n\t\tif type == \"emptyDir\" {\n\t\t\tmedium: 102 *\"\" | \"Memory\"\n\t\t}\n\t}]\n\n\t// +usage=Instructions for assessing 103 whether the container is alive.\n\tlivenessProbe?: #HealthProbe\n\n\t// 104 +usage=Instructions for assessing whether the container is in a suitable 105 state to serve traffic.\n\treadinessProbe?: #HealthProbe\n}\n\n#HealthProbe: 106 {\n\n\t// +usage=Instructions for assessing container health by executing 107 a command. Either this attribute or the httpGet attribute or the tcpSocket 108 attribute MUST be specified. This attribute is mutually exclusive with 109 both the httpGet attribute and the tcpSocket attribute.\n\texec?: {\n\t\t// 110 +usage=A command to be executed inside the container to assess its health. 111 Each space delimited token of the command is a separate array element. 112 Commands exiting 0 are considered to be successful probes, whilst all 113 other exit codes are considered failures.\n\t\tcommand: [...string]\n\t}\n\n\t// 114 +usage=Instructions for assessing container health by executing an HTTP 115 GET request. Either this attribute or the exec attribute or the tcpSocket 116 attribute MUST be specified. This attribute is mutually exclusive with 117 both the exec attribute and the tcpSocket attribute.\n\thttpGet?: {\n\t\t// 118 +usage=The endpoint, relative to the port, to which the HTTP GET request 119 should be directed.\n\t\tpath: string\n\t\t// +usage=The TCP socket 120 within the container to which the HTTP GET request should be directed.\n\t\tport: 121 int\n\t\thttpHeaders?: [...{\n\t\t\tname: string\n\t\t\tvalue: string\n\t\t}]\n\t}\n\n\t// 122 +usage=Instructions for assessing container health by probing a TCP 123 socket. Either this attribute or the exec attribute or the httpGet attribute 124 MUST be specified. This attribute is mutually exclusive with both the 125 exec attribute and the httpGet attribute.\n\ttcpSocket?: {\n\t\t// +usage=The 126 TCP socket within the container that should be probed to assess container 127 health.\n\t\tport: int\n\t}\n\n\t// +usage=Number of seconds after the 128 container is started before the first probe is initiated.\n\tinitialDelaySeconds: 129 *0 | int\n\n\t// +usage=How often, in seconds, to execute the probe.\n\tperiodSeconds: 130 *10 | int\n\n\t// +usage=Number of seconds after which the probe times 131 out.\n\ttimeoutSeconds: *1 | int\n\n\t// +usage=Minimum consecutive 132 successes for the probe to be considered successful after having failed.\n\tsuccessThreshold: 133 *1 | int\n\n\t// +usage=Number of consecutive failures required to determine 134 the container is not alive (liveness probe) or not ready (readiness 135 probe).\n\tfailureThreshold: *3 | int\n}\n" 136 workload: 137 definition: 138 apiVersion: apps/v1 139 kind: Deployment 140 type: deployments.apps 141 status: {} 142 resourcesConfigMap: 143 name: test-assemble-v1 144 traitDefinitions: 145 ingress: 146 apiVersion: core.oam.dev/v1beta1 147 kind: TraitDefinition 148 metadata: {} 149 spec: 150 appliesToWorkloads: 151 - deployments.apps 152 definitionRef: 153 name: "" 154 schematic: 155 cue: 156 template: "// trait template can have multiple outputs in one trait\noutputs: 157 service: {\n\tapiVersion: \"v1\"\n\tkind: \"Service\"\n\tmetadata:\n\t\tname: 158 context.name\n\tspec: {\n\t\tselector: {\n\t\t\t\"app.oam.dev/component\": 159 context.name\n\t\t}\n\t\tports: [\n\t\t\tfor k, v in parameter.http 160 {\n\t\t\t\tport: v\n\t\t\t\ttargetPort: v\n\t\t\t},\n\t\t]\n\t}\n}\n\noutputs: 161 ingress: {\n\tapiVersion: \"networking.k8s.io/v1beta1\"\n\tkind: \"Ingress\"\n\tmetadata:\n\t\tname: 162 context.name\n\tspec: {\n\t\trules: [{\n\t\t\thost: parameter.domain\n\t\t\thttp: 163 {\n\t\t\t\tpaths: [\n\t\t\t\t\tfor k, v in parameter.http {\n\t\t\t\t\t\tpath: 164 k\n\t\t\t\t\t\tbackend: {\n\t\t\t\t\t\t\tserviceName: context.name\n\t\t\t\t\t\t\tservicePort: 165 v\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t}]\n\t}\n}\n\nparameter: 166 {\n\t// +usage=Specify the domain you want to expose\n\tdomain: string\n\n\t// 167 +usage=Specify the mapping relationship between the http path and the 168 workload port\n\thttp: [string]: int\n}\n" 169 status: 170 customStatus: |- 171 let igs = context.outputs.ingress.status.loadBalancer.ingress 172 if igs == _|_ { 173 message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + " --route'\n" 174 } 175 if len(igs) > 0 { 176 if igs[0].ip != _|_ { 177 message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip 178 } 179 if igs[0].ip == _|_ { 180 message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host 181 } 182 } 183 healthPolicy: | 184 isHealth: len(context.outputs.service.spec.clusterIP) > 0 185 status: {}