y4h2 / personal-notes

my personal notes
0 stars 0 forks source link

Kubernetes ServiceAccount #35

Open y4h2 opened 2 years ago

y4h2 commented 2 years ago

在Kubernetes中,ServiceAccount主要用于给Pod提供权限。

ServiceAccount可以和role通过RoleBinding绑定在一起

y4h2 commented 2 years ago

Configure Service Accounts for Pods

Default Service Account

如果什么都不配置,会默认使用Default ServiceAccount

Manually create a service account API token

通过annotation可以把secret绑定到service account上

kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
  name: build-robot-secret
  annotations:
    kubernetes.io/service-account.name: build-robot
type: kubernetes.io/service-account-token
EOF

Add image pull secret to service account

在service account中可以配置image pull secrets

apiVersion: v1
kind: ServiceAccount
metadata:
  creationTimestamp: 2015-08-07T22:02:39Z
  name: default
  namespace: default
  uid: 052fb0f4-3d50-11e5-b066-42010af0d7b6
imagePullSecrets:
- name: myregistrykey
y4h2 commented 2 years ago

Managing Service Accounts

理解User Account和Service Account的区别

Service Account Automation