diff --git a/infra/k8s/cluster-observer.yaml b/infra/k8s/cluster-observer.yaml new file mode 100644 index 0000000..4b4f93a --- /dev/null +++ b/infra/k8s/cluster-observer.yaml @@ -0,0 +1,70 @@ +# Read-only cluster observer for WishForge's Copilot and health checks. +# +# Purpose: let the platform read cluster state (resource accounting, service inventory, live +# alerts) without any ability to change it. The identity can list and watch workloads, events, +# persistent storage, quotas and metrics in every namespace, and read Pod logs for triage. +# +# Deliberately excluded: Secrets and ConfigMaps (they hold credentials and connection strings), +# pods/exec and pods/portforward (they are command execution paths), and every write verb. The +# only verbs granted are get, list and watch. +# +# Apply with an administrator kubeconfig: +# kubectl apply -f infra/k8s/cluster-observer.yaml +# The long-lived token lives in Secret wishforge-observer-token; deleting that Secret revokes it. +apiVersion: v1 +kind: ServiceAccount +metadata: + name: wishforge-observer + namespace: droboticflow-fanyu + labels: { app.kubernetes.io/part-of: wishforge, app.kubernetes.io/component: cluster-observer } +automountServiceAccountToken: false +--- +# Long-lived token for the read-only kubeconfig that WishForge keeps outside the repository. +apiVersion: v1 +kind: Secret +type: kubernetes.io/service-account-token +metadata: + name: wishforge-observer-token + namespace: droboticflow-fanyu + labels: { app.kubernetes.io/part-of: wishforge, app.kubernetes.io/component: cluster-observer } + annotations: { kubernetes.io/service-account.name: wishforge-observer } +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: wishforge-observer + labels: { app.kubernetes.io/part-of: wishforge, app.kubernetes.io/component: cluster-observer } +rules: + - apiGroups: [''] + resources: [nodes, namespaces, persistentvolumes] + verbs: [get, list, watch] + - apiGroups: [''] + resources: + [pods, pods/log, events, services, persistentvolumeclaims, resourcequotas, limitranges] + verbs: [get, list, watch] + - apiGroups: [apps] + resources: [deployments, statefulsets, replicasets, daemonsets] + verbs: [get, list, watch] + - apiGroups: [batch] + resources: [jobs, cronjobs] + verbs: [get, list, watch] + - apiGroups: [storage.k8s.io] + resources: [storageclasses] + verbs: [get, list, watch] + - apiGroups: [metrics.k8s.io] + resources: [nodes, pods] + verbs: [get, list, watch] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: wishforge-observer + labels: { app.kubernetes.io/part-of: wishforge, app.kubernetes.io/component: cluster-observer } +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: wishforge-observer +subjects: + - kind: ServiceAccount + name: wishforge-observer + namespace: droboticflow-fanyu