UCS Microservice Additional Features#
Horizontal Pod Autoscaler (HPA) support#
HPA is a nice feature in Kubernetes that allows for workloads to dynamically scale up and down based on resource useage, such as memory or CPU, or custom resources.
A UCS Microservice definition allows for setting these HPA requirements. In the manifest.py, the user can set the hpa
parameter of the ucf.k8s.app.deployment
built-in component. Below is an example of setting memory and cpu target utilization values for an example echo server (note that several manifest components have been omitted for brevity). Specifically, the HPA setings on indicate that pods should be scaled up and down accordingly between a minimum of 1 pod and a maximum of 4, based on CPU resource utilization and memory utilization thresholds. The threshold defined for each is a percentage (75% in this example) of the corresponding target value defined within the pod resource requests.
type: msapplication
specVersion: 2.5.0
name: ucf.svc.echo
chartName: echo-server
description: Echo server example
version: 0.0.1
displayName: "Echo Server"
nSpectId: NSPECT-0000-0000
ingress-endpoints:
- name: http-api
description: Short description of http-api ingress endpoint
scheme: http
data-flow: in-out # Or in or out
#params:
#stringToEcho: someString
#> type: string
#> enum_values: someString, someOtherString
#> description: String to echo in init container
---
spec:
- name: echo-deployment
type: ucf.k8s.app.deployment
parameters:
apptype: stateless
hpa:
maxReplicas: 4
minReplicates: 1 # default if not specified
cpu:
averageUtilization: 75
memory:
averageUtilization: 75
- name: "echo-container"
type: ucf.k8s.container
parameters:
image:
repository: ealen/echo-server
tag: "0.9.2"
ports:
- containerPort: 80
name: http
- containerPort: 8002
name: metrics
resources:
limits:
cpu: "0.5"
memory: "500Mi"
- name: echo-service
type: ucf.k8s.service
parameters:
fullNameOverride: true
ports:
- port: 3000
name: http-api
targetPort: 80
See the Kubernetes HPA documentation for more information about HPA.