Created
June 20, 2022 13:42
-
-
Save RajputVaibhav/aec67eceedefb5907fb10ae0a832a6fb to your computer and use it in GitHub Desktop.
HPA trait definition for Medium blog on KubeVela
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: core.oam.dev/v1beta1 | |
kind: TraitDefinition | |
metadata: | |
annotations: | |
definition.oam.dev/description: "configure k8s Horizontal Pod Autoscaler for Component which using Deployment as worklaod" | |
name: hpa | |
spec: | |
appliesToWorkloads: | |
- deployments.apps | |
workloadRefPath: spec.scaleTargetRef | |
schematic: | |
cue: | |
template: | | |
outputs: hpa: { | |
apiVersion: "autoscaling/v2beta2" | |
kind: "HorizontalPodAutoscaler" | |
spec: { | |
minReplicas: parameter.min | |
maxReplicas: parameter.max | |
metrics: [{ | |
type: "Resource" | |
resource: { | |
name: "cpu" | |
target: { | |
type: "Utilization" | |
averageUtilization: parameter.cpuUtil | |
} | |
} | |
}] | |
} | |
} | |
parameter: { | |
min: *1 | int | |
max: *10 | int | |
cpuUtil: *50 | int | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment