feat: add Loki query proxy for user-scoped log isolation#999
Conversation
Go-based reverse proxy that injects user_id filtering into LogQL queries based on the caller's Kubernetes identity (via TokenReview API). Bridges per-user Loki access until Perses adds native user-scoped querying. - proxy-source-configmap.yaml: Go source (main, auth, rewriter, config) - deployment-user.yaml: runs on stock ubi9/go-toolset, no custom image - rbac.yaml: SA + ClusterRoleBindings (logging-view, tokenreview) - service.yaml: ClusterIP on port 8080 - kustomization.yaml: namespace replacement for ClusterRoleBinding subjects
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tgitelman The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@tgitelman: The following test has Failed: OCI Artifact Browser URLInspecting Test Artifacts ManuallyTo inspect your test artifacts manually, follow these steps:
mkdir -p oras-artifacts
cd oras-artifacts
oras pull quay.io/opendatahub/odh-ci-artifacts:maas-group-test-dllxt |
Summary
user_idfiltering into LogQL queries based on the caller's Kubernetes identity (TokenReview API)ubi9/go-toolset:1.25— no custom image build requiredDesign
The proxy sits between Perses and the LokiStack gateway. When a non-admin user queries Loki:
username+groups| user_id="<username>"into every LogQL stream selectorcluster-logging-application-viewRBAC)Admins (
system:cluster-admins,system:masters) bypass filtering and see all logs.Files (5 files, 646 lines)
proxy-source-configmap.yamldeployment-user.yamlrbac.yamlservice.yamlkustomization.yamlSecurity
runAsNonRoot, drop ALL capabilities,RuntimeDefaultseccomp profilecluster-logging-application-view+tokenreviewscreate/loki/api/v1/query,/query_range)Bridging solution
This proxy is a temporary bridge until Perses adds native user-scoped Loki filtering (tracked in COO 1.5+). Known POC limitations:
go runon startup (~60-90s cold start)io.ReadAll)Prerequisites
openshift-loggingwith structured logs flowing from OTel Collectorloki/infrastructure: CA, RBAC, secret)Test plan
kustomize build deployment/components/observability/loki-proxy | kubectl apply -f -user_idfilter injected)user_id/labels,/series) return 403 for non-admin users