# services/maintenance/k3s-traefik-cleanup-rbac.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: k3s-traefik-cleanup
  namespace: maintenance

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: k3s-traefik-cleanup
rules:
  - apiGroups: ["k3s.cattle.io"]
    resources: ["addons"]
    verbs: ["get", "list", "watch", "delete"]
  - apiGroups: ["helm.cattle.io"]
    resources: ["helmcharts", "helmchartconfigs"]
    verbs: ["get", "list", "watch", "delete"]
  - apiGroups: ["batch"]
    resources: ["jobs"]
    verbs: ["get", "list", "watch", "delete"]
  - apiGroups: [""]
    resources: ["services", "serviceaccounts"]
    verbs: ["get", "list", "watch", "delete"]
  - apiGroups: ["apps"]
    resources: ["deployments"]
    verbs: ["get", "list", "watch", "delete"]
  - apiGroups: ["rbac.authorization.k8s.io"]
    resources: ["clusterroles", "clusterrolebindings"]
    verbs: ["get", "list", "watch", "delete"]

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: k3s-traefik-cleanup
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: k3s-traefik-cleanup
subjects:
  - kind: ServiceAccount
    name: k3s-traefik-cleanup
    namespace: maintenance
