deployment in version "v1" cannot be handled as a Deployment: no kind "deployment" is registered for version

7/3/2021
apiVersion: apps/v1
kind: deployment
metadata:
  name: mongodb-deployment
  labels:
    app: mongodb
spec:
  replicas: 1
  selector:
    matchLebels:
       app: mongodb
  template:
    metadata:
      lebels:
        app: mongodb
    spec:
     containers:
     - name: mongodb
       image: mongo
       ports:
       - containerPort: 27017
       env:
       - name: MONGO_INITDB_ROOT_USERNAE
         valueFrom:
           secretKeyref:
             name: mongodb-secret
             key: mongo-root-username
       - name: MONGO_INITDB_ROOT_PASSWORD
         valueFrom:
          secretKeyref:
            name: mongodb-secret
            key: mongo-root-password

enter image description here

-- Idehen Scofield
cloud
kubectl
kubernetes
minikube

4 Answers

7/3/2021

kind Deployment is case sensitive, use capital D

kind: Deployment
-- Sudz
Source: StackOverflow

7/4/2021

If above suggestion did not work..then check your kubernetes version. Probably you are using old version which does not support apps/v1 api.

-- subudear
Source: StackOverflow

7/4/2021

You can please check the deployment version Kubernetes supporting.

Try this command :

kubectl api-resources

according to that change the version in YAML file instead of apps/v1 maybe it will be apps/v1beta2

apiVersion: apps/v1
kind: deployment

command

kubectl api-resources 

will print the all supported API version by the cluster you are running.

-- Harsh Manvar
Source: StackOverflow

7/5/2021
  • There are multiple typos in the yaml you have provided in the question.
  • I have corrected them as following , use following yaml and check
apiVersion: apps/v1
kind: Deployment    #corrected typo deployment to Deployment
metadata:
  name: mongodb-deployment
  labels:
    app: mongodb
spec:
  replicas: 1
  selector:
    matchLabels:            #corrected typo matchLebels to matchLabels
       app: mongodb
  template:
    metadata:
      labels:               #corrected typo lebels to labels
        app: mongodb
    spec:
     containers:
     - name: mongodb
       image: mongo
       ports:
       - containerPort: 27017
       env:
       - name: MONGO_INITDB_ROOT_USERNAE
         valueFrom:
           secretKeyRef:                  #corrected typo secretKeyref to secretKeyRef
             name: mongodb-secret
             key: mongo-root-username
       - name: MONGO_INITDB_ROOT_PASSWORD
         valueFrom:
          secretKeyRef:                  #corrected typo secretKeyref to secretKeyRef
            name: mongodb-secret
            key: mongo-root-password
-- confused genius
Source: StackOverflow