UCS 微服务附加功能
水平 Pod 自动扩缩器 (HPA) 支持
HPA 是 Kubernetes 中的一项出色功能,允许工作负载根据资源使用情况(例如内存或 CPU)或自定义资源动态向上和向下扩展。
UCS 微服务定义允许设置这些 HPA 要求。在 manifest.py 中,用户可以设置 ucf.k8s.app.deployment
内置组件的 hpa
参数。以下是为示例 echo 服务器设置内存和 CPU 目标利用率值的示例(请注意,为了简洁起见,省略了几个 manifest 组件)。具体而言,HPA 设置表明 Pod 应根据 CPU 资源利用率和内存利用率阈值在最少 1 个 Pod 和最多 4 个 Pod 之间相应地向上和向下扩展。为每个阈值定义的百分比(在本例中为 75%)是 Pod 资源请求中定义的相应目标值的百分比。
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
有关 HPA 的更多信息,请参阅 Kubernetes HPA 文档。