Certified Kubernetes Administrator (CKA) Practice Exam: Part 3

Create a Service Account. Create a service account in the web namespace called webautomation.

Linux

kubectl config use-context acgk8s
kubectl create sa webautomation -n web

Create a ClusterRole That Provides Read Access to Pods. Create a ClusterRole called pod-reader that has get, watch, and list access to all Pods.

Linux

vi pod-reader.yml

pod-reader.yml

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
   name: pod-reader
rules:
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["get", "watch", "list"]   

Linux

Bind the ClusterRole to the Service Account to Only Read Pods in the web Namespace. Bind the ClusterRole to the webautomation service account so that it can read all Pods, but only in the web namespace.

Linux

rb-pod-reader.yml

Linux

There are no pods in this namespace but if there was we'd be able to view them as the webautomation service account.

Last updated