gpt4 book ai didi

Kubernetes 为同一个 Deployment 报告不同的 apiVersion

转载 作者:行者123 更新时间:2023-12-02 11:53:03 24 4
gpt4 key购买 nike

由于 Kubernetes 删除了已弃用的 API,我试图找出集群中资源的 apiVersion 并遇到以下行为。

在为特定部署请求定义时,它会报告旧的 api 版本:

> kubectl get deployment/some-deployment -o yaml
apiVersion: extensions/v1beta1
kind: Deployment
...

Bud 请求所有资源 api 版本报告为同一资源的新版本时:
> kubectl get all -o yaml
...
- apiVersion: apps/v1
kind: Deployment
...

检查 selfLink 时也是如此在元数据中:
kubectl get all -o=custom-columns=NAME:.metadata.name,API-version:.metadata.selfLink
and
kubectl get deployment/some-deployment -o=custom-columns=NAME:.metadata.name,API-version:.metadata.selfLink

这应该如何解释?

Kubernetes 版本是 1.15.7。

最佳答案

引自 here

kubectl get deployment foo is ambiguous, since the server has deployments in multiple api groups. When a resource exists in multiple api groups, kubectl uses the first group listed in discovery docs published by the server which contains the resource. For backwards compatibility, that is the extensions api group.

If you want to ensure you get a deployment in the apps api group, fully qualify the resource you are requesting by running kubectl get deployments.apps test-nginx

If you want a specific version, like v1, in the apps api group, include that as well: kubectl get deployments.v1.apps test-nginx


也来自 here

What stored version is used for?

It is the serialized version in etcd. Whenever you fetch an object, the api server reads it from etcd, converts it into an internal version, then converts it to the version you requested.


所以,如果你跑
$ kubectl get deployments nginx -o name
deployment.extensions/nginx
如您所见,上述命令的请求版本是 deployment.extensions如果你跑
$ kubectl get all -o name
...
deployment.apps/nginx
请求的版本是 deployment.apps .因此,它返回带有 apps/v1 的版本
引用: https://github.com/kubernetes/kubernetes/issues/58131

关于Kubernetes 为同一个 Deployment 报告不同的 apiVersion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61957962/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com