10000 Support native sidecar by default by irenezhong2861 · Pull Request #56428 · istio/istio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support native sidecar by default #56428

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

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

irenezhong2861
Copy link
@irenezhong2861 irenezhong2861 commented May 27, 2025

Please provide a description of this PR:
Enables native sidecar by default

@irenezhong2861 irenezhong2861 requested review from a team as code owners May 27, 2025 17:46
Copy link
linux-foundation-easycla bot commented May 27, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@istio-policy-bot
Copy link

😊 Welcome @irenezhong2861! This is either your first contribution to the Istio istio repo, or it's been
a while since you've been here.

You can learn more about the Istio working groups, Code of Conduct, and contribution guidelines
by referring to Contributing to Istio.

Thanks for contributing!

Courtesy of your friendly welcome wagon.

@istio-testing istio-testing added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 27, 2025
@istio-testing
Copy link
Collaborator

Hi @irenezhong2861. Thanks for your PR.

I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@jaellio
Copy link
Contributor
jaellio commented May 27, 2025

/ok-to-test

@istio-testing istio-testing added ok-to-test Set this label allow normal testing to take place for a PR not submitted by an Istio org member. and removed needs-ok-to-test labels May 27, 2025
@irenezhong2861 irenezhong2861 force-pushed the irenezhong/default-native-sidecar branch 2 times, most recently from 8d311f3 to 08c79ad Compare May 27, 2025 19:34
@irenezhong2861 irenezhong2861 force-pushed the irenezhong/default-native-sidecar branch 2 times, most recently from aa7d148 to d39664b Compare May 27, 2025 19:45
{{ $nativeSidecar := (or (and (not (isset .ObjectMeta.Annotations `sidecar.istio.io/nativeSidecar`)) (eq (env "ENABLE_NATIVE_SIDECARS" "false") "true")) (eq (index .ObjectMeta.Annotations `sidecar.istio.io/nativeSidecar`) "true")) }}
{{ $nativeSidecar := .NativeSidecars }}
{{ if (isset .ObjectMeta.Annotations `sidecar.istio.io/nativeSidecar`) }}
{{ $nativeSidecar = eq (index .ObjectMeta.Annotations `sidecar.istio.io/nativeSidecar`) "true" }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this duplicated in the injection template logic?

Copy link
Author

Choose a reason for hiding this comment

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

Cleaned up this line. The injection-template is ran here, with params.nativeSidecar being passed in and read in injection-template.yaml via .NativeSidecars. The is to generate the template pod. Later on, the same annotation logic is used to generate the merged pod. Both places need code to overwrite the param.nativeSidecar value with the annotation value.

Name: "node-1",
},
Status: corev1.NodeStatus{
NodeInfo: corev1.NodeSystemInfo{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get more of a range of kubelet versions?

Copy link
Contributor

Choose a reason for hiding this comment

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

What about old kubelet versions? We should probably test that they have classic sidecars right?

Copy link
Author

Choose a reason for hiding this comment

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

added test case below with old version and added golden files. The new test case has one 1.33 node and one 1.28 node so native sidecar will be off without needing to set any flags.

log.Infof("Resetting the UserID of sideCar proxy as it matches with the app container for Pod %q", params.pod.Name)
sideCarProxy.SecurityContext.RunAsUser = nil
sideCarProxy.SecurityContext.RunAsGroup = nil
}
}
}

var nodes kclient.Client[*corev1.Node]
if wh.nodes != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably log or something if this isn't initialized for some reason


minVersion := 29
allNodesValid := false
for _, n := range nodes.List(metav1.NamespaceAll, klabels.Everything()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if someone adds an older node to their k8s cluster? Talk through the process in a code comment.

Copy link
Author

Choose a reason for hiding this comment

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

add comment around how older nodes will switch the native sidecar value to false since this checks versions of all nodes.

Copy link
Member
@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

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

this needs to take into account Kubernetes version of wait until the minimum supported version is GA. this would be about 3 years so a long wait.

If you look through the issue you'll see I had a WIP PR to do so that we could leverage.

edit: I skimmed quickly on my phone and I think I missed some logic, so I may be wrong - will look closer soon. Sorry!

return false
}

minVersion := 29
Copy link
Member

Choose a reason for hiding this comment

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

should do 1.33 imo. we cannot GA a beta feature

6D4E Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to this - I missed it in my initial pass. There is also a bug in older versions that doesn't really affect Istio, but still shouldn't expose users to it by default if we can help it IMO

Copy link
Member

Choose a reason for hiding this comment

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

in my initial PR I had a way for a user to say "automatically detect, minimum beta" as an opt-in to 1.29. but for default should be 1.33 IMO

Copy link
Member

Choose a reason for hiding this comment

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

if the pod has a node name assigned explicitly (very rare) we can also probably check only that node. maybe niche though

Copy link
Author

Choose a reason for hiding this comment

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

Updated the version to 1.33, with a branch to check if only the corresponding node if pod.Spec.nodeName is not empty. Currently have a log.warn if the the node name is set but the node can't be found, and not enabling native sidecar in that case, open to suggestions!

Copy link
Author

Choose a reason for hiding this comment

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

With this kubelet version check though, I don't think we need to wait until 1.33 is the min supported k8s version. It handles the case of nodes on ineligible versions by not defaulting native side cars for them. We might not need a check like this at all once 1.33 is the min version and just enable all by default.

Copy link
Contributor
@keithmattix keithmattix Jun 6, 2025

Choose a reason for hiding this comment

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

Yes, once we get past the supported 1.33 version skew, we could remove a lot of these checks, though folks who are running LTS in a cloud provider need to keep them around

Name: "node-1",
},
Status: corev1.NodeStatus{
NodeInfo: corev1.NodeSystemInfo{
Copy link
Contributor

Choose a reason for hiding this comment

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

What about old kubelet versions? We should probably test that they have classic sidecars right?

@irenezhong2861 irenezhong2861 force-pushed the irenezhong/default-native-sidecar branch from b3cc938 to 74b4cce Compare June 5, 2025 00:41
@irenezhong2861
Copy link
Author

/test integ-ambient-mc

@irenezhong2861 irenezhong2861 force-pushed the irenezhong/default-native-sidecar branch from e4fc569 to 553567d Compare June 16, 2025 22:02
@istio-testing istio-testing removed the needs-rebase Indicates a PR needs to be rebased before being merged label Jun 16, 2025
Copy link
Member
@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

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

I am sorry for this late comment, but i am starting to question whether this is a sane default... the thing I worry about is a user having 1000 nodes and requiring native sidecars, in prod, all good.

Now someone adds some random node pool completely unrelated to istio, where Istio pods cannot even run, and now cluster wide we make a radical change to their (new) pods...

The alternative seems to be to wait ~3 years for this to rollout to everyone which is pretty bad too.

At minimum I would like that users to be able to explicitly say YES to native sidecars. Before we had yes/no, now we have no/auto. We MUST have an explicit YES option

nodes = wh.nodes.ForCluster(cluster.ID(clusterID))
params.nativeSidecar = DetectNativeSidecar(nodes, pod.Spec.NodeName)
} else {
// only enable native sidecars if the feature is explicitly enabled
Copy link
Member

Choose a reason for hiding this comment

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

IIRC this will warn on each injection request a confusing message for users that disable native sidecars

@@ -797,6 +801,16 @@ func IntoObject(injector Injector, sidecarTemplate Templates, valuesConfig Value
warningHandler(warningStr)
return out, nil
}

var nativeSidecar bool
if injector != nil && injector.GetKubeClient() != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This is pretty sketchy since at least for injection we know the Pod is being created at that time. For kube-inject it is checked into CI.

But not a big deal since kube-inject is not very common

@howardjohn
Copy link
Member

LGTM aside from that comment though

@irenezhong2861
Copy link
Author

I am sorry for this late comment, but i am starting to question whether this is a sane default... the thing I worry about is a user having 1000 nodes and requiring native sidecars, in prod, all good.

Now someone adds some random node pool completely unrelated to istio, where Istio pods cannot even run, and now cluster wide we make a radical change to their (new) pods...

The alternative seems to be to wait ~3 years for this to rollout to everyone which is pretty bad too.

At minimum I would like that users to be able to explicitly say YES to native sidecars. Before we had yes/no, now we have no/auto. We MUST have an explicit YES option

So we'd have yes/auto/no as the choices, and

  • if yes, enable regardless of node versions
  • follow the current node verification logic if auto/unset
  • does not enable native sidecar if no?

and if the feature is unset, default to auto? This will need to be called out so users acknowledge they have the action item of setting a value here for their intended behaviors.

@howardjohn
Copy link
Member

So we'd have yes/auto/no as the choices, and

Yep.

I am still not 100% convinced its safe to ever use "auto" (and 'yes' is definitely not able to be default for years) but it may be worth it to do so..

I do also worry users will see the opposite issue when they upgrade their first k8s node

@irenezhong2861
Copy link
Author

/test integ-cni

@istio-testing istio-testing added the needs-rebase Indicates a PR needs to be rebased before being merged label Jun 28, 2025
@istio-testing
Copy link
Collaborator

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR needs to be rebased before being merged ok-to-test Set this label allow normal testing to take place for a PR not submitted by an Istio org member. release-notes-none Indicates a PR that does not require release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0