Kubernetes versions:
1.15.2 版
场景显示:
Kubernetes v1.15.2 添加了一些新的 API 版本,例如自动缩放组中的autoscaling/v2beta2
。但是在阅读了 kubernetes 代码srck8s.iokubernetespkgcontrollerpodautoscaler
中的 HorizontalController 结构后,HorizontalController 中的所有成员都autoscaling/v1
了。
type HorizontalController struct {
scaleNamespacer scaleclient.ScalesGetter ==> autoscaling/v1
hpaNamespacer autoscalingclient.HorizontalPodAutoscalersGetter ==> autoscaling/v1
mapper apimeta.RESTMapper
replicaCalc *ReplicaCalculator
eventRecorder record.EventRecorder
downscaleStabilisationWindow time.Duration
// hpaLister is able to list/get HPAs from the shared cache from the informer passed in to
// NewHorizontalController.
hpaLister autoscalinglisters.HorizontalPodAutoscalerLister ==> autoscaling/v1
hpaListerSynced cache.InformerSynced ==> autoscaling/v1
// podLister is able to list/get Pods from the shared cache from the informer passed in to
// NewHorizontalController.
podLister corelisters.PodLister
podListerSynced cache.InformerSynced
// Controllers that need to be synced
queue workqueue.RateLimitingInterface
// Latest unstabilized recommendations for each autoscaler.
recommendations map[string][]timestampedRecommendation
}
那么 kubernetes 如何使用 HorizontalController 维护自动缩放/v2beta2 资源呢?
在官方 kubernetes 文档中,您可以找到以下信息:
接口对象
Horizontal Pod Autoscaler 是 Kubernetes
autoscaling
API 组中的 API 资源。当前稳定版本(仅包括对 CPU 自动缩放的支持(可在autoscaling/v1
API 版本中找到。测试版包括对内存扩展和自定义指标的支持,可以在
autoscaling/v2beta2
中找到。autoscaling/v2beta2
中引入的新字段在使用autoscaling/v1
时将保留为注释。有关 API 对象的更多详细信息,请参阅 HorizontalPodAutoscaler Object。
另外,根据 API 版本控制下有关 API 概述的 kubernetes 文档:
API 版本控制
要消除字段或重构资源表示形式, Kubernetes 支持多个 API 版本,每个版本都有不同的 API 路径。例如:
/api/v1
或/apis/extensions/v1beta1
。版本是在 API 级别设置的,而不是在资源或 字段级别到:
- 确保 API 提供清晰一致的系统资源和行为视图。
- 启用对生命周期结束和/或实验性 API 的控制访问。
JSON 和 Protobuf 序列化架构遵循相同的准则 用于架构更改。以下说明涵盖了这两种格式。
因此,您可以在 kubernetes/pkg/apis/autoscaling/下找到autoscaling
(如v2beta2
(的所有 apis 版本。
例如,使用HTTP GET
将是这样的:GET /apis/autoscaling/v2beta2