Kubernetes "the server doesn't have a resource type deployments"
Asked Answered
A

6

14

I'm new on kubernetes.

I couldn't get deployments using kubectl but I can see all deployments on kubernetes dashboard. How can i fix this problem?

user@master:~$ kubectl get deployments
error: the server doesn't have a resource type "deployments"

kubernetes version: 1.12

kubectl version: 1.13

kubectl api-versions:

apiregistration.k8s.io/v1

apiregistration.k8s.io/v1beta1

v1

api-resources:

user@master:~$ kubectl api-resources
NAME                     SHORTNAMES   APIGROUP                 NAMESPACED               
KIND
bindings                                                       true         
Binding
componentstatuses        cs                                    false        
ComponentStatus
configmaps               cm                                    true         
ConfigMap
endpoints                ep                                    true         
Endpoints
events                   ev                                    true         
Event
limitranges              limits                                true         
LimitRange
namespaces               ns                                    false        
Namespace
nodes                    no                                    false        
Node
persistentvolumeclaims   pvc                                   true         
PersistentVolumeClaim
persistentvolumes        pv                                    false        
PersistentVolume
pods                     po                                    true         
Pod
podtemplates                                                   true         
PodTemplate
replicationcontrollers   rc                                    true         
ReplicationController
resourcequotas           quota                                 true         
ResourceQuota
secrets                                                        true         
Secret
serviceaccounts          sa                                    true         
ServiceAccount
services                 svc                                   true         
Service
apiservices                           apiregistration.k8s.io   false        
APIService

Thanks for your helps.

-----------Edit 1-----------

Hello @EduardoBaitello, Thank you for quicly reply. The problem is not related to permission.

user@master:~$ kubectl auth can-i get deployments Warning: the server doesn't have a resource type 'deployments' yes user@master:~$ kubectl auth can-i get deployment Warning: the server doesn't have a resource type 'deployment' yes user@master:~$ kubectl auth can-i get namespaces yes user@master:~$ kubectl auth can-i get pods yes

So I think this is not a duplicated question.

user@master:~$ kubectl get po --namespace=kube-system NAME READY STATUS RESTARTS AGE calico-kube-controllers-7c6b876df8-nk7nm 1/1 Running 2 118d calico-node-8lt9f 1/1 Running 3 118d calico-node-d9r9l 1/1 Running 2 118d calico-node-ffqlj 1/1 Running 2 118d dns-autoscaler-57ff59dd4c-c9tjv 1/1 Running 2 118d kube-apiserver-node1 1/1 Running 3 118d kube-controller-manager-node1 1/1 Running 6 118d kube-dns-84467597f5-hf2fn 3/3 Running 6 118d kube-dns-84467597f5-sttgx 3/3 Running 9 118d kube-proxy-node1 1/1 Running 3 118d kube-proxy-node2 1/1 Running 2 118d kube-proxy-node3 1/1 Running 2 118d kube-scheduler-node1 1/1 Running 6 118d kubernetes-dashboard-5db4d9f45f-gkl6w 1/1 Running 3 118d nginx-proxy-node2 1/1 Running 2 118d nginx-proxy-node3 1/1 Running 2 118d tiller-deploy-6f6fd74b68-27fqc 1/1 Running 0 16d

user@master:~$ kubectl get componentstatus NAME STATUS MESSAGE scheduler Healthy ok controller-manager Healthy ok etcd-2 Healthy {"health": "true"} etcd-1 Healthy {"health": "true"} etcd-0 Healthy {"health": "true"}

Alluvion answered 15/3, 2019 at 13:42 Comment(3)
Looks like a duplicated question. Maybe your problem is lack of RBAC permissions to get the deployment api-resource. Can you check the pods from kube-system namespace? (kubectl get po --namespace=kube-system). A crashed etcd pod can cause some missing api-resources...Also, check logs from kube-apiserver pod.Textualism
Possible duplicate of Kubernetes set image missing resource type 'deployment'Textualism
Can you share output: kubectl get deployments -v10?Sorrows
K
11

The first step would be to increase a verbosity level to help in finding out the root cause:

Kubectl get deployments --v=99

Overall, there few things that might cause it:

  1. You might have run commands below as a root user, not a regular one. So run as a regular user

cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

chown $(id -u):$(id -g) $HOME/.kube/config

As suggested here https://github.com/kubernetes/kubernetes/issues/52636

  1. Certificates in kubectl config file expired or if the cluster is in "AWS EKS" then IAM access keys might be inactive.

In my case when running "kubectl get deployments --v=99" in addition to “the server doesn't have a resource type deployments” it showed that:

Response Body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Unauthorized","reason":"Unauthorized","code":401

If it is the case then check out your certificates kubectl config file (they might not be there, expired, new ones have to be created, etc) or if on EKS then IAM keys issued/activated.

  1. Lack of RBAC permissions so that a user/group for whom certificates/keys issued/signed are not allowed to view specific resources.
Kastroprauxel answered 22/9, 2019 at 11:2 Comment(1)
Use verbose option helped in getting the idea around errors( --v=99).Closing
D
3

please change user to root and try the same. It worked for me

Diagnosis answered 7/10, 2019 at 23:51 Comment(0)
D
2

I was experiencing exactly the same behavior as in "Edit 1" above with Kubernetes 1.13.5 (client and server). Removing the ~/.kube/http-cache directory on the client worked for me.

Digger answered 4/7, 2019 at 15:41 Comment(1)
wasn't helpful in my caseKastroprauxel
L
2

I delete ~/.kube directory, then remake the directory and move KUBECONFIG file into it. That works for me.

Laurent answered 18/11, 2021 at 11:8 Comment(0)
S
0

@AliCan

I suspect this is because of Kubectl binary version. I noticed your kubectl version(1.13) is higher than the Kubernetes version(1.12).

can you try downgrading your kubectl version to 1.12 or lower?

Stoat answered 3/4, 2019 at 10:55 Comment(0)
A
0

This seems to be typo, it is deployment and not deployments.

trying running this command kubectl get deployment -A - This should provide all deployments across all namespaces.

Agrippina answered 16/6 at 18:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.