apiVersion: v1
kind: ServiceAccount
metadata:
  name: easyai-ai-gateway
  labels:
    app.kubernetes.io/part-of: easyai-ai-gateway
automountServiceAccountToken: true
imagePullSecrets:
  - name: easyai-registry
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: easyai-gateway-security-events
rules:
  - apiGroups: [""]
    resources: ["secrets"]
    resourceNames: ["easyai-gateway-security-events"]
    verbs: ["get", "update", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: easyai-gateway-security-events
subjects:
  - kind: ServiceAccount
    name: easyai-ai-gateway
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: easyai-gateway-security-events
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: easyai-capacity-controller
  labels:
    app.kubernetes.io/name: easyai-capacity-controller
    app.kubernetes.io/part-of: easyai-ai-gateway
automountServiceAccountToken: true
imagePullSecrets:
  - name: easyai-registry
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: easyai-capacity-controller
rules:
  - apiGroups: ["apps"]
    resources: ["deployments"]
    resourceNames: ["easyai-worker-ningbo", "easyai-worker-hongkong"]
    verbs: ["get"]
  - apiGroups: ["apps"]
    resources: ["deployments/scale"]
    resourceNames: ["easyai-worker-ningbo", "easyai-worker-hongkong"]
    verbs: ["get", "update", "patch"]
  - apiGroups: [""]
    resources: ["pods"]
    verbs: ["get", "list", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: easyai-capacity-controller
subjects:
  - kind: ServiceAccount
    name: easyai-capacity-controller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: easyai-capacity-controller
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: easyai-capacity-controller
rules:
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["get", "list"]
  - apiGroups: ["metrics.k8s.io"]
    resources: ["nodes", "pods"]
    verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: easyai-capacity-controller
subjects:
  - kind: ServiceAccount
    name: easyai-capacity-controller
    namespace: easyai
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: easyai-capacity-controller
