无法以 kubernetes 类型安装 CRD

Unable to install CRDs in kubernetes kind

我正在设置一个 kind 集群

Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:v1.22.1)  
 ✓ Preparing nodes    
 ✓ Writing configuration  
 ✓ Starting control-plane ️ 
 ✓ Installing CNI  
 ✓ Installing StorageClass  
 ✓ Joining worker nodes  
 ✓ Waiting ≤ 5m0s for control-plane = Ready ⏳ 
 • Ready after 0s 

然后尝试根据 instructions 关于版本 1.6

安装 ECK 运算符
kubectl apply -f https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml

但是这个过程失败了,好像kind不支持CRDs...是这样吗?

namespace/elastic-system created
serviceaccount/elastic-operator created
secret/elastic-webhook-server-cert created
configmap/elastic-operator created
clusterrole.rbac.authorization.k8s.io/elastic-operator created
clusterrole.rbac.authorization.k8s.io/elastic-operator-view created
clusterrole.rbac.authorization.k8s.io/elastic-operator-edit created
clusterrolebinding.rbac.authorization.k8s.io/elastic-operator created
service/elastic-webhook-server created
statefulset.apps/elastic-operator created
unable to recognize "https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml": no matches for kind "ValidatingWebhookConfiguration" in version "admissionregistration.k8s.io/v1beta1"

您在这里看到的问题与种类无关,而是您尝试应用的清单使用了过时的 API 版本,这些版本已在 Kubernetes 1.22

中删除

特别是清单使用了 v1beta1 版本的 customresourcedefinition 对象和 validatingadmissionwebhook 对象

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition

this post 中所述,这是 1.22 进入时删除的版本之一。

对此有一些修复。首先,您可以获得清单,只需更改自定义资源定义以使用新的 API 版本 apiextensions.k8s.io/v1 和 validatingadmissionwebhook 以使用 admissionregistration.k8s.io/v1.

另一个修复方法是使用旧版本的 Kubernetes。如果您使用 1.21 或更早的版本,则不应出现该问题,因此 kind create cluster --image=kindest/node:v1.21.2 之类的内容应该会起作用。