Unable to install CRDs in kubernetes kind

ghz 7months ago ⋅ 136 views

I am setting up a kind cluster

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 💚

and then trying to install ECK operator as per instructions about version 1.6

kubectl apply -f https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml

However the process fails, as if kind does not support CRDs...Is this the case?

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"

Answers

The issue you're encountering is due to the fact that Kubernetes v1.22 has deprecated and removed the apiextensions.k8s.io/v1beta1 version for CustomResourceDefinitions (CRDs) and admissionregistration.k8s.io/v1beta1 for webhook configurations. Instead, you should use apiextensions.k8s.io/v1 and admissionregistration.k8s.io/v1, respectively.

The Elastic Cloud on Kubernetes (ECK) operator v1.6.0 likely uses these deprecated versions, which is why it fails on your Kind cluster running Kubernetes v1.22.1.

To resolve this issue, you have a couple of options:

  1. Use a Compatible Version of ECK Operator: Find a version of the ECK operator that supports Kubernetes v1.22. This would mean looking for a release that uses apiextensions.k8s.io/v1 and admissionregistration.k8s.io/v1.

  2. Manually Update the CRD and Webhook Configurations: If you need to use ECK v1.6.0 specifically, you could download the all-in-one.yaml file and manually update the API versions to the new ones. However, this might involve more work as you need to ensure compatibility.

Option 1: Use a Compatible Version

Elastic typically maintains compatibility matrices for their products. Check the ECK documentation for the latest version that supports Kubernetes v1.22.

For instance, to install the latest version compatible with Kubernetes v1.22, you could use:

kubectl apply -f https://download.elastic.co/downloads/eck/2.1.0/all-in-one.yaml

(Replace 2.1.0 with the latest version that supports Kubernetes v1.22)

Option 2: Manually Update the YAML File

  1. Download the all-in-one.yaml file:

    curl -O https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml
    
  2. Open the all-in-one.yaml file and update the apiVersion fields for CustomResourceDefinition and ValidatingWebhookConfiguration:

    • Change apiextensions.k8s.io/v1beta1 to apiextensions.k8s.io/v1
    • Change admissionregistration.k8s.io/v1beta1 to admissionregistration.k8s.io/v1
  3. Apply the modified all-in-one.yaml:

    kubectl apply -f all-in-one.yaml
    

Example of Manual Changes

Here's a snippet of how you would change the CustomResourceDefinition:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: elasticsearches.elasticsearch.k8s.elastic.co
spec:
  group: elasticsearch.k8s.elastic.co
  versions:
  - name: v1
    served: true
    storage: true
  scope: Namespaced
  names:
    plural: elasticsearches
    singular: elasticsearch
    kind: Elasticsearch
    shortNames:
    - es

And for the ValidatingWebhookConfiguration:

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
  name: elastic-webhook.k8s.elastic.co
webhooks:
  - name: validation.elastic.k8s.elastic.co
    rules:
      - apiGroups:
          - elasticsearch.k8s.elastic.co
        apiVersions:
          - v1
        operations:
          - CREATE
          - UPDATE
        resources:
          - elasticsearches
    clientConfig:
      service:
        name: elastic-webhook-server
        namespace: elastic-system
        path: "/validate-elasticsearch-k8s-elastic-co-v1-elasticsearch"
      caBundle: <base64-encoded-ca-cert>

After making these updates, you should be able to apply the configuration without errors.

By using one of these approaches, you should be able to install ECK on your Kind cluster running Kubernetes v1.22.