diff --git a/apps/base/logging/agent-observability-rolebinding.yaml b/apps/base/logging/agent-observability-rolebinding.yaml new file mode 100644 index 0000000..9a96ac5 --- /dev/null +++ b/apps/base/logging/agent-observability-rolebinding.yaml @@ -0,0 +1,16 @@ +--- +# Confines the agent-observability service account (in vm-system) to the +# agent-observability ClusterRole within this namespace. +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: agent-observability + namespace: logging +subjects: + - kind: ServiceAccount + name: agent-observability + namespace: vm-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: agent-observability diff --git a/apps/base/logging/kustomization.yaml b/apps/base/logging/kustomization.yaml index cc3dc17..af2bdc3 100644 --- a/apps/base/logging/kustomization.yaml +++ b/apps/base/logging/kustomization.yaml @@ -17,6 +17,7 @@ resources: - configmap_logarchiver.yaml - deployment_logarchiver.yaml - logviewer + - agent-observability-rolebinding.yaml # Vector pipelines are the single source of truth (also validated by # `vector test` in CI). Mounted into each tier via `existingConfigMaps`. diff --git a/apps/base/observability/agent-observability-rolebinding.yaml b/apps/base/observability/agent-observability-rolebinding.yaml new file mode 100644 index 0000000..bc6faba --- /dev/null +++ b/apps/base/observability/agent-observability-rolebinding.yaml @@ -0,0 +1,16 @@ +--- +# Confines the agent-observability service account (in vm-system) to the +# agent-observability ClusterRole within this namespace. +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: agent-observability + namespace: observability +subjects: + - kind: ServiceAccount + name: agent-observability + namespace: vm-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: agent-observability diff --git a/apps/base/observability/kustomization.yaml b/apps/base/observability/kustomization.yaml index 93d5367..1a77cb3 100644 --- a/apps/base/observability/kustomization.yaml +++ b/apps/base/observability/kustomization.yaml @@ -13,3 +13,4 @@ resources: - httproute.yaml - vmpodscrape-cnpg.yaml - vmpodscrape-traefik.yaml + - agent-observability-rolebinding.yaml diff --git a/apps/base/vm-system/agent-observability-rbac.yaml b/apps/base/vm-system/agent-observability-rbac.yaml new file mode 100644 index 0000000..da8921e --- /dev/null +++ b/apps/base/vm-system/agent-observability-rbac.yaml @@ -0,0 +1,50 @@ +--- +# Static service account that Vault's kubernetes secret engine mints scoped +# tokens for (agent-observability role). RBAC is confined to the metrics and +# logging namespaces via the per-namespace RoleBindings, not a +# ClusterRoleBinding. Workloads and VictoriaMetrics CRs are deliberately +# patch/update only: deleting a VMCluster or VLCluster destroys data. +apiVersion: v1 +kind: ServiceAccount +metadata: + name: agent-observability + namespace: vm-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: agent-observability +rules: + - apiGroups: ["operator.victoriametrics.com"] + resources: ["*"] + verbs: ["get", "list", "watch", "create", "patch", "update"] + - apiGroups: ["apps"] + resources: ["deployments", "statefulsets", "daemonsets"] + verbs: ["get", "list", "watch", "patch", "update"] + # delete permits a rolling restart without granting workload deletion. + - apiGroups: [""] + resources: ["pods"] + verbs: ["get", "list", "watch", "delete"] + - apiGroups: [""] + resources: ["pods/log"] + verbs: ["get"] + - apiGroups: [""] + resources: ["services", "configmaps", "endpoints", "events"] + verbs: ["get", "list", "watch"] + - apiGroups: ["gateway.networking.k8s.io"] + resources: ["gateways", "httproutes"] + verbs: ["get", "list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: agent-observability + namespace: vm-system +subjects: + - kind: ServiceAccount + name: agent-observability + namespace: vm-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: agent-observability diff --git a/apps/base/vm-system/kustomization.yaml b/apps/base/vm-system/kustomization.yaml index 5122f9e..e775f55 100644 --- a/apps/base/vm-system/kustomization.yaml +++ b/apps/base/vm-system/kustomization.yaml @@ -4,3 +4,4 @@ kind: Kustomization resources: - namespace.yaml + - agent-observability-rbac.yaml