[tenant] fix: allow egress to vlogs in parent tenants - #1971
[tenant] fix: allow egress to vlogs in parent tenants#1971Aleksei Sviridkin (lexfrei) wants to merge 1 commit into
Conversation
Summary of ChangesHello Aleksei Sviridkin (@lexfrei), I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical connectivity issue preventing nested Kubernetes clusters from sending logs to parent tenant Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on Gemini (@gemini-code-assist) comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
📝 WalkthroughWalkthroughA conditional block was added to the tenant network policy template to allow egress traffic to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Code Review
This pull request correctly adds an egress rule to the CiliumClusterwideNetworkPolicy to allow traffic to vlogs in parent tenants, fixing an issue with log collection from nested clusters. The change mirrors the existing rule for vminsert. However, this introduces code duplication. My review includes a suggestion to refactor the policy to combine the rules for vminsert and vlogs, which would improve the maintainability of this Helm template.
| {{- if ne (include "tenant.name" .) "tenant-root" }} | ||
| - toEndpoints: | ||
| {{- if hasPrefix "tenant-" .Release.Namespace }} | ||
| {{- $parts := splitList "-" .Release.Namespace }} | ||
| {{- range $i, $v := $parts }} | ||
| {{- if ne $i 0 }} | ||
| - matchLabels: | ||
| "k8s:app.kubernetes.io/name": "vlogs" | ||
| "k8s:io.kubernetes.pod.namespace": {{ join "-" (slice $parts 0 (add $i 1)) }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} |
There was a problem hiding this comment.
This block is a near-duplicate of the vminsert rule on lines 43-55, which harms maintainability. Instead of adding a new block, you can combine the logic for both vlogs and vminsert into a single rule.
I recommend deleting this new block and modifying the vminsert block to use matchExpressions, which can match multiple values for a label. This makes the policy more concise and easier to extend.
Here's how you could refactor the vminsert block to include vlogs:
- toEndpoints:
{{- if hasPrefix "tenant-" .Release.Namespace }}
{{- $parts := splitList "-" .Release.Namespace }}
{{- range $i, $v := $parts }}
{{- if ne $i 0 }}
- matchExpressions:
- key: "k8s:io.kubernetes.pod.namespace"
operator: "In"
values:
- {{ join "-" (slice $parts 0 (add $i 1)) | quote }}
- key: "k8s:app.kubernetes.io/name"
operator: "In"
values:
- "vminsert"
- "vlogs"
{{- end }}
{{- end }}
{{- end }}This single toEndpoints rule would replace the two separate rules for vminsert and vlogs.
There was a problem hiding this comment.
Done, refactored to use matchExpressions combining vminsert and vlogs into a single rule.
Combine vminsert and vlogs egress rules using matchExpressions to reduce code duplication. This allows Fluent Bit in nested Kubernetes clusters to send logs to VLogs in parent tenants. Without this fix, logs from nested clusters timeout because Cilium blocks traffic to vlogs pods while metrics to vminsert work fine. Fixes #1970 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
adbaeb0 to
cd2483d
Compare
|
This is probably a bug; we need to redesign this somehow (for example, by using a user-space proxy). |
What this PR does
Adds
vlogsto the tenant egressCiliumClusterwideNetworkPolicy, mirroring the existingvminsertrule.Currently, nested Kubernetes clusters can send metrics to parent cluster's
vminsert(explicitly allowed), but logs tovlogsare blocked by Cilium because there's no matching egress rule.This causes Fluent Bit connection timeouts:
Fixes #1970
Release note
Summary by CodeRabbit