天天看點

Kubernetes - 6.4 Config and Storage - Serivce Account

什麼是Service Account

Service Account是為了解決Kubernetes叢集内部資源認證問題而誕生,例如Pod的程序想調用Kubernetes API或者其他外部服務。

Service Account基本操作

通過kubectl建立ServiceAccount

kubectl create sa nginx-sa

Kubernetes - 6.4 Config and Storage - Serivce Account

可以見到建立了ServiceAccount之後也自動建立了Secret對象并自動引用了

Kubernetes - 6.4 Config and Storage - Serivce Account

将Service Account綁定到Pod

kubectl apply -f nginx-pod-sa.yaml

apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
spec:
  containers:
    - name: nginx
      image: nginx:1.16
  serviceAccountName: nginx-sa           
Kubernetes - 6.4 Config and Storage - Serivce Account

繼續閱讀