Skip to content

Instantly share code, notes, and snippets.

@RajputVaibhav
Created June 20, 2022 13:42
Show Gist options
  • Save RajputVaibhav/aec67eceedefb5907fb10ae0a832a6fb to your computer and use it in GitHub Desktop.
Save RajputVaibhav/aec67eceedefb5907fb10ae0a832a6fb to your computer and use it in GitHub Desktop.
HPA trait definition for Medium blog on KubeVela
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