1.
kubectl create role a-plus-deployments-get --verb=get,list,watch,update --resource=deployments --resource=pods --namespace=a-plus
kubectl create rolebinding a-plus-user --role=a-plus-role --serviceaccount=a-plus:a-plus-sa --namespace=a-plus
kubectl auth can-i get pods -n=a-plus --as=system:serviceaccount:a-plus:a-plus-sa
docker run -d --network=host --name=kubectl-host --rm -it piotrzan/kubectl-comp
docker exec -ti e5fd65b112ae /bin/bash
2. запускаем команды поочередно в контейнере для подключения к вашему кластеру
kubectl config set-cluster eks-cluster --server=https://yourserver:443
===========================================================================
root@docker-desktop:~# kubectl get pods -n a-plus --insecure-skip-tls-verify
NAME READY STATUS RESTARTS AGE
api-6586d66f9f-642zx 1/1 Running 0 2d7h
api-6586d66f9f-fqjtm 1/1 Running 0 31h
api-6586d66f9f-vp29t 1/1 Running 0 31h
business-api-dc455f645-4nqhz 1/1 Running 0 133m
cdn-api-85bcb56559-9ncsv 1/1 Running 0 124m
cdn-api-85bcb56559-fns94 1/1 Running 0 66m
cdn-api-85bcb56559-pj5g6 1/1 Running 0 124m
events-api-6bb4ccdb6b-8gjlj 1/1 Running 0 7d4h
events-api-6bb4ccdb6b-b2pmf 1/1 Running 0 7d8h
events-api-6bb4ccdb6b-gp6nn 1/1 Running 0 7d8h
frontend-5fb58bb6b5-zfqnk 1/1 Running 0 25h
oauth-779695bf74-s5bcb 1/1 Running 0 4h28m
rabbitmq-0 1/1 Running 0 13d
redis-0 1/1 Running 0 14d
redis-1 1/1 Running 0 14d
templater-api-54b7dd5495-65brt 1/1 Running 0 131m
root@docker-desktop:~# kubectl get deployments -n a-plus --insecure-skip-tls-verify
NAME READY UP-TO-DATE AVAILABLE AGE
api 3/3 3 3 2d9h
business-api 1/1 1 1 2d4h
cdn-api 3/3 3 3 14d
events-api 3/3 3 3 14d
frontend 1/1 1 1 30h
oauth 1/1 1 1 2d6h
templater-api 1/1 1 1 14d
root@docker-desktop:~# kubectl get pods -n default --insecure-skip-tls-verify
Error from server (Forbidden): pods is forbidden: User "system:serviceaccount:a-plus:a-plus-sa" cannot list resource "pods" in API group "" in the namespace "default"
root@docker-desktop:~# kubectl get deployments -n kube-system --insecure-skip-tls-verify
Error from server (Forbidden): deployments.apps is forbidden: User "system:serviceaccount:a-plus:a-plus-sa" cannot list resource "deployments" in API group "apps" in the namespace "kube-system"
Комментариев нет:
Отправить комментарий