Deployment 添加serviceaccount

创建了一个服务,需要操作集群,默认权限无法操作。

RBAC

apiVersion: v1
kind: ServiceAccount
metadata:
  name: deploy-manager
  namespace: office
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: deploy-manager
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: deploy-manager
    namespace: office

deployment

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: nginx
    version: latest
  name: nginx
  namespace: office
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  minReadySeconds: 3
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nginx        
        version: latest
    spec:
      containers:
      - env:[]
        image: nginx:latest
        imagePullPolicy: Always
        name: nginx        
        ports:
        - containerPort: 80
        resources: {}
        restartPolicy: Always
        serviceAccount: deploy-manager
        serviceAccountName: deploy-manager

你可能感兴趣的:(Deployment 添加serviceaccount)