在部署mojaloop时,Kubernetes会返回以下错误:
错误:验证失败:[无法识别“”:在版本“apps/v1 beta2”中没有与类型“Deployment”匹配的项,无法识别“”:在版本“extensions/v1 beta1”中没有与类型“Deployment”匹配的项,无法识别“”:在版本“apps/v1 beta2”中没有与类型“StatefulSet”匹配的项,无法识别“”:在版本“apps/v1 beta1”中没有与类型“StatefulSet”匹配的项]
Kubernetes版本是1.16。
如何解决API版本的问题?
通过调查,我发现Kubernetes不支持apps/v1 beta2,apps/v1 beta1。
如何让Kubernetes使用未弃用的版本或其他支持的版本?
我是Kubernetes的新手,任何可以支持我的人我都很高兴
8条答案
按热度按时间xytpbqjk1#
在Kubernetes 1.16中,一些
api
被改变了。您可以检查哪些API支持当前的Kubernetes对象
字符串
这意味着只有带有
apps
的apiVersion才适用于Deployments(extensions
不支持Deployment
)。StatefulSet的情况相同。您需要将Deployment和StatefulSet apiVersion更改为
apiVersion: apps/v1
。如果这没有帮助,请将您的YAML添加到问题中。
编辑由于HEM模板在Deployments中包含了旧apiVersions(版本1.16不支持)导致问题,有两种可能的解决方案:
1.
git clone
整个存储库并使用脚本将apiVersion替换为apps/v1
中的所有模板/deployment.yaml**2.**当验证器接受
extensions
为Deployment
和StatefulSet
时,使用旧版本的Kubernetes(1.15)。new9mtju2#
要将较旧的Deployment转换为apps/v1,可以运行:
字符串
xriantvc3#
您也可以手动更改。取舵图:
字符串
访问图表文件夹:
型
更改API版本:
型
添加
spec.selector.matchLabels
:型
最后,安装您更改的图表:
型
好好享受吧!
wmvff8tz4#
我更喜欢
kubectl explain
。字符串
使用
kubectl explain
,您还可以查看对象的特定参数:型
aij0ehis5#
简单地说,您不会强制当前安装使用过时版本的API;你在你的配置文件中修正版本。如果你想查看你当前的kube支持哪个版本,可以运行:
字符串
xe55xuns6#
我在出错以下-
错误:无法识别“deploye.yaml”:在版本“extensions/v1 beta1”中没有匹配类型“Deployment”
对我有效的解决方案-
修改了apiVersion中的行:extensions/v1beta1 to apiVersion:部署中的apps/v1。yaml
原因-我们升级了K8群集,因此发生了此错误。
omqzjyyz7#
这让我很恼火,因为我正在测试大量的helm包,所以我写了一个快速脚本--它可以被修改来排序你的工作流程,也许见下面
新工作流首先将图表作为tgz提取到您的工作目录中
字符串
然后在您的工作中直接运行下面的bash脚本-我命名为helmk
型
helmk的内容-需要编辑您的kubeconfig集群名称才能工作
型
这是一个有点危险的黑客,因为我手动切换到你想要的新名称空间上下文,然后再回来,所以只用于单用户开发者,真的或注解出来。
您将收到一个关于使用Kubectl Convert工具的警告,如下所示
如果你需要编辑YAML来自定义-只需要将/dev/stdin中的一个替换为中间文件,但最好是使用“create”和save-config,然后简单地“apply”你的更改,这意味着它们也会被记录在kubernetes中。祝你好运
a9wyjsp78#
我在一个集群上遇到了同样的问题,该集群升级到了不支持某些API版本(v1.17和apps/v1 beta2)。
字符串
查看Helm文档,清单文件似乎存储在集群中供Helm引用,它可能包含无效的API版本,从而导致错误。
建议的两种方法是手动编辑清单(一个相当繁琐的多阶段过程),或者使用一个名为
mapkubeapis
的helm插件自动编辑清单。型
它可以运行
--dry-run
标志来模拟效果:型
然后在没有标志的情况下运行以应用改变。