The CustomResourceDefinition "elasticsearches.elasticsearch.k8s.elastic.co" is invalid

I apply this command on my kubernetes cluster
kubectl delete -f https://download.elastic.co/downloads/eck/0.9.0/all-in-one.yaml

I get this error:

The CustomResourceDefinition "elasticsearches.elasticsearch.k8s.elastic.co" is invalid:
* status.storedVersions[0]: Invalid value: "v1beta1": must appear in spec.versions
* status.storedVersions[1]: Invalid value: "v1": must appear in spec.versions

Any help is highly appreciated.

It looks like you had ECK v1.0.0 installed at some point according to the logs.

Are you trying to uninstall ECK completely? You should probably run your delete command with the 1.0.0 URL:

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

I ran the above command. It says

customresourcedefinition.apiextensions.k8s.io "apmservers.apm.k8s.elastic.co" deleted
customresourcedefinition.apiextensions.k8s.io "elasticsearches.elasticsearch.k8s.elastic.co" deleted
customresourcedefinition.apiextensions.k8s.io "kibanas.kibana.k8s.elastic.co" deleted
clusterrole.rbac.authorization.k8s.io "elastic-operator" deleted
clusterrolebinding.rbac.authorization.k8s.io "elastic-operator" deleted
namespace "elastic-system" deleted
statefulset.apps "elastic-operator" deleted
serviceaccount "elastic-operator" deleted
Error from server (NotFound): error when deleting "https://download.elastic.co/downloads/eck/1.0.0/all-in-one.yaml": validatingwebhookconfigurations.admissionregistration.k8s.io "elastic-webhook.k8s.elastic.co" not found
Error from server (NotFound): error when deleting "https://download.elastic.co/downloads/eck/1.0.0/all-in-one.yaml": services "elastic-webhook-server" not found
Error from server (NotFound): error when deleting "https://download.elastic.co/downloads/eck/1.0.0/all-in-one.yaml": secrets "elastic-webhook-server-cert" not found

I then run

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

then apply command for fresh CRDs of v0.9.0

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

I get again the same error

customresourcedefinition.apiextensions.k8s.io/apmservers.apm.k8s.elastic.co created
customresourcedefinition.apiextensions.k8s.io/trustrelationships.elasticsearch.k8s.elastic.co created
customresourcedefinition.apiextensions.k8s.io/kibanas.kibana.k8s.elastic.co created
clusterrole.rbac.authorization.k8s.io/elastic-operator created
clusterrolebinding.rbac.authorization.k8s.io/elastic-operator created
namespace/elastic-system created
statefulset.apps/elastic-operator created
secret/webhook-server-secret created
serviceaccount/elastic-operator created
The CustomResourceDefinition "elasticsearches.elasticsearch.k8s.elastic.co" is invalid:
* status.storedVersions[0]: Invalid value: "v1beta1": must appear in spec.versions
* status.storedVersions[1]: Invalid value: "v1": must appear in spec.versions

You may have existing v1 or v1beta1 Elasticsearch resources around?

kubectl get elasticsearch --all-namespaces

They should be deleted first.