【发布时间】:2022-09-30 13:04:36
【问题描述】:
看起来不支持使用 fabric8 的 K8S Java 客户端版本:6.0.0 删除 HorizontalPodAutoscaler。
虽然使用 fabric8 的 K8S Java 客户端 ver:6.0.0 创建 HorizontalPodAutoscaler 很简单。
例如。
HorizontalPodAutoscalerStatus hpaStatus = k8sClient.resource(createHPA())
.inNamespace(namespace)
.createOrReplace().getStatus();
public HorizontalPodAutoscaler createHPA(){
return new HorizontalPodAutoscalerBuilder()
.withNewMetadata()
.withName(applicationName)
.addToLabels(\"name\", applicationName)
.endMetadata()
.withNewSpec()
.withNewScaleTargetRef()
.withApiVersion(hpaApiVersion)
.withKind(\"Deployment\")
.withName(applicationName)
.endScaleTargetRef()
.withMinReplicas(minReplica)
.withMaxReplicas(maxReplica)
.addNewMetric()
.withType(\"Resource\")
.withNewResource()
.withName(\"cpu\")
.withNewTarget()
.withType(\"Utilization\")
.withAverageUtilization(cpuAverageUtilization)
.endTarget()
.endResource()
.endMetric()
.addNewMetric()
.withType(\"Resource\")
.withNewResource()
.withName(\"memory\")
.withNewTarget()
.withType(\"AverageValue\")
.withAverageValue(new Quantity(memoryAverageValue))
.endTarget()
.endResource()
.endMetric()
.withNewBehavior()
.withNewScaleDown()
.addNewPolicy()
.withType(\"Pods\")
.withValue(podScaleDownValue)
.withPeriodSeconds(podScaleDownPeriod)
.endPolicy()
.withStabilizationWindowSeconds(podScaledStabaliztionWindow)
.endScaleDown()
.endBehavior()
.endSpec().build();
}
任何使用 fabric8\'s K8S Java 客户端版本:6.0.0 删除 HorizontalPodAutoscaler 的解决方案都将得到应用。
-
client.autoscaling().v1().horizontalPodAutoscalers().resource(hpa).delete();不工作吗?
标签: java linux kubernetes fabric8 fabric8-maven-plugin