假设我有这个 VPA 配置文件:
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: vpa-reco
spec:
targetRef:
apiVersion: "batch/v1beta1"
kind: CronJob
name: test-autoscaling-1
updatePolicy:
updateMode: "Off"
如何使我的 VPA 目标也成为 CronJob test-autoscaling-2
?
最佳答案
遗憾的是,您无法在单个 VPA
对象中引用多个对象。
如果您尝试如下所示(在单个 VPA
中拥有 2 个 CronJobs
):
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: vpa-reco
spec:
targetRef:
- apiVersion: "batch/v1beta1"
kind: CronJob
name: test-autoscaling-1
- apiVersion: "batch/v1beta1"
kind: CronJob
name: test-autoscaling-2
updatePolicy:
updateMode: "Off"
您应该得到类似于下面的错误(部分错误):
denied the request: json: cannot unmarshal array into Go struct field VerticalPodAutoscalerSpec.targetRef of type v1.CrossVersionObjectReference
要为 test-autoscaling-1
和 test-autoscaling-2
配置 VPA
,您需要创建2 个独立的 VPA
对象,例如:vpa-reco-1
和 vpa-reco-2
。
从VPA
和CronJob
的角度来说,在0.7.0
版本中添加了对它的支持。可以在这个特定的发行说明中找到更多信息:
其他资源:
关于Kubernetes,一个VPA可以管理多个Cronjobs吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66232832/