Not able to create role in kubernetes challenge 1

its asking for user name and password

1 Like

image

Hi @ranjithgoud4949,

Thank you for your question,
Can you please respond on following question than we can help better :

  • Which context did you use to create role ?
  • Are you already create user martin and context developer and how ??
  • You can give us kubectl config view output

Thank

this is the question and answer and its not about just role im not able to get pods , services . for every request its asking for the username and password @mmkmou

Hi @ranjithgoud4949,

Thank you for your quick response, i’m not able to reproduce your issue but i can give you some tracks to achieve the challenge.

You need to follow a specific order as admin :

  • create user Martin on default kubeconfig file
kubectl config set-credentials martin  --client-certificate=./martin.crt --client-key=./martin.key --embed-certs=true
  • create context developer
kubectl config set-context developer --cluster=kubernetes --user=martin --namespace=development

At this step you need to create first Role and RoleBinding before switch to context developer. User Martin has no role assigned to him so he can’t do anything

  • Create Role
kubectl create role developer-role --verb=* --resource=services,persistentvolumeclaims,pods --dry-run=client --namespace=development --output=yaml > developer-role.yaml

you can edit the file developer-role.yaml to check if all is ok, you will have something like :

and now you can create the role
Capture d’écran 2022-08-30 à 20.32.54

  • Create role binding

kubectl create rolebinding developer-rolebinding --user=martin --role=developer-role --namespace=development -o yaml --dry-run=client > developer-rolebinding.yaml

edit to check if all is ok

apply the rolebinding

kubectl create -f developer-rolebinding.yaml
  • At this step you can now check if martin can access to pod, pvc and services

At this step now you can switch to context developer and continue the challenge

kubectl config use-context developer

The final config view should be :

To resume :

  • Create credentials Martin
  • Create context developer with namespace development
  • With Admin create Role and Rolebinding on development namespace
  • Switch context to developer
  • Continue the challenge

Good luck

Thanks @mmkmou this is helpful