# Role for namespace-scoped Helm upgrade operations
# Grants permissions for Helm release management and {product} workloads
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: helm-release-upgrader
  namespace: mission-control
rules:
  # Helm release management
  - apiGroups: [""]
    resources: ["secrets"]
    verbs: ["get", "list", "create", "update", "patch", "delete"]

  # Core workload management
  - apiGroups: ["apps"]
    resources: ["deployments", "statefulsets", "daemonsets", "replicasets"]
    verbs: ["get", "list", "create", "update", "patch", "delete"]

  - apiGroups: [""]
    resources: ["pods", "services", "configmaps", "persistentvolumeclaims", "serviceaccounts"]
    verbs: ["get", "list", "create", "update", "patch", "delete"]

  # Batch jobs
  - apiGroups: ["batch"]
    resources: ["jobs", "cronjobs"]
    verbs: ["get", "list", "create", "update", "patch", "delete"]

  # RBAC
  - apiGroups: ["rbac.authorization.k8s.io"]
    resources: ["roles", "rolebindings"]
    verbs: ["get", "list", "create", "update", "patch", "delete"]

  # Networking
  - apiGroups: ["networking.k8s.io"]
    resources: ["ingresses", "networkpolicies"]
    verbs: ["get", "list", "create", "update", "patch", "delete"]

  # cert-manager
  - apiGroups: ["cert-manager.io"]
    resources: ["certificates", "issuers", "certificaterequests"]
    verbs: ["get", "list", "create", "update", "patch", "delete"]

  # Policy
  - apiGroups: ["policy"]
    resources: ["poddisruptionbudgets"]
    verbs: ["get", "list", "create", "update", "patch", "delete"]

  # Autoscaling
  - apiGroups: ["autoscaling"]
    resources: ["horizontalpodautoscalers"]
    verbs: ["get", "list", "create", "update", "patch", "delete"]
