3.4.17. ServiceAccount.yaml¶
apiVersion: v1
kind: ServiceAccount
metadata:
name: aliyun-acr # 指定sa名字
namespace: kube-system
annotations:
kubernetes.io/enforce-mountable-secrets: "true" # 使用此sa的pod只能挂载下面secrets指定的密钥
secrets:
- name: aliyun-acr-g2mwh # 指定可挂载的secret
imagePullSecrets:
- name: secrets1 # 使用此sa的pod会自动添加此密钥
- name: secrets2 # 可指定多个
创建sa和clusterrolebinding:
$ kubectl create serviceaccount website-controller
$ kubectl create clusterrolebinding website-controller --clusterrole=cluster-admin \
--serviceaccount=default:website-controller