Service+Accounts+in+Kubernetes+Cluster.pdf
376.6 kB
If any pod has to access k8s api then a service account need to be created.
Creating a Service Account
apiVersion: v1
kind: ServiceAccount
metadata:
name: my-serviceaccount
namespace: development
automountServiceAccountToken: false
Assigning the service account using rolebinding
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: sa-pod-reader
namespace: development
subjects:
- kind: ServiceAccount
name: my-serviceaccount
namespace: development
roleRef:
kind: Role
name: pod-reader
apiGroup: rbac.authorization.k8s.io