Search code examples
mongodbkubernetesconfiguration-files

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


I am following a MongoDB tutorial on Kubernetes, but when I create the configuration map, it gives me this error:

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

This is the mongo-configmap.yaml file:

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

Solution

  • The version should be lower case.

    apiVersion: v1
    lang-none
    

    You can run the below command to refer to the attributes.

    kubectl explain cm | head
    

    Or

    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>