|
| 1 | +# KEP-8905: Native Sidecar Support |
| 2 | + |
| 3 | +<!-- toc --> |
| 4 | +- [Summary](#summary) |
| 5 | + - [Goals](#goals) |
| 6 | + - [Non-Goals](#non-goals) |
| 7 | +- [Proposal](#proposal) |
| 8 | +- [Design Details](#design-details) |
| 9 | + - [Recommendations](#recommendations) |
| 10 | + - [Update / Admission](#update--admission) |
| 11 | + - [Test Plan](#test-plan) |
| 12 | + - [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy) |
| 13 | +- [Alternatives](#alternatives) |
| 14 | +<!-- /toc --> |
| 15 | + |
| 16 | +## Summary |
| 17 | + |
| 18 | +This proposal adds support for native sidecar containers (init containers with `restartPolicy: Always`) in Vertical Pod Autoscaler. |
| 19 | + |
| 20 | +Kubernetes 1.28 introduced native sidecar containers. These are init containers that start before the main containers and continue running during the lifecycle of the Pod. VPA currently supports standard containers and regular init containers, but it should also support recommending resources for these new native sidecar containers to ensure they are right-sized. |
| 21 | +Addresses [issue #7229](https://github.com/kubernetes/autoscaler/issues/7229) |
| 22 | + |
| 23 | +### Goals |
| 24 | + |
| 25 | +- Allow VPA Recommender to generate resource recommendations for native sidecar containers. |
| 26 | +- Ensure VPA Updater and Admission Controller can apply recommendations to native sidecar containers. |
| 27 | + |
| 28 | +### Non-Goals |
| 29 | + |
| 30 | +- Support for sidecar containers in Kubernetes versions older than 1.28. |
| 31 | + |
| 32 | +## Proposal |
| 33 | + |
| 34 | +The proposal is to introduce a new feature gate `NativeSidecar` in VPA. When enabled, VPA components will recognize and handle native sidecar containers. |
| 35 | + |
| 36 | +## Design Details |
| 37 | + |
| 38 | +### Recommendations |
| 39 | + |
| 40 | +The `ClusterFeeder` in Recommender is updated to identify init containers with `restartPolicy: Always` as native sidecars. Native sidecars will be treated exactly like normal containers from recommenders perspective. The VPA custom resource definition will remain the same due to the fact container names are unique within a pod. All recommendation status updates for native sidecars will added with other container recommendations. |
| 41 | + |
| 42 | +### Update / Admission |
| 43 | + |
| 44 | +The patch generation logic is updated to target `/spec/initContainers` for native sidecar containers. Updater and Admission will work almost entirely the same due to the unique container naming of a pod they will be able to find which container needs updates from the VPA status. |
| 45 | + |
| 46 | +### Test Plan |
| 47 | + |
| 48 | +The following test scenarios will be added to e2e tests. |
| 49 | + |
| 50 | +- Admission applies recommendations to native sidecars. |
| 51 | +- Updater will update sidecar container resources in-place or evict. |
| 52 | +- Admission will patch sidecar container resources. |
| 53 | +- When the feature gate `NativeSidecar` is false VPA components will not modify native sidecars. |
| 54 | + |
| 55 | +### Upgrade / Downgrade Strategy |
| 56 | + |
| 57 | +#### Upgrade |
| 58 | + |
| 59 | +On upgrade of the VPA to 1.6.0 (tentative release version), nothing will change, |
| 60 | +VPAs will continue to work as before. |
| 61 | + |
| 62 | +Users can use the new `NativeSidecar` by enabling the alpha Feature Gate (which defaults to disabled) |
| 63 | +by passing `--feature-gates=NativeSidecar=true` to the VPA components. |
| 64 | + |
| 65 | +#### Downgrade |
| 66 | + |
| 67 | +On downgrade of VPA from 1.6.0 (tentative release version), nothing will change. |
| 68 | +VPAs will continue to work as previously. Checkpoints may contain sidecar resource information until updated, but updater and admission will modify sidecar resources. |
| 69 | + |
| 70 | +## Alternatives |
| 71 | + |
| 72 | +### Treat as Standard Containers |
| 73 | + |
| 74 | +We could treat them as standard containers, but they are technically init containers in the Pod spec, so the patch path would be incorrect (`/spec/containers` vs `/spec/initContainers`). |
0 commit comments