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

     1  hpa: {
     2  	type: "trait"
     3  	annotations: {}
     4  	labels: {}
     5  	description: "configure k8s HPA for Deployment"
     6  	attributes: {
     7  		podDisruptive: true
     8  		appliesToWorkloads: ["deployments.apps"]
     9  	}
    10  }
    11  template: {
    12  	outputs: hpa: {
    13  		apiVersion: "autoscaling/v2beta2"
    14  		kind:       "HorizontalPodAutoscaler"
    15  		metadata: name: context.name
    16  		spec: {
    17  			scaleTargetRef: {
    18  				apiVersion: "apps/v1"
    19  				kind:       "Deployment"
    20  				name:       context.name
    21  			}
    22  			minReplicas: parameter.min
    23  			maxReplicas: parameter.max
    24  			metrics: [{
    25  				type: "Resource"
    26  				resource: {
    27  					name: "cpu"
    28  					target: {
    29  						type:               "Utilization"
    30  						averageUtilization: parameter.cpuUtil
    31  					}
    32  				}
    33  			}]
    34  		}
    35  	}
    36  	parameter: {
    37  		min:     *1 | int
    38  		max:     *10 | int
    39  		cpuUtil: *50 | int
    40  	}
    41  }