You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
root@master:~# kubectl create ns test-ns1
namespace/test-ns1 created
root@master:~# kubectl create ns test-ns2
namespace/test-ns2 created
Creating test Pods:
root@master:~# kubectl run nginx-pod-default --image=nginx
pod/nginx-pod-default created
root@master:~# kubectl run redis-pod-ns1 --image=redis -n test-ns1
pod/redis-pod-ns1 created
root@master:~# kubectl run httpd-pod-ns2 --image=busybox -n test-ns2
pod/httpd-pod-ns2 created
Test Before Deploying:
root@master:~# kubectl get pods --user=appmonitor
Error from server (Forbidden): pods is forbidden: User "appmonitor" cannot list resource "pods"in API group ""in the namespace "default"
root@master:~# kubectl get pods -n test-ns1 --user=appmonitor
Error from server (Forbidden): pods is forbidden: User "appmonitor" cannot list resource "pods"in API group ""in the namespace "test-ns1"
root@master:~# kubectl get pods -n test-ns2 --user=appmonitor
Error from server (Forbidden): pods is forbidden: User "appmonitor" cannot list resource "pods"in API group ""in the namespace "test-ns2"
root@master:~# kubectl get pods -n kube-system --user=appmonitor
Error from server (Forbidden): pods is forbidden: User "appmonitor" cannot list resource "pods"in API group ""in the namespace "kube-system"
root@master:~# kubectl get pods -A --user=appmonitor
Error from server (Forbidden): pods is forbidden: User "appmonitor" cannot list resource "pods"in API group "" at the cluster scope
Pod Operations: get, list, watch - in "kube-system", "default", "test-ns1", and "test-ns2" namespaces:
root@master:~# kubectl auth can-i get pods -n kube-system --user=appmonitor
yes
root@master:~# kubectl auth can-i get pods -n default --user=appmonitor
yes
root@master:~# kubectl auth can-i get pods -n test-ns1 --user=appmonitor
yes
root@master:~# kubectl auth can-i get pods -n test-ns2 --user=appmonitor
yes
root@master:~# kubectl get pods -n kube-system --user=appmonitor
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-56fcbf9d6b-zkhc2 1/1 Running 58 (14h ago) 8d
calico-node-5hfv2 1/1 Running 4 (14h ago) 8d
calico-node-wb5cc 1/1 Running 6 (14h ago) 8d
coredns-64897985d-bzhgt 1/1 Running 4 (14h ago) 8d
coredns-64897985d-jv568 1/1 Running 4 (14h ago) 8d
etcd-master 1/1 Running 13 (34m ago) 8d
kube-apiserver-master 1/1 Running 47 (34m ago) 8d
kube-controller-manager-master 1/1 Running 11 (34m ago) 8d
kube-proxy-g7wcd 1/1 Running 6 (46m ago) 8d
kube-proxy-z6zpg 1/1 Running 4 (14h ago) 8d
kube-scheduler-master 1/1 Running 11 (34m ago) 8d
metrics-server-847dcc659d-9sjvh 0/1 Running 4 (14h ago) 8d
root@master:~# kubectl get pods -n default --user=appmonitor
NAME READY STATUS RESTARTS AGE
nginx-pod-default 1/1 Running 0 7m1s
root@master:~# kubectl get pods -n test-ns1 --user=appmonitor
NAME READY STATUS RESTARTS AGE
redis-pod-ns1 1/1 Running 0 7m1s
root@master:~# kubectl get pods -n test-ns2 --user=appmonitor
NAME READY STATUS RESTARTS AGE
httpd-pod-ns2 0/1 CrashLoopBackOff 5 (2m29s ago) 7m
Creating Objects in "default" (or in any other) namespace:
root@master:~# kubectl auth can-i create pods --user=appmonitor
no
root@master:~# kubectl auth can-i create services --user=appmonitor
no
root@master:~# kubectl auth can-i create deployments --user=appmonitor
no
root@master:~# kubectl run redis-pod --image=redis --user=appmonitor
Error from server (Forbidden): pods is forbidden: User "appmonitor" cannot create resource "pods"in API group ""in the namespace "default"
root@master:~# kubectl create deploy redis-deploy --image=redis --user=appmonitor
error: failed to create deployment: deployments.apps is forbidden: User "appmonitor" cannot create resource "deployments"in API group "apps"in the namespace "default"
Deleting Objects in "default" (or in any other) namespace:
root@master:~# kubectl auth can-i delete pods --user=appmonitor
no
root@master:~# kubectl auth can-i delete services --user=appmonitor
no
root@master:~# kubectl auth can-i delete deployments --user=appmonitor
no
root@master:~# kubectl delete pods nginx-pod --user=appmonitor
Error from server (Forbidden): pods "nginx-pod" is forbidden: User "appmonitor" cannot delete resource "pods"in API group ""in the namespace "default"