Kubernetes Service Account Operations

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Create a Service Account

With CLI

kubectl create serviceaccount -n <namespace> <service-account-name>
kubectl create serviceaccount -n blue blue-serviceaccount

It automatically creates the secret.

With Metadata

apiVersion: v1
kind: ServiceAccount
metadata:
  name: example-sa

It automatically creates the secret.

Details about the Namespace's Default Service Account

kubectl -n <namespace> -o yaml get sa default

Deploy a Service Account, a Role and a Role Binding with a Helm Chart

https://github.com/ovidiuf/playground/tree/master/helm/service-account-and-roles