github.com/oam-dev/kubevela@v1.9.11/vela-templates/definitions/registry/webserver.cue (about)

     1  webserver: {
     2  	type: "component"
     3  	annotations: {}
     4  	labels: {}
     5  	description: "webserver was composed by deployment and service"
     6  	attributes: workload: definition: {
     7  		apiVersion: "apps/v1"
     8  		kind:       "Deployment"
     9  	}
    10  }
    11  template: {
    12  	output: {
    13  		apiVersion: "apps/v1"
    14  		kind:       "Deployment"
    15  		spec: {
    16  			selector: matchLabels: "app.oam.dev/component": context.name
    17  			template: {
    18  				metadata: labels: "app.oam.dev/component": context.name
    19  				spec: containers: [{
    20  					name:  context.name
    21  					image: parameter.image
    22  
    23  					if parameter["cmd"] != _|_ {
    24  						command: parameter.cmd
    25  					}
    26  
    27  					if parameter["env"] != _|_ {
    28  						env: parameter.env
    29  					}
    30  
    31  					if context["config"] != _|_ {
    32  						env: context.config
    33  					}
    34  
    35  					ports: [{
    36  						containerPort: parameter.port
    37  					}]
    38  
    39  					if parameter["cpu"] != _|_ {
    40  						resources: {
    41  							limits: cpu:   parameter.cpu
    42  							requests: cpu: parameter.cpu
    43  						}
    44  					}
    45  				}]
    46  			}
    47  		}
    48  	}
    49  	// workload can have extra object composition by using 'outputs' keyword
    50  	outputs: service: {
    51  		apiVersion: "v1"
    52  		kind:       "Service"
    53  		spec: {
    54  			selector: "app.oam.dev/component": context.name
    55  			ports: [
    56  				{
    57  					port:       parameter.port
    58  					targetPort: parameter.port
    59  				},
    60  			]
    61  		}
    62  	}
    63  	parameter: {
    64  		image: string
    65  		cmd?: [...string]
    66  		port: *80 | int
    67  		env?: [...{
    68  			name:   string
    69  			value?: string
    70  			valueFrom?: secretKeyRef: {
    71  				name: string
    72  				key:  string
    73  			}
    74  		}]
    75  		cpu?: string
    76  	}
    77  }