![]() |
VOOZH | about |
We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.
Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.
Follow TNS on your favorite social media networks.
Become a TNS follower on LinkedIn.
Check out the latest featured and trending stories while you wait for your first TNS newsletter.
kubectl config set-context eng-context \ --cluster=minikube \ --namespace=engineering \ --user=bob Context "eng-context" created.
apiVersion: v1 kind: Pod metadata: name: myapp namespace: engineering labels: app: myapp spec: containers: - name: myapp image: busybox command: ["/bin/sh", "-ec", "while :; do echo '.'; sleep 5 ; done"]
kubectl create -f myapp.yaml pod/myapp created
kubectl get pods -n=engineering NAME READY STATUS RESTARTS AGE myapp 1/1 Running 0 89s
kubectl get pods --namespace engineering --as bob Error from server (Forbidden): pods is forbidden: User "bob" cannot list resource "pods" in API group "" in the namespace "engineering"
kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: namespace: engineering name: eng-reader rules: - apiGroups: [""] # "" indicates the core API group resources: ["pods", "services", "nodes"] verbs: ["get", "watch", "list"]
kubectl create -f role.yaml role.rbac.authorization.k8s.io/eng-reader created
kubectl get roles --namespace=engineering NAME AGE eng-reader 58s
kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: eng-read-access namespace: engineering subjects: - kind: User name: bob # Name is case sensitive apiGroup: rbac.authorization.k8s.io roleRef: kind: Role #this must be Role or ClusterRole name: eng-reader # this must match the name of the Role or ClusterRole you wish to bind to apiGroup: rbac.authorization.k8s.io
kubectl create -f role-binding.yaml rolebinding.rbac.authorization.k8s.io/eng-read-access created
kubectl get rolebindings --namespace=engineering NAME AGE eng-read-access 31s
kubectl get pods --namespace engineering --as bob NAME READY STATUS RESTARTS AGE myapp 1/1 Running 0 11m
kubectl get nodes --as bob Error from server (Forbidden): nodes is forbidden: User "bob" cannot list resource "nodes" in API group "" at the cluster scope
kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: # "namespace" omitted since ClusterRoles are not namespaced name: cluster-node-reader rules: - apiGroups: [""] resources: ["nodes"] verbs: ["get", "watch", "list"]
kubectl create -f cluster-role.yaml clusterrole.rbac.authorization.k8s.io/cluster-node-reader created
kubectl get clusterroles cluster-node-reader NAME AGE cluster-node-reader 49s
kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: read-cluster-nodes subjects: - kind: User name: bob # Name is case sensitive apiGroup: rbac.authorization.k8s.io roleRef: kind: ClusterRole name: cluster-node-reader apiGroup: rbac.authorization.k8s.io
kubectl create -f cluster-role-binding.yaml clusterrolebinding.rbac.authorization.k8s.io/read-cluster-nodes created
kubectl get clusterrolebindings read-cluster-nodes NAME AGE read-cluster-nodes 35s
kubectl get nodes --as bob NAME STATUS ROLES AGE VERSION minikube Ready master 52m v1.15.2