Kubernetes “种类不匹配”;“部署”;在“版本”中;扩展/v1beta1“;

Kubernetes “种类不匹配”;“部署”;在“版本”中;扩展/v1beta1“;,kubernetes,Kubernetes,在部署mojaloop时,Kubernetes会响应以下错误: 错误:验证失败:[无法识别“”:种类没有匹配项 版本“apps/v1beta2”中的“部署”,无法识别“”:否 与版本“extensions/v1beta1”中的“Deployment”类型匹配,无法 要识别“”:版本中的“StatefulSet”种类没有匹配项 “apps/v1beta2”,无法识别“”:种类没有匹配项 版本“apps/v1beta1”中的“StatefulSet”] 我的Kubernetes版本是1.16。 如何

在部署mojaloop时,Kubernetes会响应以下错误:

错误:验证失败:[无法识别“”:种类没有匹配项 版本“apps/v1beta2”中的“部署”,无法识别“”:否 与版本“extensions/v1beta1”中的“Deployment”类型匹配,无法 要识别“”:版本中的“StatefulSet”种类没有匹配项 “apps/v1beta2”,无法识别“”:种类没有匹配项 版本“apps/v1beta1”中的“StatefulSet”]

我的Kubernetes版本是1.16。
如何解决API版本的问题?
通过调查,我发现Kubernetes不支持apps/v1beta2、apps/v1beta1。
如何使Kubernetes使用未弃用的版本或其他受支持的版本


我是Kubernetes的新手,任何能支持我的人我都很高兴在Kubernetes 1.16中,一些api已经更改

您可以使用以下命令检查哪些API支持当前Kubernetes对象

$ kubectl api-resources | grep deployment
deployments                       deploy       apps                           true         Deployment
这意味着只有带有
应用程序的apiVersion才能正确地进行部署(
扩展程序
不支持
部署
)。StatefulSet的情况也一样

您需要将部署和状态更改为apiVersion:apps/v1

如果这没有帮助,请将您的YAML添加到问题中

编辑 由于该问题是由部署中包含旧版本的HELM模板(版本1.16不支持)引起的,因此有两种可能的解决方案:

1.
git克隆整个repo,并使用脚本将所有模板/deployment.yaml中的apiVersion替换为
apps/v1

2.当验证器将
扩展接受为
部署
状态集
apiVersion
时,使用旧版本的Kubernetes(1.15)这让我很恼火,因为我正在测试很多helm软件包,所以我编写了一个快速脚本,可以修改它来排序您的工作流程 见下文

新工作流程 首先将图表作为tgz提取到工作目录中

helm fetch repo/chart
然后在您的工作中直接运行下面的bash脚本-我将其命名为helmk

helmk myreleasename mynamespace chart.tgz [any parameters for kubectl create]
helmk的内容-需要编辑kubeconfig clustername才能工作

#!/bin/bash
echo usage $0 releasename namespace chart.tgz [createparameter1] [createparameter2] ... [createparameter n]
echo This will use your namespace then shift back to default so be careful!!
kubectl create namespace $2   #this will create harmless error if namespace exists have to ignore
kubectl config set-context MYCLUSTERNAME --namespace $2
helm template -n $1 --namespace $2 $3 | kubectl convert -f /dev/stdin | kubectl create --save-config=true ${@:4}  -f /dev/stdin
#note the --namespace parameter in helm template above seems to be ignored so we have to manually switch context
kubectl config set-context MYCLUSTERNAME --namespace default
这是一个有点危险的黑客行为,因为我手动切换到您想要的新名称空间上下文,然后再切换回来,所以只用于单用户开发或注释

您将收到一条关于像这样使用kubectl convert工具的警告

如果您需要编辑YAML以进行定制,只需将/dev/stdin中的一个替换为中间文件,但最好使用“create”和“save config”将其设置为我的配置,然后简单地“apply”您的更改,这意味着它们也将被记录在kubernetes中。
祝你好运

你也可以手动更改。获取舵图:

helm fetch --untar stable/metabase
访问图表文件夹:

cd ./metabase
更改API版本:

sed -i 's|extensions/v1beta1|apps/v1|g' ./templates/deployment.yaml
添加
spec.selector.matchLabels

spec:
[...]
selector:
    matchLabels:
    app: {{ template "metabase.name" . }}
[...]
最后安装更改后的图表:

helm install ./ \
  -n metabase \
  --namespace metabase \
  --set ingress.enabled=true \
  --set ingress.hosts={metabase.$(minikube ip).nip.io}

享受吧

简而言之,您不会强制当前安装使用过时的API版本;您可以在配置文件中修复该版本。 如果要检查当前kube支持的版本,请运行:

root@ubn64:~#kubectl api版本| grep-i应用程序
应用程序/v1

要将较旧的部署转换为apps/v1,您可以运行:

kubectl convert -f ./my-deployment.yaml --output-version apps/v1

我遇到了以下错误-
错误:无法识别“deployment.yaml”:版本“extensions/v1beta1”中的类型“deployment”没有匹配项

对我有效的解决方案-

在deployment.yaml中将行从apiVersion:extensions/v1beta1修改为apiVersion:apps/v1

理由-
我们升级了K8群集,因此发生了此错误。

在升级到不支持某些api版本(v1.17和apps/v1beta2)的群集上,我遇到了相同的问题

查看helm文档,清单似乎存储在集群中供helm参考,并且可能包含无效的api版本,从而导致错误

这两种方法要么手动编辑清单(一个相当繁琐的多阶段过程),要么使用一个名为helm的插件自动完成

$ helm plugin install https://github.com/hickeyma/helm-mapkubeapis
可以使用
--dry run
标志运行,以模拟效果:

$ helm mapkubeapis --dry-run some-deployment
2021/02/15 09:33:29 NOTE: This is in dry-run mode, the following actions will not be executed.
2021/02/15 09:33:29 Run without --dry-run to take the actions described below:
2021/02/15 09:33:29
2021/02/15 09:33:29 Release 'some-deployment' will be checked for deprecated or removed Kubernetes APIs and will be updated if necessary to supported API versions.
2021/02/15 09:33:29 Get release 'some-deployment' latest version.
2021/02/15 09:33:30 Check release 'some-deployment' for deprecated or removed APIs...
2021/02/15 09:33:30 Found deprecated or removed Kubernetes API:
"apiVersion: apps/v1beta2
kind: Deployment"
Supported API equivalent:
"apiVersion: apps/v1
kind: Deployment"
2021/02/15 09:33:30 Finished checking release 'some-deployment' for deprecated or removed APIs.
2021/02/15 09:33:30 Deprecated or removed APIs exist, updating release: some-deployment.
2021/02/15 09:33:30 Map of release 'some-deployment' deprecated or removed APIs to supported versions, completed successfully.

然后不带标志运行以应用更改。

我更喜欢
kubectl explain

# kubectl explain deploy
KIND:     Deployment
VERSION:  apps/v1

DESCRIPTION:
     Deployment enables declarative updates for Pods and ReplicaSets.

FIELDS:
   apiVersion   <string>
     APIVersion defines the versioned schema of this representation of an
     object. Servers should convert recognized schemas to the latest internal
     value, and may reject unrecognized values. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

   kind <string>
     Kind is a string value representing the REST resource this object
     represents. Servers may infer this from the endpoint the client submits
     requests to. Cannot be updated. In CamelCase. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

   metadata     <Object>
     Standard object metadata.

   spec <Object>
     Specification of the desired behavior of the Deployment.

   status       <Object>
     Most recently observed status of the Deployment.
#kubectl解释部署
种类:部署
版本:apps/v1
说明:
部署支持POD和复制集的声明性更新。
领域:
蜂房
APIVersion定义了
对象服务器应将已识别的架构转换为最新的内部架构
值,并可能拒绝无法识别的值。更多信息:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
友善的
种类是表示此对象的REST资源的字符串值
代表。服务器可以从客户端提交的端点推断出这一点
请求。无法更新。在这种情况下。更多信息:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-种类
元数据
标准对象元数据。
规格
部署所需行为的规范。
地位
最近观察到的部署状态。

重写您的清单文件以使用当前支持的API我如何重现问题您能否与我分享一些步骤我是否可以降级Kubernette?因为mojaloop的所有部署yaml文件都与kuberntes 1.15版兼容,所以我如何降级或通过进行降级我是否可以获得解决方案?我已经检查了此mojaloop/mojaloop舵图。不幸的是,所有部署的模板都有APIVersion:
extensions/v1beta1
。作为可能的工作之一
# kubectl explain deploy
KIND:     Deployment
VERSION:  apps/v1

DESCRIPTION:
     Deployment enables declarative updates for Pods and ReplicaSets.

FIELDS:
   apiVersion   <string>
     APIVersion defines the versioned schema of this representation of an
     object. Servers should convert recognized schemas to the latest internal
     value, and may reject unrecognized values. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

   kind <string>
     Kind is a string value representing the REST resource this object
     represents. Servers may infer this from the endpoint the client submits
     requests to. Cannot be updated. In CamelCase. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

   metadata     <Object>
     Standard object metadata.

   spec <Object>
     Specification of the desired behavior of the Deployment.

   status       <Object>
     Most recently observed status of the Deployment.