apiVersion: v1
kind: ServiceAccount
metadata:
  name: ops-service
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: ops-service
rules:
  - apiGroups: [""]
    resources: ["configmaps", "pods"]
    verbs: ["get", "list", "delete"]
  - apiGroups: [""]
    resources: ["pods/exec"]
    verbs: ["create"]
  - apiGroups: ["apps"]
    resources: ["statefulsets"]
    verbs: ["get", "list"]
  - apiGroups: ["autoscaling"]
    resources: ["horizontalpodautoscalers"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["batch"]
    resources: ["cronjobs"]
    verbs: ["get", "list"]
  - apiGroups: ["gateway.serverless.pingcap.com"]
    resources: ["gateways"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["pingcap.com"]
    resources: ["tidbclusters"]
    verbs: ["get", "list"]
  - apiGroups: ["serverless.pingcap.com"]
    resources: ["tidbautoscalings"]
    verbs: ["get", "list", "watch", "update", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: ops-service
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: ops-service
subjects:
  - kind: ServiceAccount
    name: ops-service
    namespace: tidb-admin
