Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deployments.apps is forbidden: User "system:serviceaccount:default:default" cannot create deployments.apps in the namespace

Tags:

kubernetes

URL: /apis/apps/v1/namespaces/diyclientapps/deployments

) "{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"deployments.apps is forbidden: User \"system:serviceaccount:default:default\" cannot create deployments.apps in the namespace \"diyclientapps\"","reason":"Forbidden","details":{"group":"apps","kind":"deployments"},"code":403}

I'm getting the above error when trying to create a deployment via the Kubernetes REST API.

Why? I don't understand the error message...

This occurs on a custom Kubernetes cluster... The above worked correctly on a local Minikube instance.

I can successfully create a deployment via: kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.4 --port=8080

like image 829
Chris Stryczynski Avatar asked Mar 08 '18 13:03

Chris Stryczynski


1 Answers

WARNING: This allows any user with read access to secrets or the ability to create a pod to access super-user credentials.

kubectl create clusterrolebinding serviceaccounts-cluster-admin \
  --clusterrole=cluster-admin \
  --group=system:serviceaccounts

https://kubernetes.io/docs/admin/authorization/rbac/

like image 93
Chris Stryczynski Avatar answered Oct 20 '22 16:10

Chris Stryczynski