Skip to content

Fix Istio sidecar injection by moving from annotations to labels #2527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

madmecodes
Copy link
Contributor

@madmecodes madmecodes commented Mar 14, 2025

What this PR does / why we need it:

This PR fixes the Istio sidecar injection configuration by moving from using annotations to using labels in Katib components.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Issue: kubeflow/manifests#2798
Part of PR: kubeflow/manifests#3044

Checklist:

  • Docs included if any changes are user facing

@juliusvonkohout
Copy link
Member

/ok-to-test

@juliusvonkohout
Copy link
Member

@andreyvelich @Electronic-Waste for approval and merging

Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

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

I'm wondering if we should fix all things: https://github.com/search?q=repo%3Akubeflow%2Fkatib%20sidecar.istio.io%2Finject&type=code

If not, Katib with istio might not work well.

@juliusvonkohout
Copy link
Member

I'm wondering if we should fix all things: https://github.com/search?q=repo%3Akubeflow%2Fkatib%20sidecar.istio.io%2Finject&type=code

If not, Katib with istio might not work well.

Probably Yes, according to the istio documentations it should be a label https://istio.io/latest/docs/setup/additional-setup/sidecar-injection/#controlling-the-injection-policy

Copy link
Member

@andreyvelich andreyvelich left a comment

Choose a reason for hiding this comment

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

@madmecodes Thank you for updating it!
Please can you also update other places where we set these labels.
For example:

AnnotationIstioSidecarInjectName = "sidecar.istio.io/inject"

@madmecodes
Copy link
Contributor Author

@madmecodes Thank you for updating it! Please can you also update other places where we set these labels. For example:

AnnotationIstioSidecarInjectName = "sidecar.istio.io/inject"

Screenshot 2025-03-19 at 10 42 45 PM

@andreyvelich
I was changing that, if i change the variables to this, utils/annotation also need to be changed

func SuggestionAnnotations(instance *suggestionsv1beta1.Suggestion) map[string]string {

which is dependent on

Annotations: util.SuggestionAnnotations(s),

I shall proceed with these changes and create a appropriate PR right?

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@google-oss-prow google-oss-prow bot added size/M and removed size/XS labels Mar 19, 2025
@madmecodes
Copy link
Contributor Author

@andreyvelich looking forward for the feedback

@juliusvonkohout
Copy link
Member

@madmecodes please rebase (not merge) to master and fix the linting tests
image

…codebase

Replace annotations with labels for Istio sidecar injection according to Istio recommendations. Update conformance tests, examples, constants, composers, and utilities to use the new label-based approach consistently.

Signed-off-by: madmecodes <[email protected]>
@madmecodes madmecodes force-pushed the fix-istio-sidecar-injection branch from 3962524 to 6759bb1 Compare March 20, 2025 13:08
@madmecodes
Copy link
Contributor Author

Screenshot 2025-03-20 at 6 30 32 PM Screenshot 2025-03-20 at 6 30 46 PM rebased as requested Screenshot 2025-03-20 at 6 40 22 PM Screenshot 2025-03-20 at 6 40 37 PM

@madmecodes
Copy link
Contributor Author

maybe, in this repository also, we can add automatic, pre-commit run check when we do : git commit -s -m ""

@madmecodes
Copy link
Contributor Author

@madmecodes Thank you for updating it! Please can you also update other places where we set these labels. For example:

AnnotationIstioSidecarInjectName = "sidecar.istio.io/inject"

@andreyvelich Hey! i did update the changes, is there anything more thats need to be done? I'm open to the feedback.

@madmecodes
Copy link
Contributor Author

madmecodes commented May 3, 2025

@anencore94 @andreyvelich @Electronic-Waste any updates, regarding this PR? i am for the feedback.

@@ -95,7 +95,7 @@ def generate_trial_template() -> V1beta1TrialTemplate:
"kind": "Job",
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We might need to also update this one: https://github.com/kubeflow/trainer/blob/release-1.9/sdk/python/kubeflow/training/utils/utils.py#L259

Made the respective Pull Request in the trainer/release-1.9 kubeflow/trainer#2637


func appendAnnotation(annotations map[string]string, newAnnotationName string, newAnnotationValue string) map[string]string {
// AppendIstioSidecarLabel adds the Istio sidecar injection label to a labels map
func AppendIstioSidecarLabel(labels map[string]string) map[string]string {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved the func in labels.go

@google-oss-prow google-oss-prow bot removed the size/M label May 6, 2025
@andreyvelich
Copy link
Member

@juliusvonkohout @madmecodes Just one question, in which release Istio changed this property from annotations to labels?
Previously, we disable the sidecar injection using annotations and it works.

@madmecodes
Copy link
Contributor Author

madmecodes commented May 8, 2025

@juliusvonkohout @madmecodes Just one question, in which release Istio changed this property from annotations to labels? Previously, we disable the sidecar injection using annotations and it works.

shift from annotations to labels for sidecar injection in Istio occurred in version 1.2.

Labels: https://istio.io/latest/docs/setup/additional-setup/sidecar-injection/#controlling-the-injection-policy

annotations: https://istio.io/v1.1/docs/setup/kubernetes/additional-setup/sidecar-injection/#policy

https://istio.io/v1.2/docs/setup/kubernetes/additional-setup/sidecar-injection/#deploying-an-app

@andreyvelich
Copy link
Member

Oh, I see, thanks for letting me know @madmecodes!

Copy link
Member

@andreyvelich andreyvelich left a comment

Choose a reason for hiding this comment

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

Thank you for this effort @madmecodes!
/lgtm
/approve

Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andreyvelich

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot merged commit 1ebd5e4 into kubeflow:master May 9, 2025
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants