{{- if .Values.rbac.create -}} apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: backstage-environment-manager labels: {{- include "backstage.labels" . | nindent 4 }} rules: # Namespace management for environment lifecycle - apiGroups: [""] resources: ["namespaces"] verbs: ["get", "list", "watch", "delete"] # Read access to environment resources for display, plus ConfigMap management # Used for: allhosts ConfigMap, environment-admin-users, environment-tracked-users - apiGroups: [""] resources: ["resourcequotas", "limitranges", "pods", "services", "configmaps"] verbs: ["get", "list", "watch", "create", "patch", "update"] # Pod logs access for Backstage Kubernetes plugin - apiGroups: [""] resources: ["pods/log"] verbs: ["get", "list"] # ServiceAccount token creation for kubeconfig generation - apiGroups: [""] resources: ["serviceaccounts/token"] verbs: ["create"] # Read ServiceAccounts to verify existence - apiGroups: [""] resources: ["serviceaccounts"] verbs: ["get", "list"] # Read secrets for database credential discovery - apiGroups: [""] resources: ["secrets"] verbs: ["get", "list"] - apiGroups: ["apps"] resources: ["deployments", "replicasets"] verbs: ["get", "list", "watch"] - apiGroups: ["networking.k8s.io"] resources: ["networkpolicies"] verbs: ["get", "list", "watch"] # ArgoCD Applications - for environment provisioning and cleanup - apiGroups: ["argoproj.io"] resources: ["applications"] verbs: ["get", "list", "watch", "create", "patch", "update", "delete"] # Argo Workflows - for monitoring environment provisioning status - apiGroups: ["argoproj.io"] resources: ["workflows"] verbs: ["get", "list", "watch"] # Gateway API HTTPRoutes - for displaying service URLs - apiGroups: ["gateway.networking.k8s.io"] resources: ["httproutes"] verbs: ["get", "list", "watch"] # Ingress - for displaying service URLs (legacy) - apiGroups: ["networking.k8s.io"] resources: ["ingresses"] verbs: ["get", "list", "watch"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: backstage-environment-manager-binding labels: {{- include "backstage.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: backstage-environment-manager subjects: - kind: ServiceAccount name: {{ include "backstage.serviceAccountName" . }} namespace: {{ .Values.namespaceOverride }} {{- end }}