Skip to content

feat: Update Flagd container injection to native Kubernetes sidecar#807

Draft
Y0sh1dk wants to merge 7 commits intoopen-feature:mainfrom
Y0sh1dk:fix/sidecar-injection-fix
Draft

feat: Update Flagd container injection to native Kubernetes sidecar#807
Y0sh1dk wants to merge 7 commits intoopen-feature:mainfrom
Y0sh1dk:fix/sidecar-injection-fix

Conversation

@Y0sh1dk
Copy link
Copy Markdown
Contributor

@Y0sh1dk Y0sh1dk commented Mar 9, 2026

This PR

Fixes #806 by updating the flagd container injection to inject as a sidecar

Related Issues

Fixes #806

Notes

How to test

Minimal scenario to test documented in #806

Signed-off-by: Yosiah de Koeyer <dev@yosiahdekoeyer.dev>
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 refactors the flagd container injection logic within the OpenFeature operator to leverage native Kubernetes sidecar containers, addressing a known issue. This change aligns the operator with modern Kubernetes practices for managing auxiliary containers, improving the lifecycle management of flagd instances. It's important to note that this update introduces a breaking change for older Kubernetes versions (pre-v1.29) that do not support built-in sidecar containers.

Highlights

  • Native Kubernetes Sidecar Injection: Updated the flagd container injection mechanism to utilize native Kubernetes sidecar containers, aligning with modern Kubernetes practices for auxiliary container management.
  • Flagd Container Restart Policy: Introduced a RestartPolicy of Always for the injected flagd sidecar container to ensure continuous operation.
  • Injection Logic Refinement: Modified the addFlagdContainer logic to target PodSpec.InitContainers instead of PodSpec.Containers for flagd injection.
  • Breaking Change Notification: Noted that this change is breaking for Kubernetes clusters older than v1.29, as they do not support built-in sidecar containers.
Changelog
  • internal/common/flagdinjector/flagdinjector.go
    • Imported k8s.io/utils/ptr for pointer utilities.
    • Added RestartPolicy: ptr.To(corev1.ContainerRestartPolicyAlways) to the generated flagd container.
    • Modified addFlagdContainer to append and update spec.InitContainers instead of spec.Containers.
  • internal/common/flagdinjector/flagdinjector_test.go
    • Imported corev1 and k8s.io/utils/ptr.
    • Removed several blank lines for cleaner code.
    • Updated calls to generatePod to include a new initContainers parameter, passing nil where appropriate.
    • Modified assertions to check expectedPod.Spec.InitContainers[0] instead of expectedPod.Spec.Containers[1].
    • Updated the generatePod function signature and implementation to accept and utilize an initContainers slice.
    • Adjusted getExpectedPod to define the flagd container within InitContainers instead of Containers, and added the RestartPolicy.
Activity
  • No human activity (comments, reviews, etc.) has been recorded on this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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-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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Y0sh1dk Y0sh1dk changed the title Update Flagd container injection to native Kubernetes sidecar feat: Update Flagd container injection to native Kubernetes sidecar Mar 9, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the flagd container injection to use native Kubernetes sidecar containers, which is a great improvement for clusters that support this feature (v1.29+). The changes correctly modify the injection logic to place the flagd container into initContainers with restartPolicy: Always. The tests have been updated accordingly to validate the new behavior. The implementation is solid. I've left one minor comment regarding import consistency in a test file.

Comment on lines 17 to 18
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The package k8s.io/api/core/v1 is imported twice with different aliases (corev1 and v1). This is confusing and should be consolidated. It's recommended to use a single alias, corev1 is the standard convention, and replace all occurrences of v1. with corev1. throughout the file for consistency.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.34%. Comparing base (499661e) to head (ff9329a).
⚠️ Report is 78 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #807       +/-   ##
===========================================
- Coverage   86.51%   72.34%   -14.17%     
===========================================
  Files          19       30       +11     
  Lines        1587     1924      +337     
===========================================
+ Hits         1373     1392       +19     
- Misses        173      484      +311     
- Partials       41       48        +7     
Files with missing lines Coverage Δ
internal/common/flagdinjector/flagdinjector.go 88.77% <100.00%> (ø)

... and 25 files with indirect coverage changes

Flag Coverage Δ
unit-tests 72.34% <100.00%> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Y0sh1dk added 3 commits March 9, 2026 16:50
Signed-off-by: Yosiah de Koeyer <dev@yosiahdekoeyer.dev>
Signed-off-by: Yosiah de Koeyer <dev@yosiahdekoeyer.dev>
Signed-off-by: Yosiah de Koeyer <dev@yosiahdekoeyer.dev>
@Y0sh1dk Y0sh1dk force-pushed the fix/sidecar-injection-fix branch from ebc2e01 to ff9329a Compare March 9, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flagd sidecar injection causes evaluation errors on pod creation/termination

1 participant