Error: unable to recognize "mongo-configmap.yaml": no matches for kind "ConfigMap" in version "V1"

Error: unable to recognize "mongo-configmap.yaml": no matches for kind "ConfigMap" in version "V1"

我正在学习关于 Kubernetes 的 MongoDB 教程,但是当我创建配置映射时,它给我这个错误:

error: unable to recognize "mongo-configmap.yaml": no matches for kind "ConfigMap" in version "V1"

这是mongo-configmap.yaml文件:

apiVersion: V1
kind: ConfigMap
metadata:
  name: mongodb-configmap
data:
  database_url: mongodb-service

版本应该是小写的。

apiVersion: v1
lang-none

您可以运行下面的命令来引用属性。

kubectl explain cm | head

或者

kubectl explain cm --recursive | grep -i <attribute> or head
KIND:     ConfigMap
VERSION:  v1

DESCRIPTION:
     ConfigMap holds configuration data for pods to consume.

FIELDS:
   apiVersion    <string>
   binaryData    <map[string]string>
   data    <map[string]string>